Accounts API
Account information retrieval operations.
Access via client.accounts.
AccountsAPI
AccountsAPI
Account information operations.
Provides methods to retrieve account/trader details.
Example
get_trader(account_id, timeout=None)
Get full account/trader information.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
account_id
|
int
|
The cTID trader account ID. |
required |
timeout
|
float | None
|
Request timeout (uses default if None). |
None
|
Returns:
| Type | Description |
|---|---|
Account
|
Full Account details including balance, leverage, etc. |
Raises:
| Type | Description |
|---|---|
APIError
|
If request fails. |
CTraderConnectionTimeoutError
|
If request times out. |
Usage Examples
Get Account Details
account = await client.accounts.get_trader(account_id)
print(f"Balance: {account.balance}")
print(f"Leverage: {account.get_leverage()}")
print(f"Account type: {account.account_type}")
print(f"Broker name: {account.broker_name}")
Account Discovery
To discover available accounts for an access token, use the auth manager:
# Get all accounts associated with a token
accounts = await client.auth.get_accounts(access_token)
for acc in accounts:
print(f"Login: {acc.trader_login}, Account ID: {acc.account_id}")
print(f" Live: {acc.is_live}, Broker: {acc.broker_name}")
Related
- Authentication - Authenticating accounts
- Models - Account - Account model reference