Type Alias BrokerOrderCheckPayload

BrokerOrderCheckPayload: {
    backtest: boolean;
    context: {
        exchangeName: ExchangeName;
        frameName?: FrameName;
        strategyName: StrategyName;
    };
    currentPrice: number;
    maxDrawdown: IStrategyPnL;
    peakProfit: IStrategyPnL;
    pnl: IStrategyPnL;
    position: "long"
    | "short";
    priceOpen: number;
    priceStopLoss: number;
    priceTakeProfit: number;
    signalId: string;
    symbol: string;
    totalEntries: number;
    totalPartials: number;
    type: "schedule" | "active";
}

Payload for the order synchronization broker event.

Emitted automatically via syncPendingSubject on every live tick while a signal is monitored, BEFORE the framework evaluates completion. Forwarded to the registered IBroker adapter, routed by type to the matching callback:

  • type: "active" — pending signal (open position), before TP/SL/time evaluation — delivered to onOrderActiveCheck;
  • type: "schedule" — scheduled signal, before timeout/price-activation evaluation (the order in question is the resting entry order) — delivered to onOrderScheduleCheck.

The adapter should query the exchange by signalId and THROW ONLY when the order is definitively NOT FOUND by that id (filled, cancelled, or liquidated externally). A throw propagates to CREATE_SYNC_PENDING_FN, which makes the framework close the pending signal with closeReason "closed" (type "active") or cancel the scheduled signal with reason "user" (type "schedule"). Returning normally keeps the signal under normal monitoring.

NOTE for type "schedule": if the resting entry order actually FILLED, confirm the fill via commitActivateScheduled instead of throwing — a throw here is a terminal cancel, not an activation.

CRITICAL: transient/network errors (timeout, 5xx, rate limit, disconnect) must be SWALLOWED — return normally instead of throwing. A thrown network error would wrongly close an open position. Only a confirmed "order not found by id" response is a valid reason to throw.

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

    Market price at the moment of the ping

  • maxDrawdown: IStrategyPnL

    Maximum drawdown experienced during the life of this position up to this event

  • peakProfit: IStrategyPnL

    Peak profit achieved during the life of this position up to this event

  • pnl: IStrategyPnL

    Unrealized PnL of the open position at the moment of the ping

  • position: "long" | "short"

    Position direction

  • priceOpen: number

    Effective entry price (may differ from priceOpen after DCA averaging)

  • priceStopLoss: number

    Effective stop-loss price at the moment of the ping

  • priceTakeProfit: number

    Effective take-profit price at the moment of the ping

  • signalId: string

    Unique signal identifier (UUID v4) the order belongs to

  • 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

  • type: "schedule" | "active"

    Monitored state: "active" — open position order, "schedule" — resting entry order

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