Type Alias StrategyStatus

StrategyStatus: {
    activatedSignal: IScheduledSignalActivateRow | null;
    cancelledSignal: IScheduledSignalCancelRow | null;
    closedSignal: ISignalCloseRow | null;
    commitQueue: ICommitRow[];
    createdSignal: ISignalDto | null;
    isPaused: boolean;
    pendingSignalId: string | null;
    retryCloseCount: number;
    retryOpenCount: number;
    retryOpenSignal: ISignalRow | IScheduledSignalRow | null;
    stopLossSignal: ISignalCloseRow | null;
    takeProfitSignal: ISignalCloseRow | null;
}

Type for persisted deferred strategy state. Snapshot of the in-flight commit queue and deferred user actions that have not yet been forwarded to the broker. Restored on waitForInit after a live crash so the pending broker operations are not silently lost.

Type declaration

  • activatedSignal: IScheduledSignalActivateRow | null

    Deferred user-initiated scheduled activate (activateScheduled), or null if none pending

  • cancelledSignal: IScheduledSignalCancelRow | null

    Deferred user-initiated scheduled cancel (cancelScheduled), or null if none pending

  • closedSignal: ISignalCloseRow | null

    Deferred user-initiated close (closePending), or null if none pending

  • commitQueue: ICommitRow[]

    Queued commit events (average-buy / partial-* / trailing-* / breakeven) not yet drained

  • createdSignal: ISignalDto | null

    User-supplied signal DTO scheduled to be consumed by the next getSignal tick instead of params.getSignal (set via createPending / createScheduled), or null if none queued. createPending and createScheduled overwrite the same slot, so only the latest wins.

  • isPaused: boolean

    Pause flag: while true nothing new opens — params.getSignal is NOT called and a queued createSignal DTO is NOT consumed (it stays queued and drains after unpause); an existing pending/scheduled signal keeps being monitored and closes normally. Unlike the deferred slots above this flag is NOT tied to any signalId — it is restored unconditionally on waitForInit and survives signal transitions until an explicit setPaused(false).

  • pendingSignalId: string | null

    Id of the pending signal these deferred operations belong to (from _pendingSignal.id), or null if there was no pending signal when the snapshot was written. On restore, the deferred fields are applied only when this matches the restored _pendingSignal.id — otherwise the snapshot belongs to a different/stale position and is discarded.

  • retryCloseCount: number

    Number of close-gate attempts STARTED for the current pending signal (pre-armed BEFORE each gate call — a crash mid-close-attempt still counts it, so after a restart the next close event carries attempt > 0 and the adapter knows a prior exit order MAY have reached the exchange). Restored only when the snapshot belongs to the restored pending signal (pendingSignalId match) or to a deferred user-close drain (closedSignal present), and CLAMPED to 1 — a stale pre-crash streak must not force-close on the first post-restart rejection; only the reconcile bit survives. Reset on a confirmed close and on any pending-signal transition.

  • retryOpenCount: number

    Number of gate attempts STARTED for retryOpenSignal's signalId (pre-armed BEFORE each gate call, so a crash mid-attempt still counts it). The gate event carries attempt = retryOpenCount - 1; once the started-attempts budget (1 initial + CC retries) is spent, the retry row is dropped loudly and signal generation resumes. Reset on successful open. Restored CLAMPED to 1 after a restart: only the attempt >= 1 reconcile bit survives — a stale pre-crash streak must not burn the fresh retry budget.

  • retryOpenSignal: ISignalRow | IScheduledSignalRow | null

    Gate-rejected open awaiting an identity-stable retry (CC_ORDER_OPEN_RETRY_ATTEMPTS), or null if none. The row is re-submitted with its ORIGINAL signalId so an idempotent broker adapter (clientOrderId = signalId) reconciles a lost-response fill instead of double-buying. Write-ahead: stays persisted until the open outcome (success / exhaustion / failed re-validation) is durably recorded — a crash right after the broker confirmed the open replays the same id and resolves on the exchange side.

  • stopLossSignal: ISignalCloseRow | null

    Deferred broker-confirmed stop-loss fill (createStopLoss), or null if none pending. Set when the external order management system reports the position's SL order was actually filled on the exchange (e.g. by candle high/low) — independent of the VWAP-based SL check. Drained on the next tick/backtest to close the position with closeReason "stop_loss".

  • takeProfitSignal: ISignalCloseRow | null

    Deferred broker-confirmed take-profit fill (createTakeProfit), or null if none pending. Set when the external order management system reports the position's TP order was actually filled on the exchange (e.g. by candle high/low) — independent of the VWAP-based TP check. Drained on the next tick/backtest to close the position with closeReason "take_profit".