Interface OpenAlgoTradeConfig

interface OpenAlgoTradeConfig {
    apiKey: string;
    baseUrl: string;
    constraints?: (
        symbol: string,
        exchange: string,
    ) => undefined | OrderConstraints;
    defaultProduct?: "CNC" | "NRML" | "MIS";
    disableIdempotency?: boolean;
    fetchImpl?: (
        input: URL | RequestInfo,
        init?: RequestInit,
    ) => Promise<Response>;
    modeCacheMs?: number;
    now?: () => number;
    onDecodeIssue?: (snapshot: OrderBookSnapshot) => void;
    strategy?: string;
    verifyMode?: ModeCheck;
}

Properties

apiKey: string
baseUrl: string
constraints?: (symbol: string, exchange: string) => undefined | OrderConstraints

Instrument constraints for the advisory pre-trade check on place, looked up per order. Return undefined when the instrument is unknown; the universal checks below still apply.

Optional because most of the value needs no configuration: a quantity that is NaN, negative or fractional is wrong for every Indian instrument and is rejected without knowing anything about the symbol. Supply this to add the freeze limit and the lot grid, which do need instrument data.

defaultProduct?: "CNC" | "NRML" | "MIS"

Default product when a request doesn't specify one.

disableIdempotency?: boolean

Turn off the feed-level duplicate guard. Default false, i.e. the guard is on. Only set true if a layer above already owns idempotency AND you have read why that is usually the wrong call: see _claimToken.

fetchImpl?: (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>

Type declaration

    • (input: URL | RequestInfo, init?: RequestInit): Promise<Response>
    • Parameters

      • input: URL | RequestInfo
      • Optionalinit: RequestInit

      Returns Promise<Response>

modeCacheMs?: number

How long a server-mode reading stays usable, in ms. Default 5000.

now?: () => number

Clock, injectable so the mode cache is testable without real timers.

onDecodeIssue?: (snapshot: OrderBookSnapshot) => void

Called after an order book fetch that had to quarantine rows. Fail-closed parsing drops nothing silently: a host that shows the book must be able to tell the trader that part of it could not be read.

strategy?: string

Strategy label sent with orders (OpenAlgo groups by strategy).

verifyMode?: ModeCheck

Mode guard on place. Default 'auto', which is described in full on _assertMode. 'always' checks both directions and refuses when the server cannot be asked; 'off' restores the pre-1.6 behaviour of trusting the caller's mode outright.