跳转至

list_market_calendar API

Shadow Ingest / API Reference / General-Purpose
list_market_calendar(
    start_date=None,
    end_date=None,
    year: int | None = None,
) -> list[datetime.date]

Returns valid A-share trading dates.

This is the main helper to use when you want valid trade_date, start_date, or end_date values.

Before You Run This Example

Parameters

Parameter Required Default Allowed values / shape Meaning
start_date no None YYYY-MM-DD, YYYYMMDD, datetime.date, date-like object Inclusive lower bound
end_date no None YYYY-MM-DD, YYYYMMDD, datetime.date, date-like object Inclusive upper bound
year no None integer year such as 2024 Shortcut for the full calendar year

Parameter Notes

  • year cannot be combined with start_date or end_date
  • the return value is sorted ascending
  • this helper is for the A-share calendar
  • legacy callers may still pass market="cn-stock" for compatibility, but new code should omit it
  • use list_hk_market_calendar(...) for Hong Kong trading dates; HK helpers do not accept a market parameter

Copy-Paste Example

import shadow_ingest as si

trade_dates = si.list_market_calendar(year=2024)
january_dates = si.list_market_calendar(
    start_date='2024-01-01',
    end_date='2024-01-31',
)

print([d.isoformat() for d in trade_dates[:5]])
print([d.isoformat() for d in january_dates[:5]])
print(trade_dates[-1].isoformat())

Example Output

[
  '2024-01-02',
  '2024-01-03',
  '2024-01-04',
  '2024-01-05',
  '2024-01-08',
]
[
  '2024-01-02',
  '2024-01-03',
  '2024-01-04',
  '2024-01-05',
  '2024-01-08',
]
'2024-12-31'