# 筛选期权
get_option_screen(request)
介绍
期权选股。混合使用标的属性(underlying)与期权属性(option)进行筛选。同一组内不能同时筛选标的属性(underlying)与期权属性(option),SDK 自动按需开新筛选组:默认每条筛选条件 AND 拼接(开新组),同 indicator_type 显式
or_with_previous=True时与上一条件 OR(同组)。参数
参数 类型 说明 request OptionScreenRequest 期权选股请求对象,构造时必传 market_categories OptionScreenRequest 字段:
字段 类型 说明 market_categories list[int] 期权市场品类列表 page_from int 分页起始位置 page_count int 单页最大返回数 筛选条件 builder 方法(默认每次调用自动开新筛选组与之前条件 AND;同 indicator_type 显式
or_with_previous=True时与上一条件 OR 同组。同一组内不能同时筛选标的属性(underlying)与期权属性(option)):方法 说明 add_underlying_filter(indicator_type, values=None, lower=None, upper=None, plate_list=None, parent_plate_id=None, or_with_previous=False) 标的属性筛选 add_option_filter(indicator_type, values=None, lower=None, upper=None, or_with_previous=False) 期权属性筛选 new_filter_group() 手动开始新的筛选组 add_sort(indicator_type, desc=False) 排序 add_option_retrieve(indicator_type) 声明额外要返回的期权字段 add_underlying_retrieve(indicator_type) 声明要返回的标的字段
返回
参数 类型 说明 ret RET_CODE 接口调用结果 data tuple 当 ret == RET_OK,返回 (last_page, all_count, DataFrame) str 当 ret != RET_OK,返回错误描述 返回 DataFrame 字段:
字段 类型 说明 code str 期权代码 option_name str 期权名称 strike_price float 行权价 strike_date str 行权日 option_type int 认购/认沽 exercise_type int 行权方式 expiration_type int 到期类型 in_the_money bool 是否价内 left_day int 剩余天数 price float 期权价格 mid_price float 中间价 bid_price float 买价 ask_price float 卖价 bid_ask_spread float 买卖价差 bid_volume int 买量 ask_volume int 卖量 bid_ask_volume_ratio float 买卖量比 change_ratio float 涨跌幅 volume int 成交量 turnover float 成交额 open_interest int 未平仓合约数(持仓量) open_interest_market_cap float 持仓市值 vol_oi_ratio float 成交量/持仓量 premium float 权利金 implied_volatility float 隐含波动率 history_volatility float 历史波动率 iv_hv_ratio float IV/HV delta float 希腊字母 Delta gamma float 希腊字母 Gamma vega float 希腊字母 Vega theta float 希腊字母 Theta rho float 希腊字母 Rho leverage_ratio float 杠杆比率 effective_gearing float 有效杠杆 itm_probability float 价内概率 buy_to_bep float 买入到盈亏平衡点比率 sell_to_bep float 卖出到盈亏平衡点比率 buy_profit_probability float 买入盈利概率 sell_profit_probability float 卖出盈利概率 intrinsic_value_per float 内在价值百分比 time_value_per float 时间价值百分比 itm_degree float 价内程度 otm_degree float 价外程度 otm_probability float 价外概率 sell_annualized_return float 卖出年化收益率 interval_return float 卖出区间收益率 underlying dict 标的信息(仅当调用 add_underlying_retrieve 后返回)
Example
from futu import (
OpenQuoteContext, RET_OK, OptionScreenRequest,
OptMarketCategory, OptIndicator, OptUnderlyingIndicator,
)
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
# 示例 1:美股标的 IV>30% + 平值附近 CALL
req = OptionScreenRequest(market_categories=[OptMarketCategory.US_STOCK])
req.add_underlying_filter(OptUnderlyingIndicator.IV, lower=0.3) # 标的 IV ≥ 30%(小数)
req.add_option_filter(OptIndicator.OPTION_TYPE, values=[1]) # CALL
req.add_option_filter(OptIndicator.DELTA, lower=0.3, upper=0.7) # Delta 0.3~0.7
req.add_option_filter(OptIndicator.LEFT_DAY, lower=7, upper=60) # 剩余 7~60 天
req.add_sort(OptIndicator.VOLUME, desc=True) # 成交量降序
req.add_option_retrieve(OptIndicator.DELTA)
req.add_option_retrieve(OptIndicator.VOLUME)
req.page_count = 30
ret, data = quote_ctx.get_option_screen(req)
if ret == RET_OK:
last_page, all_count, df = data
print(df[['code', 'option_name', 'delta', 'volume']].head(10))
else:
print('error: ', data)
# 示例 2:港股按指定标的筛选 + 同时取标的信息
# 注意:STOCK_LIST 直接传入证券代码字符串(如 "HK.00700"、"US.AAPL")
req = OptionScreenRequest(market_categories=[OptMarketCategory.HK_STOCK])
req.add_underlying_filter(OptUnderlyingIndicator.STOCK_LIST,
values=["HK.00700"]) # 标的=腾讯
req.add_option_filter(OptIndicator.OPTION_TYPE, values=[1]) # CALL
req.add_option_filter(OptIndicator.OPTION_TYPE, values=[2],
or_with_previous=True) # 与上一条 OR:CALL + PUT
req.add_underlying_retrieve(OptUnderlyingIndicator.IV)
req.add_underlying_retrieve(OptUnderlyingIndicator.MARKET_CAP)
req.add_sort(OptIndicator.OPEN_INTEREST, desc=True) # 持仓量降序
req.page_count = 50
ret, data = quote_ctx.get_option_screen(req)
if ret == RET_OK:
last_page, all_count, df = data
print(df[['code', 'option_name', 'option_type', 'open_interest', 'underlying']].head(10))
else:
print('error: ', data)
quote_ctx.close()
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
- Output
# 示例 1:
code option_name delta volume
0 US.GT260717C7000 GT 260717 7.00C 0.33809 38831
1 US.INTC260717C150000 INTC 260717 150.00C 0.30582 19548
2 US.MU260626C1050000 MU 260626 1050.00C 0.43334 18949
3 US.TSLA260710C400000 TSLA 260710 400.00C 0.58114 16002
4 US.CRWV260717C120000 CRWV 260717 120.00C 0.30415 15932
5 US.COMP260717C9000 COMP 260717 9.00C 0.47409 15645
6 US.SLV260717C65500 SLV 260717 65.50C 0.35809 13291
7 US.TSLA260710C410000 TSLA 260710 410.00C 0.50861 13010
8 US.SPCE260717C5000 SPCE 260717 5.00C 0.41268 12701
9 US.HOOD260717C100000 HOOD 260717 100.00C 0.41248 12572
# 示例 2:
code option_name option_type open_interest underlying
0 HK.TCH260730C610000 腾讯 260730 610.00 购 1 70474 {'stock_id': 54047868453564, 'iv': 0.36337, 'h...
1 HK.TCH260629C500000 腾讯 260629 500.00 购 1 56334 {'stock_id': 54047868453564, 'iv': 0.36406, 'h...
2 HK.TCH260929C550000 腾讯 260929 550.00 购 1 46470 {'stock_id': 54047868453564, 'iv': 0.36406, 'h...
3 HK.TCH260730C520000 腾讯 260730 520.00 购 1 44071 {'stock_id': 54047868453564, 'iv': 0.36406, 'h...
4 HK.TCH260929C650000 腾讯 260929 650.00 购 1 38316 {'stock_id': 54047868453564, 'iv': 0.36406, 'h...
5 HK.TCH260629C530000 腾讯 260629 530.00 购 1 34532 {'stock_id': 54047868453564, 'iv': 0.36406, 'h...
6 HK.TCH260629C540000 腾讯 260629 540.00 购 1 34085 {'stock_id': 54047868453564, 'iv': 0.36406, 'h...
7 HK.TCH270330P230000 腾讯 270330 230.00 沽 2 30586 {'stock_id': 54047868453564, 'iv': 0.36337, 'h...
8 HK.TCH270330C230000 腾讯 270330 230.00 购 1 30000 {'stock_id': 54047868453564, 'iv': 0.36337, 'h...
9 HK.TCH260629C600000 腾讯 260629 600.00 购 1 27394 {'stock_id': 54047868453564, 'iv': 0.36406, 'h...
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
字段逐项示例(按类别)
以下示例均以 US_STOCK 市场为例:先
req = OptionScreenRequest(market_categories=[OptMarketCategory.US_STOCK]), 再叠加每段中的筛选 / 取回 / 排序条件,最后quote_ctx.get_option_screen(req)取(last_page, all_count, df)。 实测的head直接取自返回的 DataFrame;标的属性示例的underlying.<field>列由add_underlying_retrieve(...)展开得到。# 标的属性 OptUnderlyingIndicator
通过
add_underlying_filter(indicator_type, lower, upper, values, ...)传入;IV/HV/IV_RANK 等百分数指标 传小数(30% 传 0.3),并需add_underlying_retrieve(...)才能在underlyingdict 中看到值#
IV(id=203 · interval · OptUnderlyingIndicator) 标的隐含波动率单位:% ;SDK 直传小数(30% 传 0.3)。需 add_underlying_retrieve 才能在 underlying dict 里看到值
req.add_underlying_filter(OptUnderlyingIndicator.IV, lower=0.3) req.add_underlying_retrieve(OptUnderlyingIndicator.IV) req.add_sort(OptIndicator.VOLUME, desc=True)1
2
3实测返回(US_STOCK · all_count=1456207、命中 10 行、head 前 5):
code option_name volume underlying.iv US.NVDA260612C205000 NVDA 260612 205.00C 226041 0.45135 US.NVDA260612P200000 NVDA 260612 200.00P 184565 0.45135 US.NVDA260612C202500 NVDA 260612 202.50C 163991 0.45135 US.NVDA260612C210000 NVDA 260612 210.00C 147236 0.45135 US.NVDA260612C207500 NVDA 260612 207.50C 143944 0.451351
2
3
4
5
6#
HV(id=204 · interval · OptUnderlyingIndicator) 标的历史波动率单位:% ;SDK 直传小数
req.add_underlying_filter(OptUnderlyingIndicator.HV, lower=0.3) req.add_underlying_retrieve(OptUnderlyingIndicator.HV) req.add_sort(OptIndicator.VOLUME, desc=True)1
2
3实测返回(US_STOCK · all_count=1336194、命中 10 行、head 前 5):
code option_name volume underlying.hv US.NVDA260612C205000 NVDA 260612 205.00C 226041 0.46845 US.NVDA260612P200000 NVDA 260612 200.00P 184565 0.46845 US.NVDA260612C202500 NVDA 260612 202.50C 163991 0.46845 US.NVDA260612C210000 NVDA 260612 210.00C 147236 0.46845 US.NVDA260612C207500 NVDA 260612 207.50C 143944 0.468451
2
3
4
5
6#
IV_RANK(id=205 · interval · OptUnderlyingIndicator) 标的 IV 历史排名0~100;衡量当前 IV 在历史中的相对位置
req.add_underlying_filter(OptUnderlyingIndicator.IV_RANK, lower=50.0) req.add_underlying_retrieve(OptUnderlyingIndicator.IV_RANK) req.add_sort(OptIndicator.VOLUME, desc=True)1
2
3实测返回(US_STOCK · all_count=0、命中 0 行):无数据。原因:OpenD 抽样无数据,可降低 lower 阈值
#
MARKET_CAP(id=401 · interval · OptUnderlyingIndicator) 标的总市值单位:元;SDK 直传原始值(百亿写 10_000_000_000)
req.add_underlying_filter(OptUnderlyingIndicator.MARKET_CAP, lower=100_000_000_000.0) req.add_underlying_retrieve(OptUnderlyingIndicator.MARKET_CAP) req.add_sort(OptIndicator.VOLUME, desc=True)1
2
3实测返回(US_STOCK · all_count=357921、命中 10 行、head 前 5):
code option_name volume underlying.market_cap US.NVDA260612C205000 NVDA 260612 205.00C 226041 4957854000000.0 US.NVDA260612P200000 NVDA 260612 200.00P 184565 4957854000000.0 US.NVDA260612C202500 NVDA 260612 202.50C 163991 4957854000000.0 US.NVDA260612C210000 NVDA 260612 210.00C 147236 4957854000000.0 US.NVDA260612C207500 NVDA 260612 207.50C 143944 4957854000000.01
2
3
4
5
6#
STOCK_PRICE(id=402 · interval · OptUnderlyingIndicator) 标的价单位:元;SDK 直传原始价
req.add_underlying_filter(OptUnderlyingIndicator.STOCK_PRICE, lower=50.0, upper=500.0) req.add_underlying_retrieve(OptUnderlyingIndicator.STOCK_PRICE) req.add_sort(OptIndicator.VOLUME, desc=True)1
2
3实测返回(US_STOCK · all_count=1055665、命中 10 行、head 前 5):
code option_name volume underlying.price US.NVDA260612C205000 NVDA 260612 205.00C 226041 204.87 US.NVDA260612P200000 NVDA 260612 200.00P 184565 204.87 US.NVDA260612C202500 NVDA 260612 202.50C 163991 204.87 US.NVDA260612C210000 NVDA 260612 210.00C 147236 204.87 US.NVDA260612C207500 NVDA 260612 207.50C 143944 204.871
2
3
4
5
6# 期权属性 OptIndicator
通过
add_option_filter(indicator_type, lower, upper, values, ...)传入;Greeks(DELTA/GAMMA/THETA/VEGA/RHO)与各类概率(ITM_PROBABILITY 等)传 0~1 小数#
STRIKE_PRICE(id=1001 · interval · OptIndicator) 行权价单位:元;SDK 直传原始价
req.add_option_filter(OptIndicator.STRIKE_PRICE, lower=50.0, upper=100.0) req.add_sort(OptIndicator.VOLUME, desc=True)1
2实测返回(US_STOCK · all_count=400354、命中 10 行、head 前 5):
code option_name strike_price volume US.HYG260717P75000 HYG 260717 75.00P 75.0 72679 US.BAC260618C55000 BAC 260618 55.00C 55.0 55636 US.TQQQ260612P72000 TQQQ 260612 72.00P 72.0 43326 US.IEF260618C95000 IEF 260618 95.00C 95.0 42077 US.HYG260918P75000 HYG 260918 75.00P 75.0 420121
2
3
4
5
6#
LEFT_DAY(id=1002 · interval · OptIndicator) 剩余天数单位:天;整数;近月通常 < 30
req.add_option_filter(OptIndicator.LEFT_DAY, lower=7, upper=60) req.add_sort(OptIndicator.VOLUME, desc=True)1
2实测返回(US_STOCK · all_count=553649、命中 10 行、head 前 5):
code option_name left_day volume US.HYG260717P75000 HYG 260717 75.00P 35 72679 US.POET260717P17000 POET 260717 17.00P 35 60754 US.HYG260717P78000 HYG 260717 78.00P 35 40594 US.HYG260717P79000 HYG 260717 79.00P 35 34919 US.IEF260717P93000 IEF 260717 93.00P 35 348071
2
3
4
5
6#
OPTION_TYPE(id=1003 · values · OptIndicator) 认购/认沽枚举:1=CALL、2=PUT;values 传枚举列表
req.add_option_filter(OptIndicator.OPTION_TYPE, values=[1]) # CALL req.add_sort(OptIndicator.VOLUME, desc=True)1
2实测返回(US_STOCK · all_count=972181、命中 10 行、head 前 5):
code option_name option_type volume US.NVDA260612C205000 NVDA 260612 205.00C 1 226041 US.NVDA260612C202500 NVDA 260612 202.50C 1 163991 US.NVDA260612C210000 NVDA 260612 210.00C 1 147236 US.NVDA260612C207500 NVDA 260612 207.50C 1 143944 US.SPY260612C740000 SPY 260612 740.00C 1 1149061
2
3
4
5
6#
IN_THE_MONEY(id=2001 · values · OptIndicator) 是否价内枚举:1=价内、0=价外
req.add_option_filter(OptIndicator.IN_THE_MONEY, values=[1]) # 仅价内 req.add_sort(OptIndicator.VOLUME, desc=True)1
2实测返回(US_STOCK · all_count=972389、命中 10 行、head 前 5):
code option_name in_the_money volume US.NVDA260612C202500 NVDA 260612 202.50C 1 163991 US.AAPL260612C295000 AAPL 260612 295.00C 1 87879 US.SPY260612C735000 SPY 260612 735.00C 1 77126 US.TSLA260612C390000 TSLA 260612 390.00C 1 70408 US.SPY260612C730000 SPY 260612 730.00C 1 628811
2
3
4
5
6#
PRICE(id=2002 · interval · OptIndicator) 期权价单位:元;SDK 直传原始价
req.add_option_filter(OptIndicator.PRICE, lower=1.0, upper=10.0) req.add_sort(OptIndicator.VOLUME, desc=True)1
2实测返回(US_STOCK · all_count=644732、命中 10 行、head 前 5):
code option_name price volume US.NVDA260612C205000 NVDA 260612 205.00C 2.0 226041 US.NVDA260612C202500 NVDA 260612 202.50C 3.55 163991 US.NVDA260612C207500 NVDA 260612 207.50C 1.04 143944 US.SPY260612C740000 SPY 260612 740.00C 2.97 114906 US.TSLA260612C400000 TSLA 260612 400.00C 6.45 937561
2
3
4
5
6#
VOLUME(id=2011 · interval · OptIndicator) 成交量单位:张
req.add_option_filter(OptIndicator.VOLUME, lower=1000) req.add_sort(OptIndicator.VOLUME, desc=True)1
2实测返回(US_STOCK · all_count=8010、命中 10 行、head 前 5):
code option_name volume US.NVDA260612C205000 NVDA 260612 205.00C 226041 US.NVDA260612P200000 NVDA 260612 200.00P 184565 US.NVDA260612C202500 NVDA 260612 202.50C 163991 US.NVDA260612C210000 NVDA 260612 210.00C 147236 US.NVDA260612C207500 NVDA 260612 207.50C 1439441
2
3
4
5
6#
OPEN_INTEREST(id=2013 · interval · OptIndicator) 未平仓合约数单位:张
req.add_option_filter(OptIndicator.OPEN_INTEREST, lower=1000) req.add_sort(OptIndicator.OPEN_INTEREST, desc=True)1
2实测返回(US_STOCK · all_count=92911、命中 10 行、head 前 5):
code option_name open_interest US.HYG260618P79000 HYG 260618 79.00P 451310 US.BKLN260717P20000 BKLN 260717 20.00P 406177 US.HYG261120C81000 HYG 261120 81.00C 386200 US.HYG260618P77000 HYG 260618 77.00P 332022 US.HYG260618P75000 HYG 260618 75.00P 3240961
2
3
4
5
6#
IMPLIED_VOLATILITY(id=3001 · interval · OptIndicator) 隐含波动率单位:% ;SDK 直传小数(50% 传 0.5)
req.add_option_filter(OptIndicator.IMPLIED_VOLATILITY, lower=0.3) req.add_sort(OptIndicator.VOLUME, desc=True)1
2实测返回(US_STOCK · all_count=1480382、命中 10 行、head 前 5):
code option_name implied_volatility volume US.NVDA260612C205000 NVDA 260612 205.00C 0.70232 226041 US.NVDA260612P200000 NVDA 260612 200.00P 0.77927 184565 US.NVDA260612C202500 NVDA 260612 202.50C 0.72661 163991 US.NVDA260612C210000 NVDA 260612 210.00C 0.76536 147236 US.NVDA260612C207500 NVDA 260612 207.50C 0.72576 1439441
2
3
4
5
6#
DELTA(id=3004 · interval · OptIndicator) 希腊字母 DeltaCALL∈[0,1]、PUT∈[-1,0];SDK 直传小数
req.add_option_filter(OptIndicator.DELTA, lower=0.3, upper=0.7) req.add_sort(OptIndicator.VOLUME, desc=True)1
2实测返回(US_STOCK · all_count=219233、命中 10 行、head 前 5):
code option_name delta volume US.NVDA260612C205000 NVDA 260612 205.00C 0.49538 226041 US.NVDA260612C202500 NVDA 260612 202.50C 0.68114 163991 US.NVDA260612C207500 NVDA 260612 207.50C 0.31335 143944 US.SPY260612C740000 SPY 260612 740.00C 0.45037 114906 US.TSLA260612C400000 TSLA 260612 400.00C 0.48887 937561
2
3
4
5
6#
GAMMA(id=3005 · interval · OptIndicator) 希腊字母 Gamma≥0;SDK 直传小数
req.add_option_filter(OptIndicator.GAMMA, lower=0.01) req.add_sort(OptIndicator.VOLUME, desc=True)1
2实测返回(US_STOCK · all_count=810281、命中 10 行、head 前 5):
code option_name gamma volume US.NVDA260612C205000 NVDA 260612 205.00C 0.07901 226041 US.NVDA260612P200000 NVDA 260612 200.00P 0.0477 184565 US.NVDA260612C202500 NVDA 260612 202.50C 0.06835 163991 US.NVDA260612C210000 NVDA 260612 210.00C 0.0481 147236 US.NVDA260612C207500 NVDA 260612 207.50C 0.06793 1439441
2
3
4
5
6#
THETA(id=3007 · interval · OptIndicator) 希腊字母 Theta一般 ≤0(时间衰减),SDK 直传小数
req.add_option_filter(OptIndicator.THETA, upper=-0.01) req.add_sort(OptIndicator.VOLUME, desc=True)1
2实测返回(US_STOCK · all_count=1238755、命中 10 行、head 前 5):
code option_name theta volume US.NVDA260612C205000 NVDA 260612 205.00C -2.30979 226041 US.NVDA260612P200000 NVDA 260612 200.00P -1.67055 184565 US.NVDA260612C202500 NVDA 260612 202.50C -2.13163 163991 US.NVDA260612C210000 NVDA 260612 210.00C -1.62903 147236 US.NVDA260612C207500 NVDA 260612 207.50C -2.10361 1439441
2
3
4
5
6#
ITM_PROBABILITY(id=3019 · interval · OptIndicator) 价内概率0~1 小数;SDK 直传
req.add_option_filter(OptIndicator.ITM_PROBABILITY, lower=0.3, upper=0.7) req.add_sort(OptIndicator.VOLUME, desc=True)1
2实测返回(US_STOCK · all_count=417899、命中 10 行、head 前 5):
code option_name itm_probability volume US.NVDA260612C205000 NVDA 260612 205.00C 0.48389 226041 US.SPY260612C740000 SPY 260612 740.00C 0.36646 114906 US.TSLA260612C400000 TSLA 260612 400.00C 0.46733 93756 US.AAPL260612C295000 AAPL 260612 295.00C 0.57372 87879 US.SPY260612C735000 SPY 260612 735.00C 0.66411 771261
2
3
4
5
6
接口限制
- 每 30 秒内最多请求 10 次筛选期权接口