"""指数及其历史成分(v3 §9/§30:Survivorship-free Universe 的数据基础)。 index_weight:指数在某交易日的成分快照(来自指数权重表,每期含当时成分与权重)。 历史成分语义:as_of 某日的成分 = 该日(<=as_of 最近一期)快照中的股票 —— 禁止用今天的成分回测过去(未来函数/幸存者偏差红线)。 """ from __future__ import annotations from datetime import date from decimal import Decimal from pydantic import BaseModel, Field class IndexWeight(BaseModel): index_code: str = Field(pattern=r"^\d{6}\.(SH|SZ|CSI|CI)$", description="如 000300.SH / 000905.SH") index_name: str | None = None trade_date: date # 该快照对应交易日(成分时点) symbol: str = Field(pattern=r"^\d{6}\.(SH|SZ|BJ)$") weight: Decimal | None = None