gather_daily_snapshot API¶
Shadow Ingest / API Reference / Task-Oriented
gather_daily_snapshot(
trade_date: str,
stock_codes: list[str],
) -> polars.DataFrame
Returns a daily cross-sectional snapshot for one trading date.
Before You Run This Example¶
Parameters¶
| Parameter | Required | Default | Allowed values / shape | Meaning |
|---|---|---|---|---|
trade_date |
yes | — | YYYY-MM-DD |
Which trading date to query |
stock_codes |
yes | — | list of stock codes such as ['000001.XSHE', '600000.XSHG'] |
Which stocks to include in the cross section |
Discovery Workflow¶
import shadow_ingest as si
trade_dates = si.list_market_calendar(year=2024)
stock_codes = si.list_universe(date=trade_dates[-1])
snapshot_df = si.gather_daily_snapshot(
trade_date=trade_dates[-1].isoformat(),
stock_codes=stock_codes[:2],
)
print(trade_dates[:3])
print(stock_codes[:5])
print(snapshot_df.columns)
Parameter Notes¶
trade_date¶
Use list_market_calendar(...) when you want a valid trading date:
import shadow_ingest as si
trade_dates = si.list_market_calendar(year=2024)
print(trade_dates[-5:])
stock_codes¶
Use list_universe(...) when you want valid identifiers for a trading date:
import shadow_ingest as si
stock_codes = si.list_universe(date='2024-01-03')
print(stock_codes[:10])
Snapshot columns¶
This API does not expose a stable public fields parameter.
If you want to see what columns are currently available in your environment:
import shadow_ingest as si
snapshot_df = si.gather_daily_snapshot(
trade_date='2024-01-02',
stock_codes=['000001.XSHE'],
)
print(snapshot_df.columns)
Copy-Paste Example¶
import shadow_ingest as si
snapshot_df = si.gather_daily_snapshot(
trade_date='2024-01-02',
stock_codes=['000001.XSHE', '600000.XSHG', '600519.XSHG'],
)
print(snapshot_df.head())
print(snapshot_df.schema)
Example Output¶
┌────────────┬─────────────┬──────┬──────┬───────┬──────────┐
│ trade_date ┆ stock_code ┆ open ┆ high ┆ close ┆ volume │
│ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │
│ date ┆ str ┆ f64 ┆ f64 ┆ f64 ┆ f64 │
╞════════════╪═════════════╪══════╪══════╪═══════╪══════════╡
│ 2024-01-02 ┆ 000001.XSHE ┆ 9.39 ┆ 9.4 ┆ 9.21 ┆ 1.14e8 │
│ 2024-01-02 ┆ 600000.XSHG ┆ 7.21 ┆ 7.28 ┆ 7.25 ┆ 8.76e7 │
│ 2024-01-02 ┆ 600519.XSHG ┆ 1688 ┆ 1699 ┆ 1692 ┆ 3.42e6 │
└────────────┴─────────────┴──────┴──────┴───────┴──────────┘
Pandas¶
snapshot_pdf = snapshot_df.to_pandas()