Type Alias BrokerPartialProfitPayload

BrokerPartialProfitPayload: {
    backtest: boolean;
    context: {
        exchangeName: ExchangeName;
        frameName?: FrameName;
        strategyName: StrategyName;
    };
    cost: number;
    currentPrice: number;
    percentToClose: number;
    position: "long"
    | "short";
    priceStopLoss: number;
    priceTakeProfit: number;
    symbol: string;
}

Payload for a partial-profit close broker event.

Forwarded to the registered IBroker adapter via onPartialProfitCommit. Called explicitly after all validations pass, before strategyCoreService.partialProfit().

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

    Dollar value of the portion being closed

  • currentPrice: number

    Current market price at which the partial close executes

  • percentToClose: number

    Percentage of the position to close (0–100)

  • position: "long" | "short"

    Position direction

  • priceStopLoss: number

    Active stop loss price at the time of the partial close

  • priceTakeProfit: number

    Active take profit price at the time of the partial close

  • symbol: string

    Trading pair symbol, e.g. "BTCUSDT"

const payload: BrokerPartialProfitPayload = {
symbol: "BTCUSDT",
percentToClose: 30,
cost: 30,
currentPrice: 52000,
context: { strategyName: "my-strategy", exchangeName: "binance", frameName: "1h" },
backtest: false,
};