Skip to main content

bse_history.py — Trading Calendar

BSEWorkingDays() / get_next_bseworkingdate() mirror nseeod/utils.py's NSEWorkingDays() / get_next_nseworkingdate(), reading holidays/specialdays with exch=3 instead of exch=1.


Calendar Seeding — exch=3, Shared Tables​

holidays/specialdays already have an exch column (NSE=1, MCX=2 — see MCXEOD's calendar notes). BSE slots in as exch=3 with zero schema change — no migration needed, unlike every other piece of BSE's schema.

India's BSE and NSE equity trading calendars are effectively identical in practice, so seed_bse_holidays_from_nse() seeds BSE's exch=3 rows by copying NSE's exch=1 rows, rather than scraping a separate source — the same approach MCX's calendar took as a starting point (derived from NSE's, with MCX-specific closures layered on top).

cd backend
python -m bseeod.bse_history # dry run - reports what would be inserted
python -m bseeod.bse_history --apply # actually insert

Confirmed live 2026-10-11: 465 holidays + 59 special (Muhurat) days copied into exch=3 from NSE's existing calendar. Safe to re-run — only inserts dates not already present under exch=3.

A starting point, not a guarantee

This is a reasonable default, not a substitute for checking BSE's own published trading-holiday circular before relying on it for a specific historical backfill range — the two exchanges' calendars are usually identical but not contractually guaranteed to be.


BSEWorkingDays(fromdate, todate)​

Returns a DataFrame indexed by date, built from a pandas.tseries.offsets.CustomBusinessDay over holidays (exch=3) plus any specialdays (exch=3) rows in range — same construction as NSEWorkingDays.

get_next_bseworkingdate(fromdate)​

The next BSE trading day strictly after fromdate, walking a 20-day window forward (mirrors get_next_nseworkingdate's approach).


  • bse_backfill.py — the main consumer, via BSEWorkingDays() to compute pending dates
  • bse_downloader.py — BseEodEqUpdater.update() and friends use BSEWorkingDays() to walk missing dates in a daily sync