# オプションスクリーニング
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 1 ページあたりの最大返却件数 フィルタ条件 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 API 呼び出し結果 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 moomoo 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 が受け取るのは内部 stock_id。get_market_snapshot / get_static_info などで
# 事前に取得する必要がある。下記の 54047868453564 は香港テンセント(00700)の stock_id。
req = OptionScreenRequest(market_categories=[OptMarketCategory.HK_STOCK])
req.add_underlying_filter(OptUnderlyingIndicator.STOCK_LIST,
values=[54047868453564]) # 原資産=テンセント
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)
quote_ctx.close()
1
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
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
- Output
code option_name delta volume
0 US.SLV260529C70000 SLV 260529 70.00C 0.52937 45838
1 US.TZA260612C5500 TZA 260612 5.50C 0.37815 40777
2 US.HIVE260717C5000 HIVE 260717 5.00C 0.36626 31104
3 US.NKE260618C45000 NKE 260618 45.00C 0.32579 24046
4 US.SG260618C9500 SG 260618 9.50C 0.39444 19020
1
2
3
4
5
6
2
3
4
5
6
APIレート制限
- 30秒以内にオプションスクリーニング API を最大10回までリクエスト可能です