NautilusTrader
ConceptsEvents
These docs track the unreleased nightly build and may change without notice. Switch to the latest stable docs.

AccountState

AccountState carries a snapshot of an account's balances and margins. The system publishes it when the venue reports an account update through the execution client, or when the Portfolio recalculates account state after a position update (for margin accounts with calculate_account_state enabled). The Portfolio subscribes to these events internally to maintain exposure and balance tracking.

The is_reported flag distinguishes venue‑reported snapshots from system‑calculated ones.

Fields

FieldPython typeRequired/defaultDescription
account_idAccountIdRequiredThe account ID (with the venue).
account_typeAccountTypeRequiredThe account type (CASH, MARGIN, BETTING, or WALLET).
base_currencyCurrency or NoneNoneThe account base currency (None for multi‑currency accounts).
is_reportedboolRequiredIf the state is reported from the exchange (otherwise system‑calculated).
balanceslist[AccountBalance]RequiredThe account balances (may be empty).
marginslist[MarginBalance]RequiredThe margin balances (may be empty).
event_idUUID4RequiredThe event ID.
ts_eventintRequiredUNIX timestamp (nanoseconds) when the event occurred.
ts_initintRequiredUNIX timestamp (nanoseconds) when the object was initialized.

Example

Account state is normally consumed through the Portfolio rather than a dedicated handler:

from nautilus_trader.model import Venue

# Account state is tracked by the portfolio; query it by venue
account = self.portfolio.account(venue=Venue("BINANCE"))
self.log.info(f"Account state: {account}")

The result is detached from the Portfolio. Mutating the returned account does not change the authoritative account held by the engine.

  • Events - Event categories and dispatch.
  • Accounting - Account types, balances, and margin models.
  • Portfolio - How account state feeds exposure and balance tracking.

On this page