Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/backtest-kit/backtest-kit-minio-s3-docker/llms.txt

Use this file to discover all available pages before exploring further.

These 9 adapters persist the live, mutable state of running strategies. Unlike the Candle adapter, which is insert-only, each of these adapters performs a simple idempotent PUT on every write — no read-before-write is needed because every object key is a pure function of its context (symbol/strategy/exchange/…). S3’s strong read-after-write consistency guarantee means that once writeXData(…) returns, the very next readXData(…) will see the new value.
All 9 adapters call await waitForInfra() on first initialization — the same shared singleshot function used by every other adapter. This gates the first write or read on Redis being ready without duplicating connection logic across instances.

Signal

The Signal adapter stores the live signal state for a single (symbol, strategyName, exchangeName) context — the running position or last-known action that backtest-kit uses to decide what to do next. Constructor arguments
constructor(
  readonly symbol:       string,
  readonly strategyName: string,
  readonly exchangeName: string,
) {}
Read / write signatures
async readSignalData(): Promise<ISignalRow | null>
async writeSignalData(signalRow: ISignalRow | null): Promise<void>
Object key schemasignal-items/<symbol>/<strategy>/<exchange>
const GET_STORAGE_KEY_FN = (
  symbol: string,
  strategyName: string,
  exchangeName: string
) => `${symbol}/${strategyName}/${exchangeName}`;
The payload stored in MinIO wraps the ISignalRow inside a document envelope (ISignalRowDoc) that adds id, createDate, and updatedDate. On read, only row.payload is returned to backtest-kit. Writing null clears the signal state by persisting null as the payload.

Schedule

The Schedule adapter stores a pending scheduled signal for a context — a signal that has been queued for execution at a future time but has not yet fired. Constructor arguments
constructor(
  readonly symbol:       string,
  readonly strategyName: string,
  readonly exchangeName: string,
) {}
Read / write signatures
async readScheduleData(): Promise<IScheduledSignalRow | null>
async writeScheduleData(scheduleRow: IScheduledSignalRow | null): Promise<void>
Object key schemaschedule-items/<symbol>/<strategy>/<exchange>
const GET_STORAGE_KEY_FN = (
  symbol: string,
  strategyName: string,
  exchangeName: string
) => `${symbol}/${strategyName}/${exchangeName}`;
The same key structure as Signal, but under the schedule-items/ prefix in the backtest-kit bucket. Writing null clears any pending schedule.

Strategy

The Strategy adapter persists a snapshot of the deferred commit queue — internal backtest-kit strategy state that must survive process restarts. Constructor arguments
constructor(
  readonly symbol:       string,
  readonly strategyName: string,
  readonly exchangeName: string,
) {}
Read / write signatures
async readStrategyData(): Promise<StrategyData | null>
async writeStrategyData(strategyRow: StrategyData | null): Promise<void>
Object key schemastrategy-items/<symbol>/<strategy>/<exchange>
const GET_STORAGE_KEY_FN = (
  symbol: string,
  strategyName: string,
  exchangeName: string
) => `${symbol}/${strategyName}/${exchangeName}`;
StrategyData is an opaque type owned by backtest-kit; the adapter stores and retrieves it verbatim. Writing null resets the deferred queue to empty.

Risk

The Risk adapter stores an array of active risk positions for a named risk manager on a given exchange. The key uses riskName rather than symbol because a risk manager may span multiple symbols simultaneously. Constructor arguments
constructor(
  readonly riskName:    string,
  readonly exchangeName: string,
) {}
Read / write signatures
async readPositionData(_when: Date): Promise<RiskData>
async writePositionData(positions: RiskData, when: Date): Promise<void>
Object key schemarisk-items/<riskName>/<exchange>
const GET_STORAGE_KEY_FN = (
  riskName: string,
  exchangeName: string
) => `${riskName}/${exchangeName}`;
RiskData is a positions array. readPositionData returns an empty array [] when no stored row exists — callers never receive null.

Partial

