Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/quant_platform_kit/common/cn_equity_calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,28 @@

CN_EQUITY_TIMEZONE = "Asia/Shanghai"

# Weekday holidays on SSE/SZSE calendars (2024-01-01 .. 2026-12-31), sourced from AkShare trade-date history.
# Weekday holidays on SSE/SZSE calendars (2023-01-01 .. 2026-12-31), sourced from the official
# SSE/SZSE holiday notices for 2023 and the existing trade-date history for later years.
CN_EQUITY_HOLIDAYS: frozenset[str] = frozenset(
{
"2023-01-02",
"2023-01-23",
"2023-01-24",
"2023-01-25",
"2023-01-26",
"2023-01-27",
"2023-04-05",
"2023-05-01",
"2023-05-02",
"2023-05-03",
"2023-06-22",
"2023-06-23",
"2023-09-29",
"2023-10-02",
"2023-10-03",
"2023-10-04",
"2023-10-05",
"2023-10-06",
"2024-01-01",
"2024-02-09",
"2024-02-12",
Expand Down
30 changes: 30 additions & 0 deletions tests/test_cn_equity_calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,36 @@ def test_new_year_holiday_is_not_trading_day(self) -> None:
def test_regular_weekday_is_trading_day(self) -> None:
self.assertTrue(is_cn_equity_trading_day("2024-01-02"))

def test_2023_weekday_holidays_are_not_trading_days(self) -> None:
closed_days = (
"2023-01-02",
"2023-01-23",
"2023-01-24",
"2023-01-25",
"2023-01-26",
"2023-01-27",
"2023-04-05",
"2023-05-01",
"2023-05-02",
"2023-05-03",
"2023-06-22",
"2023-06-23",
"2023-09-29",
"2023-10-02",
"2023-10-03",
"2023-10-04",
"2023-10-05",
"2023-10-06",
)
for day in closed_days:
with self.subTest(day=day):
self.assertFalse(is_cn_equity_trading_day(day))

def test_2023_post_holiday_weekdays_are_trading_days(self) -> None:
for day in ("2023-01-03", "2023-01-30", "2023-04-06", "2023-05-04", "2023-06-26", "2023-10-09"):
with self.subTest(day=day):
self.assertTrue(is_cn_equity_trading_day(day))

def test_next_trading_day_skips_weekend_and_holiday(self) -> None:
self.assertEqual(next_cn_equity_trading_day("2024-02-08"), date(2024, 2, 19))

Expand Down