nifty_fifty_bank_nifty_NodeJS/src/controllers/recurringOrder.controller.tsAPI:
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), orbuyDuration(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
optionChainByExpiryfor 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 viaregisterIntervalinintervalManager.ts. - Product / exchange by segment when starting recurring:
- Cash: NSE, product
CNC - Futures / Options: NFO (or index exchange), product
NRML
- Cash: NSE, product
Start / stop
- Start:
handleRecurringOrderwithrecurringStatus: truecreates a recurring DB row, sets segment flags (e.g.options.isPlacingCallOrder/isPlacingPutOrder, or cash/futuresisRecurringBuy), and registers an interval. - Stop:
recurringStatus: falsestops 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 (unlessskipBulkSellis true). Cash and futures stop the interval only — no bulk sell. - Market open resume:
startOrderServicesForSymbolinmarketSessionManager.tsrestarts schedule order service and recurring buy from last active settings when the exchange session opens.