Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/backtest-kit/backtest-kit-redis-postgres-pgpool-docker/llms.txt

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

All 16 PostgreSQL tables used by backtest-kit-redis-postgres-pgpool-docker are defined as TypeORM EntitySchema objects inside src/schema/. When the application starts, TypeORM’s synchronize: true option inspects the connected database and automatically creates any missing tables or indexes — no manual migrations or CREATE TABLE statements are required on first run.

Common Columns

Every one of the 16 entity schemas shares three infrastructure columns that TypeORM manages automatically.
ColumnPostgreSQL TypeNotes
iduuidPrimary key. Generated server-side with gen_random_uuid().
createDatetimestamptzSet once at insert time; never updated afterward.
updatedDatetimestamptzRefreshed on every write by TypeORM’s updateDate flag.

epochTransformer

Several columns store millisecond-precision Unix timestamps as PostgreSQL bigint values. The pg driver always deserializes bigint columns as JavaScript strings to avoid integer overflow, so a ValueTransformer is needed to convert those strings back to plain number values on the JavaScript side.
// src/utils/epochTransformer.ts
import { ValueTransformer } from "typeorm";

/**
 * Stores epoch-millisecond numbers in a Postgres `bigint` column while keeping
 * the JS-visible value a plain `number`. The `pg` driver returns `bigint` as a
 * string, so `from` parses it back; `to` passes the number through unchanged.
 */
export const epochTransformer: ValueTransformer = {
  to: (value: number | null | undefined) => value,
  from: (value: string | null | undefined) =>
    value === null || value === undefined ? value : Number(value),
};
Every column declared as { type: "bigint", transformer: epochTransformer } in the schemas below uses this transformer. The to direction is a no-op (TypeORM serializes the number as-is), while from parses the string returned by pg back to a number.

Schema Catalog

The 16 schemas are grouped below by their functional role: immutable market data, signal state (live position tracking), soft-delete key/value stores, and session & runtime state.

Immutable Market Data

candle-items

Stores OHLCV price bars fetched from an exchange. Each bar is uniquely identified by its symbol, interval, and timestamp.
// src/schema/Candle.schema.ts (columns excerpt)
timestamp: { type: "bigint", transformer: epochTransformer },
open:      { type: "double precision" },
high:      { type: "double precision" },
low:       { type: "double precision" },
close:     { type: "double precision" },
volume:    { type: "double precision" },
ColumnPostgreSQL TypeNotes
iduuidPK, auto-generated
symbolvarcharTrading pair, e.g. BTC/USDT
intervalvarcharCandleInterval enum value
timestampbigintMillisecond epoch — epochTransformer applied
exchangeNamevarcharSource exchange identifier
opendouble precisionOpening price
highdouble precisionHigh price
lowdouble precisionLow price
closedouble precisionClosing price
volumedouble precisionTrade volume
createDatetimestamptzAuto-set on insert
updatedDatetimestamptzAuto-updated on write
Unique index candle_items_uq: (symbol, interval, timestamp)

Signal State

These tables track the lifecycle of trading signals and their associated risk, partial-close, and breakeven state. Each row is keyed by a combination of symbol, strategy name, exchange name, and optionally a signalId.

signal-items

Holds the current open-signal row for each (symbol, strategyName, exchangeName) triplet. payload is the full ISignalRow object (nullable — cleared when no signal is active).
ColumnPostgreSQL TypeNotes
iduuidPK, auto-generated
symbolvarchar
strategyNamevarchar
exchangeNamevarchar
payloadjsonbISignalRow | null
createDatetimestamptz
updatedDatetimestamptz
Unique index signal_items_uq: (symbol, strategyName, exchangeName)

schedule-items

Same shape as signal-items. Stores a pending scheduled signal (IScheduledSignalRow | null) for each (symbol, strategyName, exchangeName) triplet, cleared after the schedule fires.
ColumnPostgreSQL TypeNotes
iduuidPK, auto-generated
symbolvarchar
strategyNamevarchar
exchangeNamevarchar
payloadjsonbIScheduledSignalRow | null
createDatetimestamptz
updatedDatetimestamptz
Unique index schedule_items_uq: (symbol, strategyName, exchangeName)