The Partial adapter stores the partial profit/loss levels for a specific open signal. Because multiple signals may be open simultaneously for the same context, the key includes signalId as a fourth segment. Constructor arguments
constructor(
  readonly symbol:       string,
  readonly strategyName: string,
  readonly exchangeName: string,
) {}
Read / write signatures
async readPartialData(signalId: string, _when: Date): Promise<PartialData>
async writePartialData(data: PartialData, signalId: string, when: Date): Promise<void>
Object key schemapartial-items/<symbol>/<strategy>/<exchange>/<signalId>
const GET_STORAGE_KEY_FN = (
  symbol: string,
  strategyName: string,
  exchangeName: string,
  signalId: string
) => `${symbol}/${strategyName}/${exchangeName}/${signalId}`;
readPartialData returns an empty object {} when no stored row exists.

Breakeven

The Breakeven adapter stores a flag (or metadata) indicating whether the breakeven level has been reached for a specific open signal. Like Partial, the key includes signalId. Constructor arguments
constructor(
  readonly symbol:       string,
  readonly strategyName: string,
  readonly exchangeName: string,
) {}
Read / write signatures
async readBreakevenData(signalId: string, _when: Date): Promise<BreakevenData>
async writeBreakevenData(data: BreakevenData, signalId: string, when: Date): Promise<void>
Object key schemabreakeven-items/<symbol>/<strategy>/<exchange>/<signalId>
const GET_STORAGE_KEY_FN = (
  symbol: string,
  strategyName: string,
  exchangeName: string,
  signalId: string
) => `${symbol}/${strategyName}/${exchangeName}/${signalId}`;
readBreakevenData returns an empty object {} when no stored row exists.

Recent

The Recent adapter stores the last public signal emitted for a context. It includes frameName and backtest in its key because the same symbol/strategy pair may run in multiple frames and in both backtest and live modes simultaneously. Constructor arguments
constructor(
  readonly symbol:       string,
  readonly strategyName: string,
  readonly exchangeName: string,
  readonly frameName:    string,
  readonly backtest:     boolean,
) {}
Read / write signatures
async readRecentData(): Promise<RecentData>
async writeRecentData(signalRow: NonNullable<RecentData>, when: Date): Promise<void>
Object key schemarecent-items/<symbol>/<strategy>/<exchange>/<frame>/<backtest>
const GET_STORAGE_KEY_FN = (
  symbol: string,
  strategyName: string,
  exchangeName: string,
  frameName: string,
  backtest: boolean
) => `${symbol}/${strategyName}/${exchangeName}/${frameName}/${backtest}`;
readRecentData returns null (via row ? row.payload : null) when no stored row exists.

State

The State adapter provides per-signal state buckets — arbitrary StateData keyed by (signalId, bucketName). A single signal may have many independent state buckets. The adapter includes a dispose() method as required by the interface. Constructor arguments
constructor(
  readonly signalId:    string,
  readonly bucketName:  string,
) {}
Read / write signatures
async readStateData(): Promise<StateData | null>
async writeStateData(data: StateData, when: Date): Promise<void>
dispose(): void
Object key schemastate-items/<signalId>/<bucket>
const GET_STORAGE_KEY_FN = (
  signalId: string,
  bucketName: string
) => `${signalId}/${bucketName}`;

Session

The Session adapter stores one session object per running strategy instance. Sessions include frameName and backtest in their key to distinguish concurrent runs of the same strategy across different frames or modes. The adapter includes a dispose() method as required by the interface. Constructor arguments
constructor(
  readonly strategyName: string,
  readonly exchangeName: string,
  readonly frameName:    string,
  readonly symbol:       string,
  readonly backtest:     boolean,
) {}
Read / write signatures
async readSessionData(): Promise<SessionData | null>
async writeSessionData(data: SessionData, when: Date): Promise<void>
dispose(): void
Object key schemasession-items/<strategy>/<exchange>/<frame>/<symbol>/<backtest>
const GET_STORAGE_KEY_FN = (
  strategyName: string,
  exchangeName: string,
  frameName: string,
  symbol: string,
  backtest: boolean
) => `${strategyName}/${exchangeName}/${frameName}/${symbol}/${backtest}`;
The dispose() methods on both State and Session are intentional no-ops — dispose(): void { void 0; }. Lifecycle cleanup (flushing open sessions, releasing state buckets) is managed externally by backtest-kit at the framework level. The MinIO objects themselves persist until explicitly overwritten by the next writeXData call or deleted manually.

Build docs developers (and LLMs) love