跳转至

合约信息

合约详情、代码类型判断、IPO 信息、指数权重、ST 历史等。

合约/证券信息客户端方法集合,对应 /api/instrument/* 端点。

get_batch_instrument_detail(stocks: list[str], iscomplete: bool = False) -> dict

批量获取合约详情信息。

底层调用 xtdata.get_instrument_detail_list(),返回多只股票/期货/期权 的合约基本信息,包括名称、上市日期、到期日、涨跌停价格等。

参数:

名称 类型 描述 默认
stocks list[str]

合约代码列表,如 ["000001.SZ", "IF2312.IF"]

必需
iscomplete bool

是否返回完整信息(True 时包含更多字段)

False

返回:

类型 描述
dict

以合约代码为键的详情字典

get_instrument_type(stock: str) -> str

判断合约类型。

底层调用 xtdata.get_instrument_type(),返回合约所属的品种类型。

参数:

名称 类型 描述 默认
stock str

合约代码,如 "000001.SZ"

必需

返回:

类型 描述
str

合约类型字符串,如 "stock"(股票)、"future"(期货)、

str

"option"(期权)、"index"(指数)、"fund"(基金)等

get_ipo_info(start_time: str = '', end_time: str = '') -> dict

获取 IPO(新股/新债)申购信息。

底层调用 xtdata.get_ipo_info(),返回指定时间范围内的 新股发行和可转债发行信息。

参数:

名称 类型 描述 默认
start_time str

开始时间,格式 "20230101"

''
end_time str

结束时间

''

返回:

类型 描述
dict

IPO 信息字典

get_index_weight(index_code: str) -> dict

获取指数成分股权重。

底层调用 xtdata.get_index_weight(),返回指定指数的全部成分股 及其权重信息。使用前需先调用 download_index_weight() 下载数据。

参数:

名称 类型 描述 默认
index_code str

指数代码,如 "000300.SH"(沪深300)

必需

返回:

类型 描述
dict

以成分股代码为键、权重为值的字典

get_st_history(stock: str) -> dict

获取股票的 ST 历史记录。

底层调用 xtdata.download_his_st_data(),返回股票被标记为 ST(特别处理)、*ST(退市风险警示)的历史记录,包括 被 ST 和摘帽的日期。

参数:

名称 类型 描述 默认
stock str

股票代码,如 "000001.SZ"

必需

返回:

类型 描述
dict

ST 历史记录字典