Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Account

Overview

An account mirrors the state of the trading account of the underlying broker. It contains available cash, open positions, open orders, available buying power and executed trades.

The account doesn’t contain closed orders and closed positions.

Account is immutable and created by the Broker during the sync() method. It is also the object that is returned from the run() function.

buying power : 390,904@USD
cash         : 390,904@USD
equity       : 2,046,038@USD
positions    : 922@GOOGL, 687@AAPL, 1602@XOM, 653@JPM, 436@TSLA, 292@META, 1020@NVDA, 840@AMZN
trades       : 296
mkt value    : 1,655,134@USD
orders       : none
last update  : 2025-12-31 05:00:00+00:00

Buying Power

The buying power indicates how much of the account can still be used to place new orders. It is the amount of cash that is available for trading, potentially increased by any margin that the broker allows.

The available cash is the amount of money currently not invested, minus any amount reserved by open orders. When margin is enabled, the buying power can be a multiple of the available cash.

The following example shows the available cash and buying power of the account.

available cash: 390904.0050163269@USD
buying power: 390,904.01@USD

Positions

A position is the quantity of an Asset currently held, representing its market exposure and risk at any given moment. Every time a trade is executed, a position is created or updated.

Each Position contains:

The size can be positive (long) or negative (short). A position whose size is zero is considered closed and is not included in the account anymore.

Hedging versus netting

When multiple orders are executed for the same asset, the broker has to decide how to combine them into positions. Often, stock brokers use netting while forex brokers use hedging.

Roboquant supports both strategies:

  1. Netting: only a single position per asset exists. A new order in the opposite direction first reduces the existing position, and only the remaining quantity opens a new position in that direction (potentially flipping long to short and vice versa).

  2. Hedging: multiple positions per asset can exist at the same time, allowing a long and a short position in the same asset to coexist. Opposite orders do not automatically reduce each other. For positions to close, you typically need to refer to the position when placing the order.

Output
Stock(symbol='GOOGL', currency='USD', info=None) 922 165.06219482421875 312.24261474609375
Stock(symbol='AAPL', currency='USD', info=None) 687 217.8272247314453 272.3187561035156
Stock(symbol='XOM', currency='USD', info=None) 1602 113.34495544433594 118.79685974121094
Stock(symbol='JPM', currency='USD', info=None) 653 302.89886474609375 319.7988586425781
Stock(symbol='TSLA', currency='USD', info=None) 436 453.0299987792969 456.1000061035156
Stock(symbol='META', currency='USD', info=None) 292 664.7088012695312 663.0430908203125
Stock(symbol='NVDA', currency='USD', info=None) 1020 187.27178955078125 189.12744140625
Stock(symbol='AMZN', currency='USD', info=None) 840 231.2100067138672 232.91000366210938
unrealized pnl 197_078.57@USD
market value 1_655_134.48@USD
Loading...

Trades

Trades are particular useful after a back test to see how P&L is distributed among assets and what type of trades resulted in winers or losers.

848959.9097557068@USD
Loading...