Function commitCreateStopLoss

  • Reports that the pending position's stop-loss order was actually filled on the exchange (e.g. by candle high/low), forcing a close that bypasses the VWAP-based SL check.

    The exchange and the strategy are parallel states: the framework evaluates TP/SL against VWAP, but the real order may fill on high/low. The close is deferred and emitted with closeReason "stop_loss" on the next tick. No-op if no pending signal exists.

    Automatically detects backtest/live mode from execution context.

    Parameters

    • symbol: string

      Trading pair symbol

    • Optionalpayload: Partial<CommitPayload>

      Optional commit payload with id and note

    Returns Promise<void>

    Promise that resolves when the stop-loss fill is queued

    import { commitCreateStopLoss } from "backtest-kit";

    // Report SL fill confirmed on the exchange
    await commitCreateStopLoss("BTCUSDT", { id: "sl-fill-001" });