Skip to main content

Documentation 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.

Every persistence adapter in this project wires a backtest-kit 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 implements waitForInit(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.
async waitForInit(initial: boolean) {
  if (!initial) return;
  await waitForInfra();
}

Read path

Each read*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

Each write*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

AdapterCollectionContext KeySoft Delete
Candlecandle-items(symbol, interval, timestamp)No (insert-only)
Signalsignal-items(symbol, strategyName, exchangeName)No
Scheduleschedule-items(symbol, strategyName, exchangeName)No
Riskrisk-items(riskName, exchangeName)No
Partialpartial-items(symbol, strategyName, exchangeName, signalId)No
Breakevenbreakeven-items(symbol, strategyName, exchangeName, signalId)No
Storagestorage-items(backtest, signalId)No
Notificationnotification-items(backtest, notificationId)No
Loglog-items(entryId)No
Measuremeasure-items(bucket, entryKey)Yes
Intervalinterval-items(bucket, entryKey)Yes
Memorymemory-items(signalId, bucketName, memoryId)Yes
Recentrecent-items(symbol, strategyName, exchangeName, frameName, backtest)No
Statestate-items(signalId, bucketName)No
Sessionsession-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.

Build docs developers (and LLMs) love