Every persistence adapter in this project wires a backtest-kitDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/theonetrade/backtest-kit-redis-mongo-docker/llms.txt
Use this file to discover all available pages before exploring further.
IPersist* interface to a dedicated MongoDB collection. During startup, each adapter calls waitForInit, which blocks until both MongoDB and Redis are reachable. After that, reads go through a Redis cache layer before falling back to MongoDB, and writes update both stores atomically. The pattern is consistent across all 15 adapters: construct with a context key, call waitForInit(initial) on first use, then call typed read*Data / write*Data methods.
Common Patterns
waitForInit
Every adapter instance implementswaitForInit(initial: boolean). When initial is true (first boot), the method awaits waitForInfra(), which resolves once the MongoDB and Redis connections are healthy. Subsequent calls with initial = false return immediately without blocking.
Read path
Eachread*Data method queries the relevant MongoDB collection using a composite context key. Some adapters (Measure, Interval, Memory) also check a removed soft-delete flag and return null for soft-deleted documents.
Write path
Eachwrite*Data method performs an upsert against MongoDB using the same composite context key. The Candle adapter is insert-only ($setOnInsert); all others overwrite the stored payload on conflict. Redis cache keys are updated on every write.
Adapter Table
| Adapter | Collection | Context Key | Soft Delete |
|---|---|---|---|
| Candle | candle-items | (symbol, interval, timestamp) | No (insert-only) |
| Signal | signal-items | (symbol, strategyName, exchangeName) | No |
| Schedule | schedule-items | (symbol, strategyName, exchangeName) | No |
| Risk | risk-items | (riskName, exchangeName) | No |
| Partial | partial-items | (symbol, strategyName, exchangeName, signalId) | No |
| Breakeven | breakeven-items | (symbol, strategyName, exchangeName, signalId) | No |
| Storage | storage-items | (backtest, signalId) | No |
| Notification | notification-items | (backtest, notificationId) | No |
| Log | log-items | (entryId) | No |
| Measure | measure-items | (bucket, entryKey) | Yes |
| Interval | interval-items | (bucket, entryKey) | Yes |
| Memory | memory-items | (signalId, bucketName, memoryId) | Yes |
| Recent | recent-items | (symbol, strategyName, exchangeName, frameName, backtest) | No |
| State | state-items | (signalId, bucketName) | No |
| Session | session-items | (strategyName, exchangeName, frameName) | No |
Three adapters — Measure, Interval, and Memory — support soft-delete. Their
remove*Data methods set removed: true on the document rather than deleting it.
Read methods return null for soft-deleted entries, and list*Data skips them entirely.Adapter Pages
Candle
OHLCV candle persistence with insert-only upsert and timestamp-stepped reads.
Signal & Schedule
Current signal row and pending scheduled signal per trading context.
Risk, Partial & Breakeven
Active position snapshots, profit/loss levels, and breakeven flags per signal.
Storage, Notification & Log
Signal history, event notifications, and strategy log entries.
Measure, Interval & Memory
Soft-delete bucket stores for caching, interval markers, and per-signal memory.
Recent, State & Session
Last public signal, named state buckets, and active strategy session.