Function listenSignalLiveOnce

  • Subscribes to filtered live signal events with one-time execution.

    Only receives events from Live.run() execution. Executes callback once and automatically unsubscribes.

    Parameters

    • filterFn: (event: IStrategyTickResult) => boolean

      Predicate to filter which events trigger the callback

    • fn: (event: IStrategyTickResult) => void

      Callback function to handle the filtered event (called only once)

    Returns () => void

    Unsubscribe function to cancel the listener before it fires

    import { listenSignalLiveOnce } from "./function/event";

    // Wait for first live take profit hit
    listenSignalLiveOnce(
    (event) => event.action === "closed" && event.closeReason === "take_profit",
    (event) => console.log("Live take profit:", event.pnl.pnlPercentage)
    );