Skip to content

gather_daily_price API

Shadow Ingest / API Reference / Task-Oriented
gather_daily_price(
    stock_codes: list[str],
    start_date: str,
    end_date: str,
    fields: list[str] | None = None,
    adjust_type: Literal['raw', 'pre', 'post', 'adj_fwd', 'adj_bwd'] = 'raw',
    *,
    auto_batch: bool = True,
    batch_symbols: int = 200,
    batch_days: int = 365,
) -> polars.DataFrame

Returns daily price rows for each trade_date x stock_code.

Before You Run This Example

Parameters

Parameter Required Default Allowed values / shape Meaning
stock_codes yes list of stock codes, e.g. ['000001.XSHE'] Which stocks to query
start_date yes YYYY-MM-DD Inclusive start date
end_date yes YYYY-MM-DD Inclusive end date
fields no None list of column names such as ['open', 'close', 'volume'] Which price columns to return
adjust_type no 'raw' 'raw', 'pre', 'post', 'adj_fwd', 'adj_bwd' Which price adjustment to use
auto_batch no True True / False Whether the client may split oversized requests automatically
batch_symbols no 200 positive integer Symbol shard size when batching is needed
batch_days no 365 positive integer Date-window shard size when batching is needed

Discovery Workflow

If you are not sure which dates, codes, or fields to use, start here first:

import shadow_ingest as si

price_fields = si.list_fields(si.gather_daily_price)
trade_dates = si.list_market_calendar(year=2024)
stock_codes = si.list_universe(date=trade_dates[-1])

print(price_fields)
print(trade_dates[:3])
print(stock_codes[:5])

Parameter Notes

stock_codes

If you are not sure which identifiers are valid on a trading date, use:

import shadow_ingest as si

stock_codes = si.list_universe(date='2024-01-03')
print(stock_codes[:10])

start_date and end_date

If you are not sure which dates are valid trading dates, use:

import shadow_ingest as si

trade_dates = si.list_market_calendar(year=2024)
print(trade_dates[:5])

fields

This is the parameter users most often need help with.

If fields=None, the client requests all available columns from the selected daily price dataset, while still keeping trade_date and stock_code in the result.

To get the documented supported public values, use:

import shadow_ingest as si

print(si.list_fields(si.gather_daily_price))

The documented fields values are:

Field Meaning
open Opening price for the trading day
high Highest traded price during the trading day
low Lowest traded price during the trading day
close Closing price for the trading day
volume Traded share volume for the trading day
total_turnover Total traded value for the trading day
prev_close Previous trading day's close
limit_up Daily upper price limit
limit_down Daily lower price limit
num_trades Number of trades during the day

A typical narrow request is:

fields=['open', 'close', 'volume']

If you are unsure what is currently available in your environment beyond the documented stable set, the safest discovery pattern is:

import shadow_ingest as si

sample_df = si.gather_daily_price(
    stock_codes=['000001.XSHE'],
    start_date='2024-01-02',
    end_date='2024-01-03',
    fields=None,
)

print(sample_df.columns)

For the helper API itself, see list_fields.

adjust_type

  • raw: raw unadjusted prices
  • pre / adj_fwd: forward-adjusted prices
  • post / adj_bwd: backward-adjusted prices

Copy-Paste Example

import shadow_ingest as si

price_df = si.gather_daily_price(
    stock_codes=['000001.XSHE'],
    start_date='2020-01-02',
    end_date='2020-01-10',
    fields=['open', 'close', 'volume'],
    adjust_type='raw',
)

print(price_df.head())
print(price_df.schema)

Example Output

┌────────────┬─────────────┬───────┬───────┬──────────┐
│ trade_date ┆ stock_code  ┆ open  ┆ close ┆ volume   │
│ ---        ┆ ---         ┆ ---   ┆ ---   ┆ ---      │
│ date       ┆ str         ┆ f64   ┆ f64   ┆ f64      │
╞════════════╪═════════════╪═══════╪═══════╪══════════╡
│ 2020-01-02 ┆ 000001.XSHE ┆ 16.65 ┆ 16.87 ┆ 1.53e8   │
│ 2020-01-03 ┆ 000001.XSHE ┆ 16.94 ┆ 17.18 ┆ 1.82e8   │
│ 2020-01-06 ┆ 000001.XSHE ┆ 17.01 ┆ 17.07 ┆ 1.64e8   │
│ 2020-01-07 ┆ 000001.XSHE ┆ 17.13 ┆ 17.15 ┆ 1.43e8   │
│ 2020-01-08 ┆ 000001.XSHE ┆ 17.0  ┆ 16.66 ┆ 1.21e8   │
└────────────┴─────────────┴───────┴───────┴──────────┘

Pandas

price_pdf = price_df.to_pandas()