Source: src/utils/zerodha/zerodha-event.utils.ts ZerodhaEventProcessor (exported as zerodhaEvent) is the core market data engine.

Lifecycle

Tick pipeline

  1. zerodhaConnection receives raw Kite tick
  2. processTick() routes by instrument token → index + segment (cash/futures/options)
  3. Aggregates into latestSnapshotData per index
  4. Every 1000ms (BROADCAST_INTERVAL_MS), broadcastAll():
    • Emits io.emit(\$TickData`, payload)` to Socket.IO clients
    • Emits marketDataEmitter for latestDataMap storage

Strike calculation

For options:
  • Computes base value and CALL/PUT strikes from tick LTP
  • Subscribes/unsubscribes option leg tokens dynamically
  • Uses optionChainByExpiry from index settings

Segment support

Trading engine input

Controllers read processed snapshots from latestDataMap (via socket manager) for recurring buy / trailing sell decisions.