list_market_calendar API¶
Shadow Ingest / API Reference / General-Purpose
list_market_calendar(
market: str = 'cn-stock',
start_date=None,
end_date=None,
year: int | None = None,
) -> list[datetime.date]
Returns valid trading dates for a supported market.
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 |
|---|---|---|---|---|
market |
no | 'cn-stock' |
currently only 'cn-stock' |
Which market calendar to query |
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¶
yearcannot be combined withstart_dateorend_date- the return value is sorted ascending
- current supported market:
cn-stock
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'