Switching from backtest to live trading in Backtest Kit requires changing one class name and removing theDocumentation 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.
frameName field. Everything else — your addExchangeSchema, addRiskSchema, addStrategySchema registrations, and your getSignal logic — stays exactly the same. The engine handles real-time clock progression, crash-safe persistence, and infinite monitoring automatically.
Live.background
Live.background starts an infinite monitoring loop in the background and returns a cancellation function. Signals flow through the same global event listeners you already attached for backtest.
strategyConnectionService.stopStrategy(), which sets an internal _stopped flag. The next tick detects the flag and exits. Any active pending signal continues monitoring until it hits TP, SL, or time expiry — the position is never abandoned.
Live.run (Async Iterator)
For scripts and LLM agent loops, use the async iterator form:Live.run is an infinite generator — it never completes on its own. Use break or cancel the outer async context to stop it.
Crash Recovery Flow
Live mode is designed to survive process crashes. Here is what happens on each restart:On the very first tick,
ClientStrategy.waitForInit() (protected by singleshot) reads the last saved signal from disk:public waitForInit = singleshot(async () => {
if (!this.params.execution.context.backtest) {
this._pendingSignal = await PersistSignalAdapter.readSignalData(
this.params.strategyName,
this.params.execution.context.symbol
);
}
});
If a pending signal was found, the engine skips
getSignal and immediately resumes TP/SL monitoring at the current market price. The open position is never re-entered.The restored signal continues monitoring until it hits TP, SL, or
minuteEstimatedTime expiry — exactly as if the process had never restarted.Custom Persistence Adapter
Replace the default file-based persistence with any backend:Live Reports
Generate and save the same reports in live mode using theLive facade:
LiveStatisticsModel includes all closed-trade metrics plus the full eventList with every tick event (idle, opened, active, closed) for dashboard integration.
Key Differences from Backtest Mode
| Aspect | Backtest | Live |
|---|---|---|
| Time source | ClientFrame → Date[] array | new Date() every tick |
| Loop | Finite — exhausts timeframes[] | Infinite — while(true) |
| Frame required | Yes | No |
| Signal persistence | Skipped (memory only) | Atomic file write on every mutation |
| Crash recovery | N/A | waitForInit() restores last signal |
| Performance | ~700× real-time per symbol | Real-time (wall clock) |
Connecting to a Real Exchange
To place actual orders on the exchange, register aBroker adapter before calling Live.background. The adapter’s methods are called atomically — if the exchange rejects an order, the internal position state rolls back and the engine retries on the next tick.