Runtime State (Developer Guide)
What It Does
The state layer persists live order and position state for crash recovery.
Why It Exists
Without persisted state, restarts can double-apply fills or lose order ownership.
Config Dependencies
config/state.yaml
With Backtrader
The Broker loads state automatically on start and persists snapshots.
Without Backtrader
You can use SQLiteStateStore directly for custom recovery workflows.
Limitations
- Schema mismatches require a reset.
- State is scoped by account_id and strategy_id.
Scenario Example
Scenario: You deploy a new version with schema changes. - Stop all processes. - Back up and delete the state DB. - Restart so the broker rebuilds state.