Interface Policy<OrderModel, ExecutionReportModel>

A custom pre-trade policy implemented in JavaScript. Pass an object satisfying this shape to EngineBuilder.preTrade / ReadyEngineBuilder.preTrade; the engine adapts it to a native policy and invokes its hooks during the pre-trade, post-trade, and account-adjustment flows.

checkPreTradeStart and performPreTradeCheck are required. Their optional dry-run counterparts let a stateful policy provide a read-only emulation; when absent, the engine falls back to the corresponding normal hook. applyExecutionReport and applyAccountAdjustment are optional. Each hook is called with this bound to the policy object.

interface Policy<OrderModel, ExecutionReportModel> {
    name: string;
    policyGroupId?: number;
    applyAccountAdjustment?(ctx: AccountAdjustmentContext, accountId: AccountId, adjustment: AccountAdjustment): PolicyAccountAdjustmentResult;
    applyExecutionReport?(ctx: PostTradeContext, report: ExecutionReportModel): undefined | null | PostTradeResult;
    checkPreTradeStart(ctx: Context, order: OrderModel): Iterable<PolicyReject, any, any>;
    checkPreTradeStartDryRun?(ctx: Context, order: OrderModel): Iterable<PolicyReject, any, any>;
    performPreTradeCheck(ctx: Context, order: OrderModel): undefined | null | PolicyPreTradeResult;
    performPreTradeCheckDryRun?(ctx: Context, order: OrderModel): undefined | null | PolicyPreTradeResult;
}

Type Parameters

Properties

name: string

Unique policy name.

policyGroupId?: number

Policy group id (0..=65535); defaults to 0 when omitted.

Methods

  • Start-stage check. Returns the rejects to raise (empty iterable to accept).

    Parameters

    Returns Iterable<PolicyReject, any, any>

  • Read-only start-stage hook used by startPreTradeDryRun and executePreTradeDryRun. Falls back to checkPreTradeStart when omitted.

    Parameters

    Returns Iterable<PolicyReject, any, any>