Skip to main content

Overview

The simulator.resetAccount endpoint resets a simulated trading account to its initial configuration, clearing all positions and restoring the starting balance.
This action is irreversible and will:
  • Close all open positions
  • Reset cash balance to initial capital
  • Clear all realized/unrealized P&L
  • Remove account history (positions, orders)
Use with caution. This is typically used when starting a new simulation or testing scenario.

Request

Parameters

string
The simulator account identifier to reset. Defaults to "default" if not provided.Each account ID maintains independent state, so resetting one account does not affect others.

Response

object
The reset account snapshot with initial balances and no positions.
number
Cash balance reset to initial capital (e.g., 10000).
number
Available cash equals cash balance (no positions using margin).
number
Always 0 after reset (no leverage or borrowed funds).
number
Equity equals cash balance (no unrealized P&L).
number
Always 0 after reset (no open positions).
string
Quote currency (e.g., "USD").
number
Always 0 after reset.
number
Always 0 after reset.
array
Always empty array [] after reset.

Code Example

Reset Behavior

What Gets Reset

  1. Positions: All open positions are immediately closed
  2. Cash Balance: Restored to initial capital (configured in simulator options)
  3. P&L: Both realized and unrealized P&L reset to zero
  4. Margin: All margin is released
  5. Borrowed Balance: Cleared to zero

What Persists

  • Simulator configuration (initial capital, margin requirements, etc.)
  • Market data (price feeds continue operating)
  • Other accounts (only the specified account ID is reset)

Initial State

After reset, the account returns to:

Use Cases

Testing New Strategies

Reset the account to test different trading strategies from a clean slate:

Multiple Simulation Scenarios

Use different account IDs for parallel simulations:

Recovery from Errors

Reset if the simulator state becomes inconsistent:

Account ID Management

Default Account

If no account ID is provided, the "default" account is reset:

Named Accounts

Use custom account IDs for isolation:

Whitespace Normalization

Account IDs are automatically trimmed:

Error Handling

Performance Implications

  • Fast operation: Reset is near-instantaneous (clears in-memory state)
  • No database impact: Simulator state is ephemeral (rehydrates from DB on restart)
  • Safe concurrency: Each account ID is isolated
Resetting an account does not affect historical trade data stored in the database. If you need to clear historical records, use database cleanup operations separately.

Best Practices

  1. Confirm before reset: Always show a confirmation dialog to prevent accidental resets
  2. Invalidate queries: Refresh all related TanStack Query caches after reset
  3. Use named accounts: Avoid resetting "default" account in multi-user scenarios
  4. Log resets: Track reset events for audit trails
  5. Test in isolation: Use separate account IDs for testing vs. production simulations