Interface OrderEngineOptions

interface OrderEngineOptions {
    armed?: boolean;
    capabilities?: TradingCapabilitySource;
    clock?: () => number;
    confirmCommand?: (command: TradingCommand) => boolean | Promise<boolean>;
    constraints: OrderConstraints;
    features?: TradingFeatureSource;
    feed: OrderFeed;
    gate?: GateFn;
    idGen?: () => string;
    maxSettledOrders?: number;
    minModifyIntervalMs?: number;
    mode?: TradeMode;
    now?: () => number;
    onValidationError?: (reason: string) => void;
    selectedAccount?:
        | Pick<AccountStateSource, "getState">
        | () => undefined | null | string;
}

Properties

armed?: boolean

Armed = fire immediately; otherwise the gate must approve each order.

Host restrictions combined with the feed's, rechecked before every write.

clock?: () => number

Wall clock in UTC seconds, for expiry checks. Default Date.now() / 1000.

confirmCommand?: (command: TradingCommand) => boolean | Promise<boolean>

Approves close, reverse and bracket commands when not armed. Omitted declines them.

constraints: OrderConstraints

Host restrictions on the newer operations, combined with the feed's features; either can refuse.

feed: OrderFeed
gate?: GateFn
idGen?: () => string
maxSettledOrders?: number

How many settled orders stay readable before the oldest are dropped. A trading session is a long-lived page and the per-order maps used to grow for its whole life. 0 drops each order the moment it settles.

minModifyIntervalMs?: number
mode?: TradeMode
now?: () => number
onValidationError?: (reason: string) => void

Called for modify validation and unsupported modify/cancel operations.

selectedAccount?:
    | Pick<AccountStateSource, "getState">
    | () => undefined | null | string

The account selection. When set, every order and command is stamped with it, one naming another account is refused, and a change while confirming sends nothing. Pass the account view itself (an AccountManager) and a selection from the other ledger is refused as well: a bare id cannot say whether it is a live account about to take a sandbox order.