The minimal broker write interface the OrderEngine drives: place / modify / cancel. OpenAlgoTradeFeed implements this. Distinct from the base-tier TradeFeed (a higher-level place + subscribe shape in openalgo-charts): implement OrderFeed for the engine's write path.

Implements

Constructors

Accessors

Methods

  • Fetch the order book, keeping the rows that could not be read.

    getOrders returns the first half of this. A host that renders the book needs the second half too: "2 rows from the broker could not be read" is a thing the trader must see, and a quietly shorter list is not.

    Returns Promise<OrderBookSnapshot>

  • Read the analyzer mode the SERVER is in.

    Analyzer mode is a server-side global in OpenAlgo: get_analyze_mode() decides where every order goes, and it is flipped at POST /api/v1/analyzer/toggle. It is not a per-order flag, there is no mode field on the placeorder payload, and one added there would be read by nothing. So this client never asserts a mode. It asks for the server's, and place refuses when the answer disagrees with the caller's belief.

    Answers younger than maxAgeMs are reused, so a host that polls the books (whose sandbox responses carry the mode already) never pays for this call.

    Parameters

    • maxAgeMs: number = ...

    Returns Promise<TradeMode>

  • Parameters

    • orderId: string
    • changes: { price?: number; qty?: number; triggerPrice?: number }

    Returns Promise<void>

  • Place an order through OpenAlgo's placeorder route.

    An order without exchange goes to NSE, and one without product takes the feed's defaultProduct. Both defaults are documented and hosts place through them, so they stay through 2.x. modify() is stricter on purpose: it never guesses an exchange or product for an order the book does not describe, since a guess there moves a live order somewhere its owner did not put it. A host that trades on any other exchange passes exchange with every order.

    Every refusal before the request is sent is a pre-flight error, so the caller can correct and retry knowing nothing reached the broker.

    Parameters

    Returns Promise<{ orderId: string }>

  • Release a claim after the host has established what really happened, for instance by finding no such order in a freshly fetched book.

    Deliberately manual. Nothing in this library can safely decide on its own that an ambiguous order did not reach the exchange.

    Parameters

    • token: string

    Returns void

  • Whether a client order id is known to have reached the broker.

    'ambiguous' is the one worth handling: the request left and the outcome is unknown, so the order may be live. A host should say so and offer the order book, not a retry button.

    Parameters

    • token: string

    Returns "unknown" | "inflight" | "sent" | "ambiguous"