strategy-items

Persists strategy-level data (StrategyData | null) for each (symbol, strategyName, exchangeName) combination, allowing strategies to survive restarts.
ColumnPostgreSQL TypeNotes
iduuidPK, auto-generated
symbolvarchar
strategyNamevarchar
exchangeNamevarchar
payloadjsonbStrategyData | null — nullable
createDatetimestamptz
updatedDatetimestamptz
Unique index strategy_items_uq: (symbol, strategyName, exchangeName)

risk-items

Stores the aggregated open positions (RiskData) managed by a named risk controller on a specific exchange. The when column records the last update time.
ColumnPostgreSQL TypeNotes
iduuidPK, auto-generated
riskNamevarcharRisk controller identifier
exchangeNamevarchar
positionsjsonbRiskData
whenbigintLast update epoch ms — epochTransformer applied
createDatetimestamptz
updatedDatetimestamptz
Unique index risk_items_uq: (riskName, exchangeName)

partial-items

Tracks partial-close state (PartialData) for an individual signal, identified by its four-part key.
ColumnPostgreSQL TypeNotes
iduuidPK, auto-generated
symbolvarchar
strategyNamevarchar
exchangeNamevarchar
signalIdvarcharUnique ID of the parent signal
payloadjsonbPartialData
whenbigintEpoch ms — epochTransformer applied
createDatetimestamptz
updatedDatetimestamptz
Unique index partial_items_uq: (symbol, strategyName, exchangeName, signalId)

breakeven-items

Mirrors partial-items in structure. Stores breakeven-move state (BreakevenData) for a specific signal.
ColumnPostgreSQL TypeNotes
iduuidPK, auto-generated
symbolvarchar
strategyNamevarchar
exchangeNamevarchar
signalIdvarcharUnique ID of the parent signal
payloadjsonbBreakevenData
whenbigintEpoch ms — epochTransformer applied
createDatetimestamptz
updatedDatetimestamptz
Unique index breakeven_items_uq: (symbol, strategyName, exchangeName, signalId)

storage-items

A generic persistent signal store. Unlike signal-items, rows here are never cleared — they form a durable history of every signal’s final serialized state (IStorageSignalRow). The backtest flag separates live and backtest namespaces.
ColumnPostgreSQL TypeNotes
iduuidPK, auto-generated
backtestbooleantrue for backtest runs
signalIdvarcharUnique signal identifier
payloadjsonbIStorageSignalRow
createDatetimestamptz
updatedDatetimestamptz
Unique index storage_items_uq: (backtest, signalId)

notification-items

Stores dispatched notifications (NotificationModel) deduplicated by notificationId. The backtest flag separates live and backtest notification namespaces.
ColumnPostgreSQL TypeNotes
iduuidPK, auto-generated
backtestboolean
notificationIdvarcharDeduplication key
payloadjsonbNotificationModel
createDatetimestamptz
updatedDatetimestamptz
Unique index notification_items_uq: (backtest, notificationId)

recent-items

Stores the most-recent public signal snapshot (IPublicSignalRow) per (symbol, strategyName, exchangeName, frameName, backtest) quintuple. Useful for UI dashboards that need the last known signal state without querying history.
ColumnPostgreSQL TypeNotes
iduuidPK, auto-generated
symbolvarchar
strategyNamevarchar
exchangeNamevarchar
frameNamevarcharTime-frame identifier
backtestboolean
payloadjsonbIPublicSignalRow
whenbigintEpoch ms — epochTransformer applied
createDatetimestamptz
updatedDatetimestamptz
Unique index recent_items_uq: (symbol, strategyName, exchangeName, frameName, backtest)

log-items

An append-style log store. Each ILogEntry is deduplicated by entryId, preventing duplicate log rows on retry.
ColumnPostgreSQL TypeNotes
iduuidPK, auto-generated
entryIdvarcharContent-addressed deduplication key
payloadjsonbILogEntry
createDatetimestamptz
updatedDatetimestamptz
Unique index log_items_uq: (entryId)

