IndexSetting collection by syncIndexSettings() in indexSettingGenerator.ts. For the full settings lifecycle see Index settings lifecycle.
Sync entry point
When sync runs
After sync, active symbols (
isActive: true) emit indexSettingUpdated, which triggers the event processor to reload subscriptions.
Kite API call
syncIndexSettings() calls Kite Connect getInstruments() in parallel for NSE, NFO, MCX, CDS. Requires a valid Zerodha access token via getKiteConnectInstance().
What gets populated
Options
optionChainByExpiry— strikes, CE/PE tradingsymbols, tokens, lot sizes per expirybaseDiffper expiry (computed from strike spacing)optionExpiriesByFuturesExpirywhen using futures underlying
Futures
futuresChainByExpiry— contract symbols per expiry dateinstrumentToken,lotSize,contractFormatfor active expiry
Cash
tradingsymbol,instrumentToken,lotSizefrom NSE EQ instrument master
Auto-detected fields
tradingModes—{ cash, futures, options }based on available instrumentsactiveSegment— priority: options → futures → cashoptionsUnderlyingType—SPOTorFUTURESviadetectOptionsUnderlyingType()
Preserved on sync
Admin-controlled fields from the existing document are not overwritten:isActive- Recurring/trailing flags, quantities, durations, limits, market protection
callDifference,putDifference, strike match valueslastActiveRight
Expiry rollover
- Futures:
pickDefaultFuturesExpiry()inoptionExpiryMapper.ts - Options:
resolveOptionExpiryAfterInstrumentSync()inresolveOptionsUnderlying.ts
Supporting modules
Runtime refresh after sync
WhenindexSettingUpdated fires:
- Event processor reloads active settings
- Clears cached strikes for affected index
- Resubscribes base and option tokens on Kite Ticker
Debug endpoint
GET /zerodha/instruments exposes cached instrument dump for debugging. Production sync uses getInstruments() internally during syncIndexSettings(), not on every admin save.