Overview
Thesimulator.getAccount endpoint retrieves the current snapshot of a simulated trading account, including cash balances, open positions, margin usage, and profit/loss calculations.
Request
Parameters
The simulator account identifier. Defaults to
"default" if not provided.Use different account IDs to maintain separate simulated portfolios with independent balances and positions.Response
Complete account snapshot containing balances, positions, and P&L.
Total cash in the account (includes borrowed balance if negative).
Cash available for new positions after accounting for margin requirements.
Amount of borrowed funds (used when trading with leverage or shorting).
Total account value:
cashBalance + totalUnrealizedPnl.Total margin locked in open positions.
Quote currency for all monetary values (e.g.,
"USD").Cumulative realized profit/loss from closed positions.
Current unrealized profit/loss from all open positions.
Array of open positions.
Trading pair symbol (e.g.,
"BTC-USD").Position direction:
"LONG" or "SHORT".Position size in base currency.
Average entry price for the position (weighted by quantity).
Realized P&L from partial closes of this position.
Current unrealized P&L based on mark price.
Current market price used for P&L calculations.
Margin locked for this position.
Position notional value:
quantity * markPrice.Leverage multiplier used when opening the position (if applicable).
Code Example
Account State Structure
The account snapshot represents the complete state at the time of the request:Balance Components
- Cash Balance: Starting capital + realized P&L ± borrowed funds
- Available Cash: Cash not locked as margin (available for new trades)
- Borrowed Balance: Negative balance from leverage or short selling
- Equity: True account value including unrealized P&L
- Margin Balance: Locked funds backing open positions
Position Tracking
Each position maintains:- Average entry price (weighted by partial fills)
- Separate realized/unrealized P&L (partial closes tracked)
- Current mark price (real-time market data)
- Margin requirement (varies by leverage)
- Optional exit plan (stop loss, take profit targets)
Real-Time Updates
Account state reflects:- All executed orders (market and limit fills)
- Current market prices for unrealized P&L
- Margin requirements based on position sizes
- Borrowed balance changes from leverage use
Use Cases
Portfolio Dashboard
Display account equity, available cash, and position summaries in a trading dashboard.Risk Management
Monitor margin usage, leverage exposure, and unrealized P&L to manage risk.Performance Analytics
Track realized P&L over time and compare against equity changes.Position Monitoring
List all open positions with entry prices, current P&L, and exit plans.Error Handling
| Error | Cause | Solution |
|---|---|---|
"Simulation mode is disabled" | IS_SIMULATION_ENABLED=false | Enable simulation mode in environment config |

