Backtest Kit exposes a rich set of event listeners built on reactiveDocumentation 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.
Subject-based emitters. Every listener wraps its callback in a queued function, which guarantees sequential async execution — if a callback returns a Promise, the next invocation waits for it to resolve before starting. All listeners return an unsubscribe function that tears down the subscription when called.
Signal Events
listenSignal
Subscribe to all signal events from both backtest and live modes.IStrategyTickResult is a discriminated union: { action: "idle" | "scheduled" | "waiting" | "opened" | "active" | "closed" | "cancelled"; ... }. Use event.action to branch.
listenSignalOnce
Subscribe to the first signal event matching a filter predicate, then automatically unsubscribe.listenSignalBacktest
Subscribe to signal events fromBacktest.background() / Backtest.run() only.
listenSignalBacktestOnce
One-shot filtered subscription to backtest signal events.listenSignalLive
Subscribe to signal events fromLive.background() / Live.run() only.
listenSignalLiveOnce
One-shot filtered subscription to live signal events.Completion Events
listenDoneBacktest
Fires when aBacktest.background() execution completes for a symbol-strategy pair.
DoneContract contains { symbol, strategyName, exchangeName, frameName, backtest }.
listenDoneLive
Fires when aLive.background() execution completes.
listenDoneWalker
Fires when aWalker.background() execution completes.
listenDoneLiveOnce / listenDoneBacktestOnce / listenDoneWalkerOnce
One-shot filtered variants for completion events.Progress
listenBacktestProgress
Receive progress updates duringBacktest.background() execution.
ProgressBacktestContract contains { symbol, strategyName, exchangeName, totalFrames, processedFrames, progress } where progress is 0.0–1.0.
listenWalkerProgress
Receive progress updates duringWalker.background() execution, emitted after each strategy completes.
ProgressWalkerContract contains { walkerName, exchangeName, frameName, symbol, totalStrategies, processedStrategies, progress } where progress is 0.0–1.0.
listenPerformance
Subscribe to execution timing metrics for profiling and bottleneck detection.PerformanceContract includes { metricType, duration, strategyName, exchangeName, frameName, symbol, backtest }. metricType is one of "backtest_total" | "backtest_timeframe" | "backtest_signal" | "live_tick".
Risk & Error Events
listenRisk
Fires only when a signal is rejected by the risk management system. Does not fire for allowed signals.RiskContract includes { symbol, strategyName, currentPrice, activePositionCount, rejectionNote, rejectionId, backtest }.
listenRiskOnce
One-shot filtered risk rejection listener.listenError
Subscribe to recoverable execution errors. Execution continues after these errors.Position Milestone Events
listenPartialProfit (listenPartialProfitAvailable)
Fires once per profit milestone (10%, 20%, …, 100%) per signal. Deduplicated with aSet — each level fires at most once per signal.
PartialProfitContract includes { symbol, strategyName, data, currentPrice, level, backtest, timestamp } where level is one of 10 | 20 | 30 | 40 | 50 | 60 | 70 | 80 | 90 | 100.
listenPartialLoss (listenPartialLossAvailable)
Fires once per loss milestone per signal.listenBreakeven (listenBreakevenAvailable)
Fires once per signal when the price moves far enough to cover transaction costs and the stop-loss can be moved to entry.Ping Events
listenSchedulePing
Fires every minute while a scheduled signal (limit entry) is waiting for activation.listenActivePing
Fires every minute while a pending signal (active position) is being monitored.listenIdlePing
Fires every tick when no signal is pending or scheduled.listenIdlePingOnce
One-shot filtered subscription to idle ping events.Lifecycle Events
listenBeforeStart
Fires exactly once perrun() invocation, immediately before the first candle or tick is processed. Useful for run-scoped initialization: opening log files, resetting accumulators, sending a “run started” notification.
BeforeStartContract includes { symbol, strategyName, exchangeName, frameName, backtest, currentPrice, when, timestamp }. In backtest mode when is the planned frame start date; in live mode it is the current wall-clock time aligned to the minute.
listenBeforeStartOnce
One-shot filtered subscription to before-start events.listenAfterEnd
Fires exactly once perrun() invocation after the strategy iterator finishes — whether by reaching the end of the frame, being stopped via stopStrategy, throwing an error, or external cancellation. Always paired with a preceding listenBeforeStart event. Useful for teardown: flushing buffers, closing files, computing final aggregates.
AfterEndContract includes { symbol, strategyName, exchangeName, frameName, backtest, currentPrice, when, timestamp }. In backtest mode when is the cursor position of the last processed candle.