Documentation Index
Fetch the complete documentation index at: https://mintlify.com/theonetrade/backtest-kit/llms.txt
Use this file to discover all available pages before exploring further.
addStrategySchema is the primary registration function for trading logic in Backtest Kit. Every strategy must be registered before it can be referenced in a Backtest.run, Live.run, or Walker.run context. The function stores the schema in an internal registry and validates its structure—including risk profile references and action names—at registration time so that misconfiguration is caught early rather than at execution.
Function Signature
Parameters
A unique string identifier for this strategy. Used as the routing key when calling
Backtest.run, Live.run, and risk/action lookup. Duplicate names throw at registration.Minimum time between successive
getSignal calls. Backtest Kit enforces this throttle to prevent signal spam.Accepted values: "1m" | "3m" | "5m" | "15m" | "30m" | "1h"The signal generation function. Called on each tick when the interval has elapsed and no pending or scheduled signal is active.
- Return an
ISignalDtoto open or schedule a position. - Return
nullto skip this tick with no action.
getCandles, getAveragePrice, and other context-aware helpers work without explicit parameters.References a risk profile registered via
addRiskSchema. If provided, Backtest Kit runs all validation functions from that profile before accepting a signal. Omit to run without risk checks.An array of risk profile names. Use instead of
riskName when a strategy must pass multiple independent risk profiles. All validations must pass for the signal to be accepted.Optional developer note for documentation or introspection. Accessible via
getStrategySchema(strategyName).note.Optional lifecycle hooks for observing signal state changes:
onOpen(symbol, data, currentPrice, backtest)— fired when a position opens.onClose(symbol, data, priceClose, backtest)— fired when a position closes.onTick(symbol, result, backtest)— fired on every tick with the full result union.onActive,onIdle,onSchedule,onCancel— additional state hooks.onSchedulePing/onActivePing— fired every minute while monitoring.onBreakeven,onPartialProfit,onPartialLoss— milestone hooks.
An array of action names registered via
addActionSchema. Each action receives every signal lifecycle event for this strategy and can send notifications, update Redux state, trigger webhooks, etc.ISignalDto — Return Value of getSignal
The object returned bygetSignal is validated and augmented by Backtest Kit before the signal is accepted.
Trade direction.
"long" enters a buy position; "short" enters a sell position.Take-profit exit price. Must be above
priceOpen for "long" and below for "short".Stop-loss exit price. Must be below
priceOpen for "long" and above for "short".Limit entry price. When provided the signal is scheduled—it waits until the market price reaches
priceOpen. When omitted the position opens immediately at the current VWAP price.Expected trade duration in minutes. The position closes with
time_expired if it has not hit TP or SL within this window. Pass Infinity for no timeout. Defaults to CC_MAX_SIGNAL_LIFETIME_MINUTES (1440).Optional UUID for the signal. Auto-generated if omitted.
Dollar amount allocated to the initial entry. Defaults to
CC_POSITION_ENTRY_COST ($100).Human-readable description of the trade rationale, stored alongside the signal.
Example
When
getSignal returns null, Backtest Kit treats the current tick as idle and moves to the next timeframe. The interval throttle timer is not reset by a null return—the next getSignal call still waits for the configured interval to elapse.