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.

These three adapters persist the audit trail of a running strategy. Storage accumulates every signal that has been created, updated, or closed. Notification collects timestamped event messages surfaced in the UI. Log records freeform strategy log entries. Storage and Notification are both partitioned by a backtest: boolean flag, which separates historical backtest data from live or paper-trading data within the same MongoDB instance. Log has no constructor arguments and shares a single global collection.

The backtest Flag

Both Storage and Notification accept backtest: boolean in their constructors. When true, all reads and writes target the backtest partition; when false, they target the live/paper partition. This allows a single deployment to maintain isolated signal histories for backtests and live runs without separate databases.

Storage Adapter

The Storage adapter persists the full set of open and closed signals. It is the primary audit log for signal lifecycle events. Reads return all records for the current mode via a listByMode query (up to 1000 rows).

Constructor

class implements IPersistStorageInstance {
  constructor(readonly backtest: boolean) {}
}
backtest
boolean
required
true to target the backtest partition; false for live/paper trading.

readStorageData

Returns all stored signal payloads for the current mode, in insertion order.
async readStorageData(): Promise<StorageData> {
  const rows = await ioc.storageDbService.listByMode(this.backtest);
  return rows.map((row) => row.payload);
}
Returns: StorageData — an array of signal payload objects. Returns an empty array when no records exist.
listByMode applies an internal limit of up to 1000 rows. For deployments that accumulate large signal histories, consider paginating or archiving older records.

writeStorageData

Upserts each signal in the array individually, keyed by signal.id.
async writeStorageData(signals: StorageData): Promise<void> {
  for (const signal of signals) {
    await ioc.storageDbService.upsert(this.backtest, signal.id, signal);
  }
}
signals
StorageData
required
Array of signal objects. Each must have an id field used as the document key.

Notification Adapter

The Notification adapter stores timestamped event messages. Unlike Storage, the read path returns records in reverse chronological order so that the most recent notifications appear first.

Constructor

class implements IPersistNotificationInstance {
  constructor(readonly backtest: boolean) {}
}
backtest
boolean
required
true for the backtest partition; false for live/paper trading.

readNotificationData

Returns all notification payloads for the current mode, in reverse chronological order.
async readNotificationData(): Promise<NotificationData> {
  const rows = await ioc.notificationDbService.listByMode(this.backtest);
  return rows.map((row) => row.payload).reverse();
}
Returns: NotificationData — an array of notification objects, newest first.
Notifications are reversed after retrieval (.reverse()) rather than using a descending index query. The underlying listByMode query returns documents in ascending insertion order, and the array is flipped in application memory.

writeNotificationData

Upserts each notification in the array individually, keyed by notification.id.
async writeNotificationData(notifications: NotificationData): Promise<void> {
  for (const notification of notifications) {
    await ioc.notificationDbService.upsert(
      this.backtest, notification.id, notification,
    );
  }
}
notifications
NotificationData
required
Array of notification objects. Each must have an id field used as the document key.

Log Adapter

The Log adapter has no constructor arguments. It uses a single log-items collection shared across all modes. Reads also return entries in reverse chronological order.

Constructor

The Log adapter takes no constructor arguments:
class implements IPersistLogInstance {
  // No constructor parameters
}

readLogData

Returns all log entry payloads, in reverse chronological order.
async readLogData(): Promise<LogData> {
  const rows = await ioc.logDbService.listAll();
  return rows.map((row) => row.payload).reverse();
}
Returns: LogData — an array of log entry objects, newest first.

writeLogData

Upserts each log entry individually, keyed by entry.id.
async writeLogData(entries: LogData): Promise<void> {
  for (const entry of entries) {
    await ioc.logDbService.upsert(entry.id, entry);
  }
}
entries
LogData
required
Array of log entry objects. Each must have an id field used as the document key.
The Log adapter does not partition by backtest mode — all log entries share the same collection. If you run backtests and live trading concurrently, log entries from both modes will appear together in readLogData.

Collection Summary

AdapterCollectionContext KeyRead OrderBacktest Partition
Storagestorage-items(backtest, signalId)Insertion orderYes
Notificationnotification-items(backtest, notificationId)Newest firstYes
Loglog-items(entryId)Newest firstNo

Build docs developers (and LLMs) love