Overview
Thesimulator.resetAccount endpoint resets a simulated trading account to its initial configuration, clearing all positions and restoring the starting balance.
Request
Parameters
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
The reset account snapshot with initial balances and no positions.
Cash balance reset to initial capital (e.g.,
10000).Available cash equals cash balance (no positions using margin).
Always
0 after reset (no leverage or borrowed funds).Equity equals cash balance (no unrealized P&L).
Always
0 after reset (no open positions).Quote currency (e.g.,
"USD").Always
0 after reset.Always
0 after reset.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
| Error | Cause | Solution |
|---|---|---|
"Simulation mode is disabled" | IS_SIMULATION_ENABLED=false | Enable simulation mode in environment config |
"Failed to reset account" | Simulator internal error | Check simulator logs for details |
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

