Skip to main content

Overview

The simulator.getAccount endpoint retrieves the current snapshot of a simulated trading account, including cash balances, open positions, margin usage, and profit/loss calculations.
This endpoint requires simulation mode to be enabled (IS_SIMULATION_ENABLED=true).

Request

Parameters

string
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

object
Complete account snapshot containing balances, positions, and P&L.
number
Total cash in the account (includes borrowed balance if negative).
number
Cash available for new positions after accounting for margin requirements.
number
Amount of borrowed funds (used when trading with leverage or shorting).
number
Total account value: cashBalance + totalUnrealizedPnl.
number
Total margin locked in open positions.
string
Quote currency for all monetary values (e.g., "USD").
number
Cumulative realized profit/loss from closed positions.
number
Current unrealized profit/loss from all open positions.
array
Array of open positions.
string
Trading pair symbol (e.g., "BTC-USD").
enum<string>
Position direction: "LONG" or "SHORT".
number
Position size in base currency.
number
Average entry price for the position (weighted by quantity).
number
Realized P&L from partial closes of this position.
number
Current unrealized P&L based on mark price.
number
Current market price used for P&L calculations.
number
Margin locked for this position.
number
Position notional value: quantity * markPrice.
number | null
Leverage multiplier used when opening the position (if applicable).
object | null
Planned exit levels (if set).
number | null
Stop loss price level.
number | null
Take profit price level.
string | null
Conditions that invalidate the trade thesis.

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

Account state is computed in real-time from the simulator’s in-memory state. For persistent storage, the simulator rehydrates from the database Orders table on bootstrap.