Skip to main content

Indian stock market calendar for NSE, MCX, Indian trading holidays, and intraday session-aware market-open checks.

Project description

aion-indian-market-calendar

Indian stock market calendar for Python — NSE trading calendar, MCX trading hours, and Indian market holidays API.

⚠️ Update (v1.1.0):

Market resolution has been fixed to ensure all inputs map to canonical segments.

  • "NFO" now correctly resolves to "NSE_EQUITY_DERIVATIVES"
  • "NIFTY" / "BANKNIFTY" resolve to derivatives by default

If you previously passed non-canonical market names, behavior is now deterministic.

If you are using <=1.0.0, upgrade immediately:

pip install --upgrade aion-indian-market-calendar

v1.1.0 fixes incorrect market resolution for NFO and index inputs.

Use this if you need to answer:

  • is NSE market open today?
  • what are NSE/MCX trading hours right now?
  • which days are trading holidays in India?
  • build intraday or algo trading systems with correct market timings

Works as a Python API for NSE trading calendar, Indian stock market holidays, MCX trading hours, "is market open today India" queries, and financial market calendar needs in quantitative finance and algorithmic trading.

Includes macro-event awareness (RBI, Budget, FOMC) for trading system restrictions.

If you tried using pandas_market_calendars for India and ran into incorrect holidays or missing MCX sessions, this package fixes those gaps.

Structure

aion_indian_market_calendar/
├── __init__.py
├── _calendar.py
├── models.py
├── data/
│   └── events_2026.json
├── tests/
│   ├── conftest.py
│   └── test_calendar.py
├── pyproject.toml
└── README.md

Quick Start

Simple Python API, no external services required.

Is the market open right now?

from aion_indian_market_calendar import is_market_open

is_market_open("NSE")  # True / False
is_market_open("MCX")  # Handles evening sessions correctly

Used in intraday trading and algo trading systems to prevent execution during closed sessions. Works for real-time checks like: "is NSE market open today?"

Next trading day

from aion_indian_market_calendar import next_trading_day

next_trading_day("NSE")

Full calendar API

import pytz

from datetime import datetime

from aion_indian_market_calendar import IndiaMarketCalendar

cal = IndiaMarketCalendar.bundled(2026)
ist = pytz.timezone("Asia/Kolkata")
now = datetime.now(ist)

# Check if NSE equity is trading right now
print("NSE open?", cal.is_market_open(now, "NSE_EQUITY"))

# Get today's exact trading session (accounts for partial MCX days)
session = cal.get_session(now, "MCX")
for seg in session or []:
    print(f"MCX: {seg.open} - {seg.close}")

# List all NSE equity holidays for 2026
for d in cal.holidays("NSE_EQUITY", 2026):
    print(d)

Designed for trading systems, bots, and execution engines that require accurate Indian market timings.

Market Input Handling

This package accepts:

  • canonical market segments (recommended)
  • common aliases such as NFO
  • common instruments such as NIFTY and BANKNIFTY

All supported inputs are normalized internally to canonical market segments before holiday and session lookup.

Examples:

from datetime import datetime

from aion_indian_market_calendar import IndiaMarketCalendar

cal = IndiaMarketCalendar.bundled(2026)
probe = datetime.fromisoformat("2026-01-27T10:00:00+05:30")

assert cal.get_session(probe, market="NFO") == cal.get_session(probe, market="NSE_EQUITY_DERIVATIVES")
assert cal.get_session(probe, market="NIFTY") == cal.get_session(probe, market="NSE_EQUITY_DERIVATIVES")

Unknown market inputs now raise ValueError.

Use with AION News-to-Signal

Used alongside AION News-to-Signal for:

  • validating whether a signal falls within trading hours
  • blocking trades on holidays or macro-event windows
  • aligning intraday execution with real Indian market sessions

Why Developers Choose aion-indian-market-calendar

  • Save weeks of engineering: no need to scrape NSE circulars, parse Hindu calendars, or model MCX partial sessions
  • Production-ready: verified against official exchange calendars and tested for known edge cases
  • Live delta updates: refresh from a remote URL, no pip install --upgrade needed for every holiday change
  • LLM-friendly: static JSON and live endpoint are machine-readable, so coding assistants can query or embed the package

Live Refresh

calendar = IndiaMarketCalendar.bundled(
    2026,
    refresh_url="https://<username>.github.io/<repo>/live_events.json",
    refresh_interval_hours=4,
)

calendar.refresh()
  • live deltas are cached at ~/.aion_indian_market/live_cache.json
  • bundled static events remain the fallback
  • live events override bundled events by id
  • deleted_ids can remove bundled events without repackaging the wheel

Delta Format

{
  "version": "20260430-001",
  "generated_at": "2026-04-30T10:00:00+05:30",
  "events": [],
  "deleted_ids": []
}

Notes

  • data/events_2026.json can be either:
    • a plain list of event objects, or
    • an object with top-level metadata plus an events list
  • main typed models:
    • MarketEvent
    • EventPolicy
    • SessionSegment
  • bundled metadata also exposes:
    • calendar.sources
    • calendar.market_timings
    • calendar.default_sessions
  • convenience helpers:
    • is_market_open(market="NSE", at=None, year=2026)
    • next_trading_day(market="NSE", after=None, year=2026)
  • live refresh metadata exposes:
    • calendar.refresh_url
    • calendar.refresh_interval
  • bundled 2026 segment calendars now include:
    • NSE_EQUITY
    • NSE_EQUITY_DERIVATIVES
    • NSE_CURRENCY_DERIVATIVES
    • NSE_COMMODITY_DERIVATIVES
    • NSE_INTEREST_RATE_DERIVATIVES
    • NSE_CORPORATE_BONDS
    • MCX
  • EventCalendar remains available as a compatibility alias for IndiaMarketCalendar
  • the current bundled data is copied from:
    • src/shared_core/risk/special_events_and_holidays.json and extended with:
    • https://nsearchives.nseindia.com/content/RSS/Circulars.xml
    • https://www.nseindia.com/resources/exchange-communication-holidays
    • https://www.mcxindia.com/market-operations/trading-survelliance/trading-holidays
  • repo-side helpers for live updates:
    • scripts/poll_nse_rss.py
    • .github/workflows/update_live_events.yml
    • .github/workflows/publish_live_events.yml

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aion_indian_market_calendar-1.1.0.tar.gz (22.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aion_indian_market_calendar-1.1.0-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

Details for the file aion_indian_market_calendar-1.1.0.tar.gz.

File metadata

File hashes

Hashes for aion_indian_market_calendar-1.1.0.tar.gz
Algorithm Hash digest
SHA256 2f5672a2af57605f4028e26ab4cd5fc110c9e7b7d2b6335812413ebd92ba952f
MD5 f4e779991f75c77756c4368dc7ac2408
BLAKE2b-256 6eb73d478752e0ec5a375edf901aa52784c22d6d0ca808a273723e5b375702de

See more details on using hashes here.

File details

Details for the file aion_indian_market_calendar-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for aion_indian_market_calendar-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dcf1ca112615dc575f4e321e12ca0d11539c6b5429e05a63fd7977e6f295c50c
MD5 b1087659e9635aa03f72996b1c1e4c0e
BLAKE2b-256 a52b0eb59a2c6ea0e835c2b499f3fae0208ceb7616fe4a6cfbd9147430af1760

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page