Type Alias BrokerTrailingStopPayload

BrokerTrailingStopPayload: {
    backtest: boolean;
    context: {
        exchangeName: ExchangeName;
        frameName?: FrameName;
        strategyName: StrategyName;
    };
    currentPrice: number;
    newStopLossPrice: number;
    percentShift: number;
    position: "long"
    | "short";
    symbol: string;
    takeProfitPrice: number;
}

Payload for a trailing stop-loss update broker event.

Forwarded to the registered IBroker adapter via onTrailingStopCommit. Called explicitly after all validations pass, before strategyCoreService.trailingStop(). newStopLossPrice is the absolute SL price computed from percentShift + original SL + effectivePriceOpen.

Type declaration

  • backtest: boolean

    true when called during a backtest run — adapter should skip exchange calls

  • context: {
        exchangeName: ExchangeName;
        frameName?: FrameName;
        strategyName: StrategyName;
    }

    Strategy/exchange/frame routing context

  • currentPrice: number

    Current market price used for intrusion validation

  • newStopLossPrice: number

    Absolute stop-loss price after applying percentShift

  • percentShift: number

    Percentage shift applied to the ORIGINAL SL distance (-100 to 100)

  • position: "long" | "short"

    Position direction

  • symbol: string

    Trading pair symbol, e.g. "BTCUSDT"

  • takeProfitPrice: number

    Active take profit price at the time of the trailing update

// LONG: entry=100, originalSL=90, percentShift=-5 → newSL=95
const payload: BrokerTrailingStopPayload = {
symbol: "BTCUSDT",
percentShift: -5,
currentPrice: 102,
newStopLossPrice: 95,
context: { strategyName: "my-strategy", exchangeName: "binance", frameName: "1h" },
backtest: false,
};