Indian trading systems often need to decide automatically whether to start, pause, or stop based on which exchange segment is actually open.
A single "is today a trading day?" check is not enough. NSE equity, CDS (currency), and MCX (commodities) have different hours. Some days are partial sessions (Muhurat trading, special closures). Hard-coding dates or relying on generic calendars leads to bots that either miss sessions or try to trade on holidays.
aion-indian-market-calendar solves exactly this problem.
Install
pip install aion-indian-market-calendar
Basic Showcase
from aion_indian_market_calendar import IndiaMarketCalendar
from datetime import datetime
import pytz
cal = IndiaMarketCalendar.bundled(2026)
ist = pytz.timezone("Asia/Kolkata")
now = datetime.now(ist)
print("NSE equity open?", cal.is_market_open(now, "NSE")) # 9:00–15:30
print("CDS open?", cal.is_market_open(now, "CDS")) # 9:00–17:00
print("MCX open?", cal.is_market_open(now, "MCX")) # 9:00–23:30
session = cal.get_session(now, "MCX")
if session:
for seg in session:
print(seg.open, "→", seg.close)
It correctly handles:
- Different close times (15:30 vs 17:00 vs 23:30)
- Muhurat trading (short evening session, usually on Diwali)
- Exchange-specific holidays
- Live refresh (optional) for last-minute circular changes
Comparison with Common Alternatives
| Tool / Approach | NSE Equity | CDS (to 5pm) | MCX Evening Session | Muhurat Trading | Partial Holidays | Notes |
|---|---|---|---|---|---|---|
| pandas_market_calendars (XNSE) | Partial | No | No | Treated as holiday | Poor | Generic calendar, no India evening sessions |
| Hard-coded holiday list | Fragile | Fragile | Fragile | Easy to miss | Very fragile | Breaks every year or on circular changes |
| Custom "if date in holidays" | Error-prone | Misses segments | Completely wrong | No | No | Common source of production incidents |
| aion-indian-market-calendar | Yes | Yes | Yes | Yes (special session) | Yes (per segment) | Segment-aware, bundled data + live refresh |
Generic calendars fail because Indian exchanges do not share one uniform schedule.
Real Use Case: Auto-Start Systems on Partial Working Days
Many developers run data pipelines, scanners, or execution engines that should only be active when a market segment is open.
Instead of one cron job that always runs 9 AM–11:30 PM, you can poll at fixed intervals and decide per segment.
Example: Polling to Auto-Start/Stop for Different Sessions
import time
from datetime import datetime
import pytz
from aion_indian_market_calendar import IndiaMarketCalendar
cal = IndiaMarketCalendar.bundled(2026)
ist = pytz.timezone("Asia/Kolkata")
def should_run_for_segment(segment: str) -> bool:
now = datetime.now(ist)
return cal.is_market_open(now, segment)
# Simple polling loop (run this in a supervisor or systemd timer)
while True:
now = datetime.now(ist)
equity_open = should_run_for_segment("NSE") or should_run_for_segment("BSE")
cds_open = should_run_for_segment("CDS")
mcx_morning = should_run_for_segment("MCX") # first session
mcx_evening = cal.is_market_open(now, "MCX") and now.hour >= 17
if equity_open:
# start or keep alive equity data ingestion / scanners
print(f"{now} — Equity session active (NSE/BSE)")
else:
# gracefully stop equity components
pass
if cds_open:
print(f"{now} — CDS session active")
if mcx_morning or mcx_evening:
print(f"{now} — MCX session active (morning or evening)")
time.sleep(60) # poll every minute; adjust as needed
Why This Matters on Partial Holidays
- Muhurat Trading Day: Equity has a very short evening session (often 1 hour). Generic calendars mark the whole day as holiday. Your polling will correctly see the special session and can start the equity engine only for that window.
- Exchange-specific closures: One segment may be closed while another is open.
- MCX second session: Even on normal days, the evening session (roughly 5 PM – 11:30 PM) is separate. Systems that only watch "9 AM – 3:30 PM" will miss commodity opportunities or data.
By checking is_market_open("SEGMENT") or get_session(...) you get the precise truth for that segment at that moment.
Other Useful Methods for Automation
cal.trading_days("NSE_EQUITY", 2026) # list of actual trading dates
cal.holidays("NSE_EQUITY", 2026) # holidays for a segment
cal.events_on("2026-11-08", "NSE") # detects Muhurat etc.
You can also enable live refresh against the official AION endpoint so last-minute circular changes are picked up without rebuilding the package.
Bottom Line for Developers
If you are building anything that needs to run autonomously around Indian market hours — data collectors, risk engines, execution schedulers, scanners — you need segment-aware, session-aware calendar logic.
aion-indian-market-calendar gives you that in one small, MIT-licensed package with no external dependencies beyond pytz/tzdata.
pip install aion-indian-market-calendar
Full documentation and vs-pandas comparison:
https://dashboard.aiondashboard.site/open-source/indian-market-calendar
Use it to poll, decide, and auto-start only when the right session is actually open — including the tricky partial and evening sessions that trip up most systems.
Source: AION Analytics (India) dashboard
Mirrored for discoverability. aion-indian-market-calendar is MIT licensed and available on PyPI.
Top comments (0)