src/app.ts → scheduleExchangeSessionJobs()
All jobs use Asia/Kolkata timezone (from getTimezone()) and run Monday–Friday unless noted.
Job timetable
Market open/close times are read from
getMarketHoursForGroup() in src/utils/marketHours.ts:
Zerodha 6:00 AM refresh
Kite access tokens expire daily. The morning job:- Sets
zerodhaRefreshInProgressflag - Disconnects WebSocket
- Deletes all
Zerodhadocuments - Runs
autoZerodhaLogin(headless TOTP) - Clears refresh flag in
finallyblock
initializeMarketDataIfNeeded skips auto-login to avoid race conditions.
Weekly data cleanup
deleteOldData(7) removes IndexData documents where created_at is older than 7 days. Runs Saturday 1:00 AM IST.
Shutdown
On graceful shutdown,schedule.gracefulShutdown() cancels all pending jobs before the process exits.
Interval-based jobs (not cron)
These run viaintervalManager rather than node-schedule:
Started/stopped by market session manager based on exchange hours.