Portfolio management
List accounts
List all accounts available to the user. This includes FCM accounts, which must be specified when sending orders.
res = await client.list_accounts()
for item in res:
print(item.account.name)[
{
"account": {
"id": "00000000-0000-0000-0000-000000000000",
"name": "STONEX:000000/JDoe"
},
"permissions": {
"list": true,
"reduce_or_close": true,
"set_limits": true,
"trade": true,
"view": true
},
"trader": "00000000-0000-0000-0000-000000000000"
},
{
"account": {
"id": "00000000-0000-0000-0000-000000000001",
"name": "STONEX:000001/JDoe"
},
"permissions": {
"list": true,
"reduce_or_close": true,
"set_limits": true,
"trade": true,
"view": true
},
"trader": "00000000-0000-0000-0000-000000000000"
}
]Account permissions
list
Trader is allowed to know about the account but not its balances or positions
reduce_or_close
Trader can send orders only to reduce or close (risk manager)
set_limits
Trader allowed to set or change risk limits on the account
trade
Trader allowed to send orders
view
Read-only view of account, including balances and positions
Get account summary
Get an account summary for a specified account.
res = await client.get_account_summary("STONEX:000000/JDoe")
print(res)
# get multiple account summaries
res = await client.get_account_summaries([
"STONEX:000000/JDoe",
"STONEX:000001/JDoe"
])
print(res){
"account": "00000000-0000-0000-0000-000000000000",
"balances": {
"USD": "5754.59"
},
"positions": {
"MGC 20250626 CME Future/USD": [
{
"quantity": "1",
"cost_basis": "3279.2"
}
]
},
"timestamp": "2025-05-15T22:32:21.222906Z",
"cash_excess": "0",
"position_margin": "1650",
"purchasing_power": "5447.59",
"realized_pnl": "0",
"total_margin": "1650",
"unrealized_pnl": "0"
}Account summary fields
account
Account ID
timestamp
Snapshot timestamp
equity
Total account equity or net liquidation value
cash_excess
Withdrawable cash
purchasing_power
Total purchasing power of the account
unrealized_pnl
Unrealized P&L
realized_pnl
Realized P&L
yesterday_equity
Yesterday account equity or net liquidation value; not provided on all venues
total_margin
Margin usage including open orders and positions
position_margin
Margin usage including only positions
balances
Map of products/assets to their quantities
positions
See "Account Positions" table
Get account history
Get historical snapshots of account summaries for the specified account.
from datetime import datetime
res = await client.get_account_history(
account="STONEX:000000/JDoe",
from_inclusive=datetime(2025, 1, 1),
to_exclusive=datetime(2025, 1, 2)
)
print(res)Last updated