Function getLatestSignal

  • Returns the latest signal (pending or closed) for the current strategy context.

    Does not distinguish between active and closed signals — returns whichever was recorded last. Useful for cooldown logic: e.g. skip opening a new position for 4 hours after a stop-loss by checking the timestamp of the latest signal regardless of its outcome.

    Searches backtest storage first, then live storage. Returns null if no signal exists at all.

    Automatically detects backtest/live mode from execution context.

    Parameters

    • symbol: string

      Trading pair symbol

    Returns Promise<IPublicSignalRow>

    Promise resolving to the latest signal or null

    import { getLatestSignal } from "backtest-kit";

    const latest = await getLatestSignal("BTCUSDT");
    if (latest && Date.now() - latest.closedAt < 4 * 60 * 60 * 1000) {
    return; // cooldown after SL — skip new signal for 4 hours
    }