Type Alias BrokerOrderCheckPayload

BrokerOrderCheckPayload: {
    attempt: number;
    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";
    when: Date;
}

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. Returning normally keeps the signal under normal monitoring. Throw semantics (see IBrokerOrderVerdict):

  • OrderDeletedError — the CONFIRMED "order not found by id" (filled, cancelled, or liquidated externally): terminal AT ONCE — close the pending signal with closeReason "closed" (type "active") or cancel the scheduled signal with reason "user" (type "schedule"), bypassing the tolerance counter.
  • plain Error / OrderTransientError (timeout, 5xx, rate limit, disconnect) — TOLERATED as a transient failure: the order is assumed still open, the next ping carries attempt incremented, up to CC_ORDER_CHECK_RETRY_ATTEMPTS consecutive failures before the framework acts terminally (a successful check resets the streak).
  • OrderRejectedError — protocol violation in this channel, degrades to transient.

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.

Type declaration

  • attempt: number

    Consecutive prior FAILED checks for this signal (0 = first check / healthy). Managed by the framework: a failed check increments the counter carried by the next ping while the failure is tolerated as transient (CC_ORDER_CHECK_RETRY_ATTEMPTS); a successful check resets it to 0.

  • 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

  • when: Date

    Virtual time of the event: candle timestamp in backtest, wall-clock tick time in live

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,
};