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. It fires when the venue reports an account update (via 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, or BETTING).
base_currencyCurrency or NoneRequiredThe 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).
infodict[str, object]RequiredAdditional implementation‑specific account information.
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("BINANCE"))
self.log.info(f"Account state: {account}")
  • Events - Event categories and dispatch.
  • Accounting - Account types, balances, and margin models.
  • Portfolio - How account state feeds exposure and balance tracking.

On this page