Recent, State, and Session are the three strategy lifecycle adapters. All carry aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/theonetrade/backtest-kit-redis-postgres-pgpool-docker/llms.txt
Use this file to discover all available pages before exploring further.
when column for look-ahead bias protection, and all follow the same atomic INSERT … ON CONFLICT … DO UPDATE … RETURNING * upsert pattern. State and Session both implement a dispose() no-op to satisfy the IPersist*Instance cleanup hook required by backtest-kit.
Recent Adapter
The Recent adapter stores the last publicly visible signal row for a given(symbol, strategyName, exchangeName, frameName, backtest) context. It is the widest context key of all 16 adapters — five fields — which ensures that two symbols running the same strategy on the same exchange but in different frames never share a recent-signal row.
Context Key and Table
| Field | Type | Role |
|---|---|---|
symbol | string | Trading pair |
strategyName | string | Strategy identifier |
exchangeName | string | Exchange identifier |
frameName | string | Frame identifier (e.g. "Jan2026Frame") |
backtest | boolean | Execution mode flag |
recent-items — unique index recent_items_uq on (symbol, strategyName, exchangeName, frameName, backtest)
Registration
Table Schema
Column Reference
Trading pair. Part of the unique index.
Strategy identifier. Part of the unique index.
Exchange identifier. Part of the unique index.
Frame identifier. Part of the unique index.
Execution mode flag. Part of the unique index. Isolates backtest rows from live/paper rows.
The last public signal row.
IPublicSignalRow is the type exported by backtest-kit. Returns null when no signal has been written yet.Logical simulation timestamp at write time, epoch milliseconds.
State Adapter
The State adapter stores per-signal state buckets. A single signal can have multiple independent state buckets (e.g., one for entry logic, one for exit logic), each addressed by(signalId, bucketName). The dispose() method is a no-op — state entries persist until explicitly overwritten by a new writeStateData call.
Context Key and Table
| Field | Type | Role |
|---|---|---|
signalId | string | Signal scope — set in constructor |
bucketName | string | Sub-scope within the signal — set in constructor |
state-items — unique index state_items_uq on (signalId, bucketName)
Registration
Table Schema
TheState.schema.ts definition is the canonical example of the when-column pattern used throughout this stack:
Column Reference
Signal identifier. Part of the unique index.
State bucket name within the signal scope. Part of the unique index.
Arbitrary state data blob.
StateData is the opaque type exported by backtest-kit. Returns null when no state has been written yet.Logical simulation timestamp at write time, epoch milliseconds. Read back as
number via epochTransformer.Set by TypeORM on first insert.
Updated by TypeORM on every write.
Session Adapter
The Session adapter stores exactly one session record per running strategy instance. Like Recent, it includessymbol and backtest in its key so that two symbols running the same strategy on the same exchange in the same frame never share a session row.
The Session schema comment in source code (
Session.schema.ts) notes the historical reason for including symbol and backtest in the uniqueness key: “without them two symbols running the same strategy shared one record and restored each other’s session state after a restart.”Context Key and Table
| Field | Type | Role |
|---|---|---|
strategyName | string | Strategy identifier |
exchangeName | string | Exchange identifier |
frameName | string | Frame identifier |
symbol | string | Trading pair |
backtest | boolean | Execution mode flag |
session-items — unique index session_items_uq on (strategyName, exchangeName, frameName, symbol, backtest)
Registration
Table Schema
SessionDbService.upsert — Atomic Write
Column Reference
Strategy identifier. Part of the unique index.
Exchange identifier. Part of the unique index.
Frame identifier. Part of the unique index.
Trading pair. Part of the unique index — prevents cross-symbol state pollution.
Execution mode flag. Part of the unique index — isolates backtest sessions from live sessions.
Session data blob.
SessionData is the opaque type exported by backtest-kit. Returns null when no session has been written yet.Logical simulation timestamp at write time, epoch milliseconds.
Comparison: Recent vs. State vs. Session
- Recent
- State
- Session
- Constructor fields:
symbol,strategyName,exchangeName,frameName,backtest - Table:
recent-items - Payload type:
IPublicSignalRow dispose(): n/a (not in interface)- Key field count: 5