qmt编程之获取期权数据
qmt更加详细的教程方法,会持续慢慢梳理。
也可找寻博主的历史文章,搜索关键词查看解决方案 !
感谢关注,咨询免费开通量化回测与获取实盘权限,欢迎和博主联系!
获取期权数据
获取指定期权标的对应的期权品种列表
为了获取与指定期权标的相关的期权品种列表,你需要使用此函数操作。根据你的需求,这个过程将需要输入期权标的(如某个公司的股票代码)作为参数,接下来,该函数将返回所有与此期权标的相关的期权品种信息。这样的功能使投资者能够对期权市场有更详尽、全面的掌握,从而做出更科学、合理的投资决策。
方式1:内置python
调用方法
内置python
#encoding:gbk
def init(ContextInfo):
pass
def after_init(ContextInfo):
data=ContextInfo.get_option_undl_data(undl_code_ref)
参数
字段 | 类型 | 说明 |
---|---|---|
undl_code_ref |
string |
期权标的代码 |
- undl_code_ref:期权标的代码,如'510300.SH',传空字符串时获取全部标的数据
返回
提示
- 指定期权标的返回的是 列表类型
- 期权标的为空字符串返回的是 字典类型
示例
#encoding:gbk
def init(ContextInfo):
ContextInfo.etf_code = "510050.SH"
def after_init(ContextInfo):
data=ContextInfo.get_option_undl_data('510300.SH')
print(data)
返回值
['10005347.SHO', '10005348.SHO', '10005349.SHO', '10005350.SHO', '10005351.SHO', '10005352.SHO', '10005353.SHO', '10005354.SHO', '10005355.SHO', '10005356.SHO', '10005357.SHO', '10005358.SHO', '10005359.SHO', '10005360.SHO', '10005361.SHO', '10005362.SHO', '10005363.SHO', '10005364.SHO', '10005387.SHO', '10005388.SHO', '10005391.SHO', '10005392.SHO', '10005467.SHO', '10005468.SHO', '10005783.SHO', '10005784.SHO', '10005785.SHO', '10005786.SHO', '10005787.SHO', '10005788.SHO', '10005789.SHO', '10005790.SHO', '10005791.SHO', '10005792.SHO', '10005793.SHO', '10005794.SHO', '10005795.SHO', '10005796.SHO', '10005797.SHO', '10005798.SHO', '10005799.SHO', '10005800.SHO', '10005867.SHO', '10005868.SHO', '10005875.SHO', '10005876.SHO', '10005897.SHO', '10005898.SHO', '10005931.SHO', '10005932.SHO', '10005933.SHO', '10005934.SHO', '10005935.SHO', '10005936.SHO', '10005937.SHO', '10005938.SHO', '10005939.SHO', '10005940.SHO', '10005941.SHO', '10005942.SHO', '10005943.SHO', '10005944.SHO', '10005945.SHO', '10005946.SHO', '10005947.SHO', '10005948.SHO', '10006007.SHO', '10006008.SHO', '10006019.SHO', '10006020.SHO', '10006021.SHO', '10006022.SHO', '10006023.SHO', '10006024.SHO', '10006043.SHO', '10006044.SHO', '10006045.SHO', '10006046.SHO', '10006047.SHO', '10006048.SHO', '10006049.SHO', '10006050.SHO', '10006051.SHO', '10006052.SHO', '10006053.SHO', '10006054.SHO', '10006055.SHO', '10006056.SHO', '10006057.SHO', '10006058.SHO', '10006059.SHO', '10006060.SHO', '10006117.SHO', '10006118.SHO', '10006135.SHO', '10006136.SHO', '10006137.SHO', '10006138.SHO', '10006139.SHO', '10006140.SHO', '10006141.SHO', '10006142.SHO']
方式2:原生python
调用方法
python
from xtquant import xtdata
xtdata.get_option_undl_data(undl_code_ref)
参数
字段 | 类型 | 说明 |
---|---|---|
undl_code_ref |
string |
期权标的代码 |
- undl_code_ref:期权标的代码,如'510300.SH',传空字符串时获取全部标的数据
返回
提示
- 指定期权标的返回的是 列表类型
- 期权标的为空字符串返回的是 字典类型
示例
from xtquant import xtdata
print(xtdata.get_option_undl_data("510300.SH"))
返回值
['10005347.SHO', '10005348.SHO', '10005349.SHO', '10005350.SHO', '10005351.SHO', '10005352.SHO', '10005353.SHO', '10005354.SHO', '10005355.SHO', '10005356.SHO', '10005357.SHO', '10005358.SHO', '10005359.SHO', '10005360.SHO', '10005361.SHO', '10005362.SHO', '10005363.SHO', '10005364.SHO', '10005387.SHO', '10005388.SHO', '10005391.SHO', '10005392.SHO', '10005467.SHO', '10005468.SHO', '10005783.SHO', '10005784.SHO', '10005785.SHO', '10005786.SHO', '10005787.SHO', '10005788.SHO', '10005789.SHO', '10005790.SHO', '10005791.SHO', '10005792.SHO', '10005793.SHO', '10005794.SHO', '10005795.SHO', '10005796.SHO', '10005797.SHO', '10005798.SHO', '10005799.SHO', '10005800.SHO', '10005867.SHO', '10005868.SHO', '10005875.SHO', '10005876.SHO', '10005897.SHO', '10005898.SHO', '10005931.SHO', '10005932.SHO', '10005933.SHO', '10005934.SHO', '10005935.SHO', '10005936.SHO', '10005937.SHO', '10005938.SHO', '10005939.SHO', '10005940.SHO', '10005941.SHO', '10005942.SHO', '10005943.SHO', '10005944.SHO', '10005945.SHO', '10005946.SHO', '10005947.SHO', '10005948.SHO', '10006007.SHO', '10006008.SHO', '10006019.SHO', '10006020.SHO', '10006021.SHO', '10006022.SHO', '10006023.SHO', '10006024.SHO', '10006043.SHO', '10006044.SHO', '10006045.SHO', '10006046.SHO', '10006047.SHO', '10006048.SHO', '10006049.SHO', '10006050.SHO', '10006051.SHO', '10006052.SHO', '10006053.SHO', '10006054.SHO', '10006055.SHO', '10006056.SHO', '10006057.SHO', '10006058.SHO', '10006059.SHO', '10006060.SHO', '10006117.SHO', '10006118.SHO', '10006135.SHO', '10006136.SHO', '10006137.SHO', '10006138.SHO', '10006139.SHO', '10006140.SHO', '10006141.SHO', '10006142.SHO']