list_universe API¶
Shadow Ingest / API Reference / General-Purpose
list_universe(
*,
date,
) -> list[str]
Returns valid A-share stock codes for a date.
This is the main helper to use when you want valid stock_codes for the public data APIs.
Before You Run This Example¶
Parameters¶
| Parameter | Required | Default | Allowed values / shape | Meaning |
|---|---|---|---|---|
date |
yes | — | YYYY-MM-DD, YYYYMMDD, datetime.date, or another date-like object |
Which trading date to evaluate |
Parameter Notes¶
dateis required; there is no implicit "latest" fallback- return values are always A-share stock codes such as
000001.XSHE - if the backing dataset exposes
order_book_idinstead ofstock_code, the SDK still normalizes the public result tostock_code - legacy callers may still pass
market="cn-stock"for compatibility, but new code should omit it - use
list_hk_universe(...)for Hong Kong stock codes; HK helpers do not accept amarketparameter
Accepted date forms:
YYYY-MM-DDstringYYYYMMDDinteger or stringdatetime.date- other date-like objects with
year,month, andday
Why date Is Explicit¶
Trading calendars and universe data can drift independently across environments.
Requiring an explicit date keeps the helper predictable and makes downstream workflows reproducible.
Copy-Paste Example¶
import shadow_ingest as si
stock_codes = si.list_universe(date="2024-01-03")
stock_codes_from_int = si.list_universe(date=20240103)
print(stock_codes[:5])
print(stock_codes_from_int[:5])
print(len(stock_codes))
Example Output¶
[
"000001.XSHE",
"000002.XSHE",
"000004.XSHE",
"000006.XSHE",
"000007.XSHE",
]
[
"000001.XSHE",
"000002.XSHE",
"000004.XSHE",
"000006.XSHE",
"000007.XSHE",
]
5000
Typical Follow-Up¶
A common pattern is to pass the result directly into another SDK API:
import shadow_ingest as si
trade_date = "2024-01-03"
stock_codes = si.list_universe(date=trade_date)
industry_df = si.get_industry_mapping(
stock_codes=stock_codes[:50],
standard="sws",
trade_date=trade_date,
)