Source: nifty_fifty_bank_nifty_NodeJS/src/controllers/recurringOrder.controller.ts
API: POST /api/recurringOrder (JWT — any authenticated user)

What it does

Places BUY orders on a repeating interval while recurring status is on. On start it places one buy immediately, then continues on the configured duration.

Segment behavior

Key rules

  • Interval comes from callBuyDuration / putBuyDuration (options), or buyDuration (cash/futures). Minimum enforced interval is about 0.1667 minutes (~10 seconds).
  • Order type is typically MARKET for index options/futures and LIMIT for stock-style symbols (symbolType === 'Stock').
  • If buyOrderLimit (or call/put buy limit) is greater than 0 and unsold BUY count reaches that limit, further recurring buys are skipped.
  • Buy limit counts all unsold BUYs — there is no date filter, so open positions from prior days count toward the limit.
  • Quantity must be greater than 0; otherwise the tick is skipped.
  • For options, tradingsymbol is resolved from optionChainByExpiry for the selected strike and CE/PE.

Market guards

  • Skips when !isExchangeMarketOpen(exchange) for the index’s configured exchange.
  • Skips when tick data is missing from latestDataMap[$TickData].

Interval and product

  • Interval key: recurringOrder_${indexName}_${right} registered via registerInterval in intervalManager.ts.
  • Product / exchange by segment when starting recurring:
    • Cash: NSE, product CNC
    • Futures / Options: NFO (or index exchange), product NRML

Start / stop

  • Start: handleRecurringOrder with recurringStatus: true creates a recurring DB row, sets segment flags (e.g. options.isPlacingCallOrder / isPlacingPutOrder, or cash/futures isRecurringBuy), and registers an interval.
  • Stop: recurringStatus: false stops the interval immediately (prevents one more in-flight buy). For options only, stopping also triggers a bulk sell of unsold completed BUYs for that right (unless skipBulkSell is true). Cash and futures stop the interval only — no bulk sell.
  • Market open resume: startOrderServicesForSymbol in marketSessionManager.ts restarts schedule order service and recurring buy from last active settings when the exchange session opens.