Expand description
JsonFileStore — a durable StateStore backed by a single JSON file.
This is the simplest real-durability backend: the framework’s risk
snapshots (per-symbol SessionPnl /
CircuitBreaker and the account
PortfolioRisk latch) survive a restart, so
a halted daily session or a tripped breaker isn’t forgotten when the bot
reboots. Wire it with Bot::with_state_store.
Writes are write-through and atomic: every
save (and flush) serialises the
full map to a sibling temp file and renames it over the target, so a crash
mid-write can’t corrupt the store — you either keep the previous good file
or get the new one. Saves are infrequent (one per realised trade) and the
payload is tiny (a handful of symbols), so rewriting the whole file each
time is cheap.
For higher write volumes or multi-process access, a sqlite/Postgres backend
(another StateStore impl) is the next step — the framework only depends on
the trait.
Structs§
- Json
File Store - A
StateStorethat persists snapshots to a JSON file on disk.