Function setSessionData

  • Writes a session value scoped to the current (symbol, strategy, exchange, frame) context.

    Session data persists across candles within a single run and can survive process restarts in live mode — useful for caching LLM inference results, intermediate indicator state, or any cross-candle accumulator that is not tied to a specific signal.

    Pass null to clear the session.

    Automatically detects backtest/live mode from execution context.

    Type Parameters

    • Value extends object = object

    Parameters

    • symbol: string

      Trading pair symbol

    • value: Value

      New value or null to clear

    Returns Promise<void>

    Promise that resolves when the session has been written

    import { setSession } from "backtest-kit";

    await setSession("BTCUSDT", { lastLlmSignal: "buy" });