# 篩選期權
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 次篩選期權介面