Overview
Thesimulator.resetAccount endpoint resets a simulated trading account to its initial configuration, clearing all positions and restoring the starting balance.
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
- Positions: All open positions are immediately closed
- Cash Balance: Restored to initial capital (configured in simulator options)
- P&L: Both realized and unrealized P&L reset to zero
- Margin: All margin is released
- 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
Best Practices
- Confirm before reset: Always show a confirmation dialog to prevent accidental resets
- Invalidate queries: Refresh all related TanStack Query caches after reset
- Use named accounts: Avoid resetting
"default"account in multi-user scenarios - Log resets: Track reset events for audit trails
- Test in isolation: Use separate account IDs for testing vs. production simulations