Soft-Delete Key/Value Stores

measure-items, interval-items, and memory-items all include a removed: boolean column (default false). Rows are never physically deleted. Instead, listKeys filters on removed = false, and a logical-delete operation flips the flag to true. This preserves historical audit trails while keeping queries fast on the active subset.

measure-items

A key/value store for named measurements (MeasureData). Each row lives in a bucket namespace and is addressed by entryKey.
ColumnPostgreSQL TypeNotes
iduuidPK, auto-generated
bucketvarcharNamespace for the measurement
entryKeyvarcharUnique key within the bucket
payloadjsonbMeasureData
removedbooleanSoft-delete flag, default false
createDatetimestamptz
updatedDatetimestamptz
Unique index measure_items_uq: (bucket, entryKey)

interval-items

Extends measure-items with a when timestamp. Stores time-stamped interval data (IntervalData) within a bucket/key namespace.
ColumnPostgreSQL TypeNotes
iduuidPK, auto-generated
bucketvarcharNamespace
entryKeyvarcharUnique key within the bucket
payloadjsonbIntervalData
removedbooleanSoft-delete flag, default false
whenbigintEpoch ms — epochTransformer applied
createDatetimestamptz
updatedDatetimestamptz
Unique index interval_items_uq: (bucket, entryKey)

memory-items

Stores arbitrary strategy memory blobs (MemoryData). Each entry is addressed by a three-part key: signalId, bucketName, and memoryId.
ColumnPostgreSQL TypeNotes
iduuidPK, auto-generated
signalIdvarcharParent signal identifier
bucketNamevarcharMemory namespace
memoryIdvarcharUnique key within the bucket
payloadjsonbMemoryData
removedbooleanSoft-delete flag, default false
whenbigintEpoch ms — epochTransformer applied
createDatetimestamptz
updatedDatetimestamptz
Unique index memory_items_uq: (signalId, bucketName, memoryId)

Session and Runtime State

state-items

Persists the runtime state blob (StateData) for a signal/bucket pair. State is restored on reconnect, enabling strategies to resume exactly where they left off.
ColumnPostgreSQL TypeNotes
iduuidPK, auto-generated
signalIdvarcharParent signal identifier
bucketNamevarcharState namespace
payloadjsonbStateData
whenbigintEpoch ms — epochTransformer applied
createDatetimestamptz
updatedDatetimestamptz
Unique index state_items_uq: (signalId, bucketName)

session-items

Persists the session checkpoint (SessionData) for a strategy running on a specific exchange, frame, and symbol. The backtest flag ensures live and backtest sessions are stored independently.
symbol and backtest are both part of the uniqueness key. Without them, two symbols running the same strategy on the same exchange would share one record and overwrite each other’s session state after a restart.
ColumnPostgreSQL TypeNotes
iduuidPK, auto-generated
strategyNamevarchar
exchangeNamevarchar
frameNamevarchar
symbolvarchar
backtestbooleanSeparates live from backtest sessions
payloadjsonbSessionData
whenbigintEpoch ms — epochTransformer applied
createDatetimestamptz
updatedDatetimestamptz
Unique index session_items_uq: (strategyName, exchangeName, frameName, symbol, backtest)

Auto-Synchronization

TypeORM’s synchronize: true (set in src/config/postgres.ts) automatically creates all 16 tables and their unique indexes the first time the application connects to a fresh database. There is nothing to run manually. For production deployments where you need precise control over schema changes, consider switching to TypeORM migrations (synchronize: false + migrations: [...]) to prevent unintended ALTER TABLE operations during upgrades.
The full entity list registered with the DataSource is:
// src/config/postgres.ts
entities: [
  BreakevenModel,
  CandleModel,
  IntervalModel,
  LogModel,
  MeasureModel,
  MemoryModel,
  NotificationModel,
  PartialModel,
  RecentModel,
  RiskModel,
  ScheduleModel,
  SessionModel,
  SignalModel,
  StateModel,
  StorageModel,
  StrategyModel,
],
synchronize: true,
logging: false,

Build docs developers (and LLMs) love