Skip to main content

Exchange Calendars: issession, trade_date_range

Project description

Holidays in China

Background

We classify calendar days into:

  • regular workdays
  • regular weekends (Saturday and Sunday) not working
  • festivals: true or legal holidays
  • quasi-holidays: extra holidays swapped with weekend workdays
  • weekend workdays:workdays in weekends for swapped extra holidays

For example, 2025-12-31 (Wednesday) is a regular workday.

2025-01-01 (Thursday) is a festival holiday (New Year)

2025-01-02 (Friday) is a quasi-holiday, though we need not to work on this day, but we need to work on 2026-01-04 (Sunday) to swap with this extra holiday.

2025-01-03 (Saturday) is a regular weekend.

2025-01-04 (Sunday) is a weekend workday. Though it a weekend, but we to work on this day to swap with extra extra holiday on 2025-01-02.

On weekend workdays, exchanges in China mainland are closed, although they are workdays.

In November each year, the state council of China announces the holiday arrangement for next year. Please update the holiday data accordingly.

cnexchcal Package

This package provides a class to handle holidays and trading days in China mainland since year 2004. We does not touch holidays before 2004.

Installation

pip install cnexchcal

Usage

Instantiation:

from cnexchcal import ExchCal
cal = ExchCal()

To return holiday names in Chinese or English

cal.holiday_cnnames
cal.holiday_ennames

To determine if a given date is a holiday or workday, uese:

cal.isholiday('2026-01-04')   # False
cal.isworkday('2026-01-04')   # True

To determine if a given date is a trading day:

cal.issession('2026-01-04')   # False

To get the previous trading day, use:

cal.previoussession('2026-01-04')   # 2025-12-31

To get the next trading day, use:

cal.nextsession('2026-01-01')   # 2026-01-05

To get the n-th trading day after a given date, use:

cal.next_nth_tradingday('2026-01-01', 3)   # 2026-01-07

To get all trading dates between two given dates, use:

cal.trade_date_range('2025-12-20', '2026-02-28')

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

cnexchcal-0.2.0-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file cnexchcal-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: cnexchcal-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for cnexchcal-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ce4c16ce9c77e7c7d358083739435b1e592e30d6e2e6c8fa4aeb17d9a7efecc6
MD5 384175d865b88eb84e1b0d99b0e695b2
BLAKE2b-256 db0d7d370ae830f4b2ed39ab177abe1377683692b43ff511851ff90dfddfbb3a

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