From 6696d08bafc1fd5db2611febaa471337d10039df Mon Sep 17 00:00:00 2001 From: samtin0x <40127309+samtin0x@users.noreply.github.com> Date: Tue, 17 Sep 2024 11:13:12 +0100 Subject: [PATCH] Add subaccounts explanation to docs --- .../documentation/account_details.md | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/v4-client-py-v2/documentation/account_details.md b/v4-client-py-v2/documentation/account_details.md index beb2b158..0da770a4 100644 --- a/v4-client-py-v2/documentation/account_details.md +++ b/v4-client-py-v2/documentation/account_details.md @@ -1,6 +1,26 @@ -# Getting Account Order Information +# Getting Account and Subaccount Information -This guide demonstrates how to retrieve information about your account's orders using the dYdX Python SDK. +This guide demonstrates how to retrieve information about your account, subaccounts, and orders using the dYdX Python SDK. + +## Understanding Accounts and Subaccounts + +**Accounts** +- Your primary identity on dYdX, linked to your blockchain wallet address. +- Acts as a container for all your trading activities and subaccounts. + +**Subaccounts** +- Separate trading entities within your main account. +- Each has its own balance, positions, orders, and trading history. +- Every account starts with subaccount 0; additional subaccounts can be created. + +**Key Points** +- Subaccounts allow segregation of trading strategies and risk management. +- Losses in one subaccount don't affect others. +- Useful for separating personal trading, algorithms, or different fund allocations. + +**API Usage** +- Most operations require both the account address and subaccount number. +- Example: `get_subaccount_orders(address, subaccount_number)` ## Setting Up @@ -23,7 +43,7 @@ To retrieve all open orders for an account: async def get_open_orders(address): orders = await client.account.get_subaccount_orders( address, - 0, + 0, # Subaccount ID status="OPEN" ) print("Open orders:", orders)