Type Alias BrokerSignalClosePayload

BrokerSignalClosePayload: {
    backtest: boolean;
    context: {
        exchangeName: ExchangeName;
        frameName?: FrameName;
        strategyName: StrategyName;
    };
    cost: number;
    currentPrice: number;
    pnl: IStrategyPnL;
    position: "long"
    | "short";
    priceStopLoss: number;
    priceTakeProfit: number;
    symbol: string;
    totalEntries: number;
    totalPartials: number;
}

Payload for the signal-close broker event.

Emitted automatically via syncSubject when a pending signal is closed (SL/TP hit or manual close). Forwarded to the registered IBroker adapter via onSignalCloseCommit.

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

  • cost: number

    Total dollar cost basis of the position at close

  • currentPrice: number

    Market price at the moment of close

  • pnl: IStrategyPnL

    Realized PnL breakdown for the closed position

  • position: "long" | "short"

    Position direction

  • priceStopLoss: number

    Original stop-loss price from the signal

  • priceTakeProfit: number

    Original take-profit price from the signal

  • symbol: string

    Trading pair symbol, e.g. "BTCUSDT"

  • totalEntries: number

    Total number of DCA entries (including initial open)

  • totalPartials: number

    Total number of partial closes executed before final close

const payload: BrokerSignalClosePayload = {
symbol: "BTCUSDT",
cost: 100,
position: "long",
currentPrice: 54000,
priceTakeProfit: 55000,
priceStopLoss: 48000,
totalEntries: 2,
totalPartials: 1,
pnl: { profit: 80, loss: 0, volume: 100 },
context: { strategyName: "my-strategy", exchangeName: "binance", frameName: "1h" },
backtest: false,
};