Type Alias BrokerPendingClosePayload

BrokerPendingClosePayload: {
    backtest: boolean;
    closeReason?: StrategyCloseReason;
    context: {
        exchangeName: ExchangeName;
        frameName?: FrameName;
        strategyName: StrategyName;
    };
    currentPrice: number;
    position: "long"
    | "short";
    priceOpen: number;
    priceStopLoss: number;
    priceTakeProfit: number;
    signalId: string;
    symbol: string;
}

Payload for the pending-signal-close broker event.

Emitted automatically via signalEventSubject (action "closed") when a pending position is closed. Forwarded to the registered IBroker adapter via onSignalPendingClose. The closeReason distinguishes take_profit / stop_loss / time_expired / user-close / broker fill / order gone.

Type declaration

  • backtest: boolean

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

  • OptionalcloseReason?: StrategyCloseReason

    Why the position closed: "take_profit" / "stop_loss" / "time_expired" / "closed"

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

    Strategy/exchange/frame routing context

  • currentPrice: number

    Market price at the moment of close

  • position: "long" | "short"

    Position direction

  • priceOpen: number

    Effective entry price of the closed position

  • priceStopLoss: number

    Effective stop-loss price of the closed position

  • priceTakeProfit: number

    Effective take-profit price of the closed position

  • signalId: string

    Unique signal identifier (UUID v4) of the closed position

  • symbol: string

    Trading pair symbol, e.g. "BTCUSDT"

const payload: BrokerPendingClosePayload = {
symbol: "BTCUSDT",
position: "long",
currentPrice: 55000,
priceOpen: 50000,
priceTakeProfit: 55000,
priceStopLoss: 48000,
closeReason: "take_profit",
context: { strategyName: "my-strategy", exchangeName: "binance", frameName: "1h" },
backtest: false,
};