Skip to content

get_industry_mapping API

Shadow Ingest / API Reference / Industry
get_industry_mapping(
    stock_codes: list[str],
    *,
    standard: str,
    trade_date,
) -> polars.DataFrame

Returns industry rows for the requested stock_codes under one standard and one trade date.

This API is designed to accept the output of list_universe(...) directly.

Before You Run This Example

Parameters

Parameter Required Default Allowed values / shape Meaning
stock_codes yes list of stock codes such as ["000001.XSHE"] Which stocks to map
standard no "sws" taxonomy name such as sws, citics, citics_2019, gildata Which industry standard to use
trade_date yes YYYY-MM-DD, YYYYMMDD, datetime.date, or another date-like object Which date to evaluate

Returned Columns

Stable result columns:

  • trade_date
  • stock_code
  • stock_name
  • standard
  • first_industry_code
  • first_industry_name
  • second_industry_code
  • second_industry_name
  • third_industry_code
  • third_industry_name

stock_name comes from common_stock.symbol for the same trade_date.

Copy-Paste Example

import shadow_ingest as si

trade_date = "2024-01-03"
stock_codes = si.list_universe(date=trade_date)[:5]
industry_df = si.get_industry_mapping(
    stock_codes=stock_codes,
    trade_date=trade_date,
)

print(industry_df)