Callback function to handle progress events
Unsubscribe function to stop listening to events
import { listenBacktestProgress, Backtest } from "backtest-kit";
const unsubscribe = listenBacktestProgress((event) => {
console.log(`Progress: ${(event.progress * 100).toFixed(2)}%`);
console.log(`${event.processedFrames} / ${event.totalFrames} frames`);
console.log(`Strategy: ${event.strategyName}, Symbol: ${event.symbol}`);
});
Backtest.background("BTCUSDT", {
strategyName: "my-strategy",
exchangeName: "binance",
frameName: "1d-backtest"
});
// Later: stop listening
unsubscribe();
Subscribes to backtest progress events with queued async processing.
Emits during Backtest.background() execution to track progress. Events are processed sequentially in order received, even if callback is async. Uses queued wrapper to prevent concurrent execution of the callback.