Function listenDoneLive

  • Subscribes to live background execution completion events with queued async processing.

    Emits when Live.background() completes execution. Events are processed sequentially in order received, even if callback is async. Uses queued wrapper to prevent concurrent execution of the callback.

    Parameters

    • fn: (event: DoneContract) => void

      Callback function to handle completion events

    Returns () => void

    Unsubscribe function to stop listening to events

    import { listenDoneLive, Live } from "backtest-kit";

    const unsubscribe = listenDoneLive((event) => {
    console.log("Live completed:", event.strategyName, event.exchangeName, event.symbol);
    });

    Live.background("BTCUSDT", {
    strategyName: "my-strategy",
    exchangeName: "binance"
    });

    // Later: stop listening
    unsubscribe();