list_universe API¶
Shadow Ingest / API Reference / General-Purpose
list_universe(
*,
date,
market: str = "cn-stock",
) -> list[str]
Returns valid tradable stock codes for a supported market and 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 |
market |
no | "cn-stock" |
currently only "cn-stock" |
Which market universe to query |
Parameter Notes¶
dateis required; there is no implicit "latest" fallback- current supported market:
cn-stock - for
cn-stock, the return values are always stock codes such as000001.XSHE - if the backing dataset exposes
order_book_idinstead ofstock_code, the SDK still normalizes the public result tostock_code
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(market="cn-stock", 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,
)