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.

The Signal and Schedule adapters persist the mutable runtime state of a running strategy. The Signal adapter holds the current active signal row for a (symbol, strategyName, exchangeName) context — representing what the strategy currently believes about the market. The Schedule adapter stores a pending scheduled signal for the same context — used when a strategy defers an action to a future bar. Both adapters support writing null to explicitly clear state.

Signal Adapter

Constructor

class implements IPersistSignalInstance {
  constructor(
    readonly symbol: string,
    readonly strategyName: string,
    readonly exchangeName: string,
  ) {}
}
symbol
string
required
The trading pair symbol, e.g. "ETHUSDT".
strategyName
string
required
The unique name of the strategy instance persisting its signal.
exchangeName
string
required
The exchange identifier used to namespace this context.

readSignalData

Fetches the stored ISignalRow payload for this context from the signal-items collection. Returns null when no signal has been written yet or when the last write was null.
async readSignalData(): Promise<ISignalRow | null> {
  const row = await ioc.signalDbService.findByContext(
    this.symbol, this.strategyName, this.exchangeName,
  );
  return row ? row.payload : null;
}
Returns: ISignalRow | null

writeSignalData

Upserts the signal payload for this context. Passing null clears the stored signal, marking it as absent.
async writeSignalData(signalRow: ISignalRow | null): Promise<void> {
  await ioc.signalDbService.upsert(
    this.symbol, this.strategyName, this.exchangeName, signalRow,
  );
}
signalRow
ISignalRow | null
required
The signal payload to persist, or null to clear the current signal state.
Writing null is the canonical way to reset signal state between strategy runs. The document is updated in MongoDB but not deleted — a subsequent read returns null from the payload field.

Redis Cache Key

signal_cache:<exchangeName>:<strategyName>:<symbol>

Schedule Adapter

The Schedule adapter mirrors the Signal adapter in structure. It stores a IScheduledSignalRow — a signal that has been deferred to execute at a specific future bar. Like the Signal adapter, writing null clears any pending schedule.

Constructor

class implements IPersistScheduleInstance {
  constructor(
    readonly symbol: string,
    readonly strategyName: string,
    readonly exchangeName: string,
  ) {}
}
symbol
string
required
The trading pair symbol.
strategyName
string
required
The unique name of the strategy instance.
exchangeName
string
required
The exchange identifier.

readScheduleData

Fetches the stored IScheduledSignalRow payload for this context from the schedule-items collection.
async readScheduleData(): Promise<IScheduledSignalRow | null> {
  const row = await ioc.scheduleDbService.findByContext(
    this.symbol, this.strategyName, this.exchangeName,
  );
  return row ? row.payload : null;
}
Returns: IScheduledSignalRow | null

writeScheduleData

Upserts the scheduled signal payload for this context. Passing null cancels any pending scheduled signal.
async writeScheduleData(scheduleRow: IScheduledSignalRow | null): Promise<void> {
  await ioc.scheduleDbService.upsert(
    this.symbol, this.strategyName, this.exchangeName, scheduleRow,
  );
}
scheduleRow
IScheduledSignalRow | null
required
The scheduled signal payload to persist, or null to cancel the pending schedule.

Redis Cache Key

schedule_cache:<exchangeName>:<strategyName>:<symbol>

Collection Summary

AdapterCollectionContext KeyNull Write
Signalsignal-items(symbol, strategyName, exchangeName)Clears signal
Scheduleschedule-items(symbol, strategyName, exchangeName)Cancels schedule
Both adapters share the same context key shape, but their collections and Redis key prefixes are distinct — a signal and a schedule for the same context are completely independent documents.

Build docs developers (and LLMs) love