# 取得オプション链
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_option_chain(code, index_option_type=IndexOptionType.NORMAL, start=None, end=None, option_type=OptionType.ALL, option_cond_type=OptionCondType.ALL, data_filter=None)
概要
原資産株からオプションチェーンを照会します。このAPIはオプションチェーンの静的情報のみを返します。気配値や板情報などの動的情報を取得するには、このAPIが返す銘柄コードを使用して、必要なタイプを自身で 登録 してください。
パラメータ
パラメータ 型 説明 code str 原資産銘柄コード index_option_type IndexOptionType 指数オプションタイプ 香港株指数オプションのフィルタにのみ有効。正株、ETF、米国株指数オプションではこのパラメータは無視可能start str 開始日期,この日期指満期日 例如:“2017-08-01”end str 終了日付(その日を含む)。この日付は満期日を指します 例:"2017-08-30"option_type OptionType オプションコール/プットタイプ 未指定の場合、デフォルトはすべてoption_cond_type OptionCondType オプションイン/アウトオブザマネータイプ 未指定の場合、デフォルトはすべてdata_filter OptionDataFilter データフィルタ条件 未指定の場合、フィルタなしstart と end の組み合わせは以下の通りです:
Start タイプ End タイプ 説明 str str start と end がそれぞれ指定された日付 None str start 為 end 往前 30 天 str None end 為 start 往后30天 None None start は当日、end は30日後 OptionDataFilter フィールドは以下の通りです
フィールド タイプ 説明 implied_volatility_min float IV(インプライドボラティリティ)フィルタ下限 小数点以下 0 桁まで、超過分は切り捨てられます
このフィールドはパーセントフィールドで、デフォルトでは % を表示しません。20 は実際には 20% に対応しますimplied_volatility_max float IV(インプライドボラティリティ)フィルタ上限 小数点以下 0 桁まで、超過分は切り捨てられます
このフィールドはパーセントフィールドで、デフォルトでは % を表示しません。20 は実際には 20% に対応しますdelta_min float グリークス Delta フィルタ下限 小数点以下 3 桁まで、超過分は切り捨てられますdelta_max float グリークス Delta フィルタ上限 小数点以下 3 桁まで、超過分は切り捨てられますgamma_min float グリークス Gamma フィルタ下限 小数点以下 3 桁まで、超過分は切り捨てられますgamma_max float グリークス Gamma フィルタ上限 小数点以下 3 桁まで、超過分は切り捨てられますvega_min float グリークス Vega フィルタ下限 小数点以下 3 桁まで、超過分は切り捨てられますvega_max float グリークス Vega フィルタ上限 小数点以下 3 桁まで、超過分は切り捨てられますtheta_min float グリークス Theta フィルタ下限 小数点以下 3 桁まで、超過分は切り捨てられますtheta_max float グリークス Theta フィルタ上限 小数点以下 3 桁まで、超過分は切り捨てられますrho_min float グリークス Rho フィルタ下限 小数点以下 3 桁まで、超過分は切り捨てられますrho_max float グリークス Rho フィルタ上限 小数点以下 3 桁まで、超過分は切り捨てられますnet_open_interest_min float ネット未決済建玉数フィルタ下限 小数点以下 0 桁まで、超過分は切り捨てられますnet_open_interest_max float ネット未決済建玉数フィルタ上限 小数点以下 0 桁まで、超過分は切り捨てられますopen_interest_min float 未決済建玉数フィルタ下限 小数点以下 0 桁まで、超過分は切り捨てられますopen_interest_max float 未決済建玉数フィルタ上限 小数点以下 0 桁まで、超過分は切り捨てられますvol_min float 出来高フィルタ下限 小数点以下 0 桁まで、超過分は切り捨てられますvol_max float 出来高フィルタ上限 小数点以下 0 桁まで、超過分は切り捨てられます
戻り値
パラメータ 型 説明 ret RET_CODE API呼び出し結果 data pd.DataFrame ret == RET_OK の場合、オプション链データ str ret != RET_OK の場合、エラーの説明を返す - オプションチェーンデータフォーマットは以下の通りです:
フィールド タイプ 説明 code str 銘柄コード name str 名字 lot_size int 1手あたりの株数。オプションの場合は1枚あたりの株数 指数オプションにはこのフィールドはありませんstock_type SecurityType 株式タイプ option_type OptionType オプションタイプ stock_owner str 原資産株 strike_time str 行使日 フォーマット:yyyy-MM-dd
香港株と A 株市場のデフォルトは北京時間、米国株市場のデフォルトは米国東部時間strike_price float 行使価格 suspension bool かどうか売買停止 True:売買停止中
False:未売買停止stock_id int 株式 ID index_option_type IndexOptionType 指数オプションタイプ expiration_cycle ExpirationCycle 受渡周期 option_standard_type OptionStandardType オプション標準タイプ option_settlement_mode OptionSettlementMode オプション結算方式
- オプションチェーンデータフォーマットは以下の通りです:
Example
from futu import *
import time
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret1, data1 = quote_ctx.get_option_expiration_date(code='HK.00700')
filter1 = OptionDataFilter()
filter1.delta_min = 0
filter1.delta_max = 0.1
if ret1 == RET_OK:
expiration_date_list = data1['strike_time'].values.tolist()
for date in expiration_date_list:
ret2, data2 = quote_ctx.get_option_chain(code='HK.00700', start=date, end=date, data_filter=filter1)
if ret2 == RET_OK:
print(data2)
print(data2['code'][0]) # 最初のレコードの銘柄コードを取得
print(data2['code'].values.tolist()) # list に変換
else:
print('error:', data2)
time.sleep(3)
else:
print('error:', data1)
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
- Output
code name lot_size stock_type option_type stock_owner strike_time strike_price suspension stock_id index_option_type expiration_cycle option_standard_type option_settlement_mode
0 HK.TCH210429C350000 腾讯 210429 350.00 购 100 DRVT CALL HK.00700 2021-04-29 350.0 False 80235167 N/A WEEK STANDARD N/A
1 HK.TCH210429P350000 腾讯 210429 350.00 沽 100 DRVT PUT HK.00700 2021-04-29 350.0 False 80235247 N/A WEEK STANDARD N/A
2 HK.TCH210429C360000 腾讯 210429 360.00 购 100 DRVT CALL HK.00700 2021-04-29 360.0 False 80235163 N/A WEEK STANDARD N/A
3 HK.TCH210429P360000 腾讯 210429 360.00 沽 100 DRVT PUT HK.00700 2021-04-29 360.0 False 80235246 N/A WEEK STANDARD N/A
4 HK.TCH210429C370000 腾讯 210429 370.00 购 100 DRVT CALL HK.00700 2021-04-29 370.0 False 80235165 N/A WEEK STANDARD N/A
5 HK.TCH210429P370000 腾讯 210429 370.00 沽 100 DRVT PUT HK.00700 2021-04-29 370.0 False 80235248 N/A WEEK STANDARD N/A
HK.TCH210429C350000
['HK.TCH210429C350000', 'HK.TCH210429P350000', 'HK.TCH210429C360000', 'HK.TCH210429P360000', 'HK.TCH210429C370000', 'HK.TCH210429P370000']
...
code name lot_size stock_type option_type stock_owner strike_time strike_price suspension stock_id index_option_type expiration_cycle option_standard_type option_settlement_mode
0 HK.TCH220330C490000 腾讯 220330 490.00 购 100 DRVT CALL HK.00700 2022-03-30 490.0 False 80235143 N/A WEEK STANDARD N/A
1 HK.TCH220330P490000 腾讯 220330 490.00 沽 100 DRVT PUT HK.00700 2022-03-30 490.0 False 80235193 N/A WEEK STANDARD N/A
2 HK.TCH220330C500000 腾讯 220330 500.00 购 100 DRVT CALL HK.00700 2022-03-30 500.0 False 80233887 N/A WEEK STANDARD N/A
3 HK.TCH220330P500000 腾讯 220330 500.00 沽 100 DRVT PUT HK.00700 2022-03-30 500.0 False 80233912 N/A WEEK STANDARD N/A
4 HK.TCH220330C510000 腾讯 220330 510.00 购 100 DRVT CALL HK.00700 2022-03-30 510.0 False 80233747 N/A WEEK STANDARD N/A
5 HK.TCH220330P510000 腾讯 220330 510.00 沽 100 DRVT PUT HK.00700 2022-03-30 510.0 False 80233766 N/A WEEK STANDARD N/A
HK.TCH220330C490000
['HK.TCH220330C490000', 'HK.TCH220330P490000', 'HK.TCH220330C500000', 'HK.TCH220330P500000', 'HK.TCH220330C510000', 'HK.TCH220330P510000']
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Qot_GetOptionChain.proto
概要
原資産株からオプションチェーンを照会します。このAPIはオプションチェーンの静的情報のみを返します。気配値や板情報などの動的情報を取得するには、このAPIが返す銘柄コードを使用して、必要なタイプを自身で 登録 してください。
プロトコル ID
3209
パラメータ
enum OptionCondType
{
OptionCondType_Unknow = 0;
OptionCondType_WithIn = 1; //インザマネー
OptionCondType_Outside = 2; //アウトオブザマネー
}
//以下はデータフィールドフィルタ(任意フィールド)。未入力の場合はフィルタなし
message DataFilter
{
optional double impliedVolatilityMin = 1; //IV(インプライドボラティリティ)フィルタ下限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double impliedVolatilityMax = 2; //IV(インプライドボラティリティ)フィルタ上限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double deltaMin = 3; //グリークス Delta フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double deltaMax = 4; //グリークス Delta フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double gammaMin = 5; //グリークス Gamma フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double gammaMax = 6; //グリークス Gamma フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double vegaMin = 7; //グリークス Vega フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double vegaMax = 8; //グリークス Vega フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double thetaMin = 9; //グリークス Theta フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double thetaMax = 10; //グリークス Theta フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double rhoMin = 11; //グリークス Rho フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double rhoMax = 12; //グリークス Rho フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double netOpenInterestMin = 13; //ネット未決済建玉数フィルタ下限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double netOpenInterestMax = 14; //ネット未決済建玉数フィルタ上限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double openInterestMin = 15; //未決済建玉数フィルタ下限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double openInterestMax = 16; //未決済建玉数フィルタ上限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double volMin = 17; //出来高フィルタ下限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double volMax = 18; //出来高フィルタ上限(小数点以下 0 桁まで、超過分は切り捨てられます)
}
message C2S
{
required Qot_Common.Security owner = 1; //オプションの原資産株。現在は香港・米国の正株およびハンセン指数・国企指数・米国指数のみ対応
optional int32 indexOptionType = 6; //Qot_Common.IndexOptionType、指数オプションのタイプ。ハンセン指数・国企指数のみ使用
optional int32 type = 2; //Qot_Common.OptionType、オプションタイプ(任意フィールド)。未指定の場合はすべて返す
optional int32 condition = 3; //OptionCondType、インザマネー/アウトオブザマネー(任意フィールド)。未指定の場合はすべて返す
required string beginTime = 4; //オプション満期日開始時間(フォーマット:yyyy-MM-dd)
required string endTime = 5; //オプション満期日結束時間,時間跨度最大一個月(フォーマット:yyyy-MM-dd)
optional DataFilter dataFilter = 7; //データフィールドフィルタ
}
message Request
{
required C2S c2s = 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
43
44
45
46
47
48
49
50
51
52
53
- 株式構造は~を参照: Security
- オプションタイプ枚举参见 OptionType
- 指数オプション類别枚举参见 IndexOptionType
- 戻り値
message OptionItem
{
optional Qot_Common.SecurityStaticInfo call = 1; //コールオプション。このフィールドは必ずしも存在せず、リクエスト条件により決定
optional Qot_Common.SecurityStaticInfo put = 2; //プットオプション。このフィールドは必ずしも存在せず、リクエスト条件により決定
}
message OptionChain
{
required string strikeTime = 1; //行使日(フォーマット:yyyy-MM-dd)
repeated OptionItem option = 2; //オプション情報
optional double strikeTimestamp = 3; //行使日タイムスタンプ
}
message S2C
{
repeated OptionChain optionChain = 1; //オプション链
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType、戻り値
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
- 株式静態情報構造は~を参照: SecurityStaticInfo
- API 呼び出し結果,構造は~を参照: RetType
プロトコル ID
3209
uint GetOptionChain(QotGetOptionChain.Request req);
virtual void OnReply_GetOptionChain(FTAPI_Conn client, uint nSerialNo, QotGetOptionChain.Response rsp);
概要
原資産株からオプションチェーンを照会します。このAPIはオプションチェーンの静的情報のみを返します。気配値や板情報などの動的情報を取得するには、このAPIが返す銘柄コードを使用して、必要なタイプを自身で 登録 してください。
パラメータ
enum OptionCondType
{
OptionCondType_Unknow = 0;
OptionCondType_WithIn = 1; //インザマネー
OptionCondType_Outside = 2; //アウトオブザマネー
}
//以下はデータフィールドフィルタ(任意フィールド)。未入力の場合はフィルタなし
message DataFilter
{
optional double impliedVolatilityMin = 1; //IV(インプライドボラティリティ)フィルタ下限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double impliedVolatilityMax = 2; //IV(インプライドボラティリティ)フィルタ上限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double deltaMin = 3; //グリークス Delta フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double deltaMax = 4; //グリークス Delta フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double gammaMin = 5; //グリークス Gamma フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double gammaMax = 6; //グリークス Gamma フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double vegaMin = 7; //グリークス Vega フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double vegaMax = 8; //グリークス Vega フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double thetaMin = 9; //グリークス Theta フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double thetaMax = 10; //グリークス Theta フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double rhoMin = 11; //グリークス Rho フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double rhoMax = 12; //グリークス Rho フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double netOpenInterestMin = 13; //ネット未決済建玉数フィルタ下限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double netOpenInterestMax = 14; //ネット未決済建玉数フィルタ上限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double openInterestMin = 15; //未決済建玉数フィルタ下限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double openInterestMax = 16; //未決済建玉数フィルタ上限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double volMin = 17; //出来高フィルタ下限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double volMax = 18; //出来高フィルタ上限(小数点以下 0 桁まで、超過分は切り捨てられます)
}
message C2S
{
required Qot_Common.Security owner = 1; //オプションの原資産株。現在は香港・米国の正株およびハンセン指数・国企指数・米国指数のみ対応
optional int32 indexOptionType = 6; //Qot_Common.IndexOptionType、指数オプションのタイプ。ハンセン指数・国企指数のみ使用
optional int32 type = 2; //Qot_Common.OptionType、オプションタイプ(任意フィールド)。未指定の場合はすべて返す
optional int32 condition = 3; //OptionCondType、インザマネー/アウトオブザマネー(任意フィールド)。未指定の場合はすべて返す
required string beginTime = 4; //オプション満期日開始時間(フォーマット:yyyy-MM-dd)
required string endTime = 5; //オプション満期日結束時間,時間跨度最大一個月(フォーマット:yyyy-MM-dd)
optional DataFilter dataFilter = 7; //データフィールドフィルタ
}
message Request
{
required C2S c2s = 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
43
44
45
46
47
48
49
50
51
52
53
- 株式構造は~を参照: Security
- オプションタイプ枚举参见 OptionType
- 指数オプション類别枚举参见 IndexOptionType
- 戻り値
message OptionItem
{
optional Qot_Common.SecurityStaticInfo call = 1; //コールオプション。このフィールドは必ずしも存在せず、リクエスト条件により決定
optional Qot_Common.SecurityStaticInfo put = 2; //プットオプション。このフィールドは必ずしも存在せず、リクエスト条件により決定
}
message OptionChain
{
required string strikeTime = 1; //行使日(フォーマット:yyyy-MM-dd)
repeated OptionItem option = 2; //オプション情報
optional double strikeTimestamp = 3; //行使日タイムスタンプ
}
message S2C
{
repeated OptionChain optionChain = 1; //オプション链
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType、戻り値
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
- 株式静態情報構造は~を参照: SecurityStaticInfo
- API 呼び出し結果,構造は~を参照: RetType
- Example
public class Program : FTSPI_Qot, FTSPI_Conn {
FTAPI_Qot qot = new FTAPI_Qot();
public Program() {
qot.SetClientInfo("csharp", 1); //クライアント情報の設定
qot.SetConnCallback(this); //接続コールバックの設定
qot.SetQotCallback(this); //取引コールバックの設定
}
public void Start() {
qot.InitConnect("127.0.0.1", (ushort)11111, false);
}
public void OnInitConnect(FTAPI_Conn client, long errCode, String desc)
{
Console.Write("Qot onInitConnect: ret={0} desc={1} connID={2}\n", errCode, desc, client.GetConnectID());
if (errCode != 0)
return;
QotCommon.Security sec = QotCommon.Security.CreateBuilder()
.SetMarket((int)QotCommon.QotMarket.QotMarket_HK_Security)
.SetCode("00700")
.Build();
QotGetOptionChain.C2S c2s = QotGetOptionChain.C2S.CreateBuilder()
.SetOwner(sec)
.SetBeginTime("2020-11-01")
.SetEndTime("2020-12-01")
.Build();
QotGetOptionChain.Request req = QotGetOptionChain.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetOptionChain(req);
Console.Write("Send QotGetOptionChain: {0}\n", seqNo);
}
public void OnDisconnect(FTAPI_Conn client, long errCode) {
Console.Write("Qot onDisConnect: {0}\n", errCode);
}
public void OnReply_GetOptionChain(FTAPI_Conn client, uint nSerialNo, QotGetOptionChain.Response rsp)
{
Console.Write("Reply: QotGetOptionChain: {0}\n", nSerialNo);
Console.Write("strikeTime: {0}, name: {1} \n",
rsp.S2C.OptionChainList[0].StrikeTime,
rsp.S2C.OptionChainList[0].OptionList[0].Call.Basic.Name);
}
public static void Main(String[] args) {
FTAPI.Init();
Program qot = new Program();
qot.Start();
while (true)
Thread.Sleep(1000 * 600);
}
}
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
47
48
49
50
51
52
53
54
55
56
57
- Output
Qot onInitConnect: ret=0 desc= connID=6825705573658441031
Send QotGetOptionChain: 3
Reply: QotGetOptionChain: 3
strikeTime: 2021-07-29, name: 腾讯 210729 400.00 购
2
3
4
int getOptionChain(QotGetOptionChain.Request req);
void onReply_GetOptionChain(FTAPI_Conn client, int nSerialNo, QotGetOptionChain.Response rsp);
概要
原資産株からオプションチェーンを照会します。このAPIはオプションチェーンの静的情報のみを返します。気配値や板情報などの動的情報を取得するには、このAPIが返す銘柄コードを使用して、必要なタイプを自身で 登録 してください。
パラメータ
enum OptionCondType
{
OptionCondType_Unknow = 0;
OptionCondType_WithIn = 1; //インザマネー
OptionCondType_Outside = 2; //アウトオブザマネー
}
//以下はデータフィールドフィルタ(任意フィールド)。未入力の場合はフィルタなし
message DataFilter
{
optional double impliedVolatilityMin = 1; //IV(インプライドボラティリティ)フィルタ下限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double impliedVolatilityMax = 2; //IV(インプライドボラティリティ)フィルタ上限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double deltaMin = 3; //グリークス Delta フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double deltaMax = 4; //グリークス Delta フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double gammaMin = 5; //グリークス Gamma フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double gammaMax = 6; //グリークス Gamma フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double vegaMin = 7; //グリークス Vega フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double vegaMax = 8; //グリークス Vega フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double thetaMin = 9; //グリークス Theta フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double thetaMax = 10; //グリークス Theta フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double rhoMin = 11; //グリークス Rho フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double rhoMax = 12; //グリークス Rho フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double netOpenInterestMin = 13; //ネット未決済建玉数フィルタ下限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double netOpenInterestMax = 14; //ネット未決済建玉数フィルタ上限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double openInterestMin = 15; //未決済建玉数フィルタ下限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double openInterestMax = 16; //未決済建玉数フィルタ上限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double volMin = 17; //出来高フィルタ下限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double volMax = 18; //出来高フィルタ上限(小数点以下 0 桁まで、超過分は切り捨てられます)
}
message C2S
{
required Qot_Common.Security owner = 1; //オプションの原資産株。現在は香港・米国の正株およびハンセン指数・国企指数・米国指数のみ対応
optional int32 indexOptionType = 6; //Qot_Common.IndexOptionType、指数オプションのタイプ。ハンセン指数・国企指数のみ使用
optional int32 type = 2; //Qot_Common.OptionType、オプションタイプ(任意フィールド)。未指定の場合はすべて返す
optional int32 condition = 3; //OptionCondType、インザマネー/アウトオブザマネー(任意フィールド)。未指定の場合はすべて返す
required string beginTime = 4; //オプション満期日開始時間(フォーマット:yyyy-MM-dd)
required string endTime = 5; //オプション満期日結束時間,時間跨度最大一個月(フォーマット:yyyy-MM-dd)
optional DataFilter dataFilter = 7; //データフィールドフィルタ
}
message Request
{
required C2S c2s = 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
43
44
45
46
47
48
49
50
51
52
53
- 株式構造は~を参照: Security
- オプションタイプ枚举参见 OptionType
- 指数オプション類别枚举参见 IndexOptionType
- 戻り値
message OptionItem
{
optional Qot_Common.SecurityStaticInfo call = 1; //コールオプション。このフィールドは必ずしも存在せず、リクエスト条件により決定
optional Qot_Common.SecurityStaticInfo put = 2; //プットオプション。このフィールドは必ずしも存在せず、リクエスト条件により決定
}
message OptionChain
{
required string strikeTime = 1; //行使日(フォーマット:yyyy-MM-dd)
repeated OptionItem option = 2; //オプション情報
optional double strikeTimestamp = 3; //行使日タイムスタンプ
}
message S2C
{
repeated OptionChain optionChain = 1; //オプション链
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType、戻り値
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
- 株式静態情報構造は~を参照: SecurityStaticInfo
- API 呼び出し結果,構造は~を参照: RetType
- Example
public class QotDemo implements FTSPI_Qot, FTSPI_Conn {
FTAPI_Conn_Qot qot = new FTAPI_Conn_Qot();
public QotDemo() {
qot.setClientInfo("javaclient", 1); //クライアント情報の設定
qot.setConnSpi(this); //接続コールバックの設定
qot.setQotSpi(this); //取引コールバックの設定
}
public void start() {
qot.initConnect("127.0.0.1", (short)11111, false);
}
@Override
public void onInitConnect(FTAPI_Conn client, long errCode, String desc)
{
System.out.printf("Qot onInitConnect: ret=%b desc=%s connID=%d\n", errCode, desc, client.getConnectID());
if (errCode != 0)
return;
QotCommon.Security sec = QotCommon.Security.newBuilder()
.setMarket(QotCommon.QotMarket.QotMarket_HK_Security_VALUE)
.setCode("00700")
.build();
QotGetOptionChain.C2S c2s = QotGetOptionChain.C2S.newBuilder()
.setOwner(sec)
.setBeginTime("2021-06-01")
.setEndTime("2021-07-01")
.build();
QotGetOptionChain.Request req = QotGetOptionChain.Request.newBuilder().setC2S(c2s).build();
int seqNo = qot.getOptionChain(req);
System.out.printf("Send QotGetOptionChain: %d\n", seqNo);
}
@Override
public void onDisconnect(FTAPI_Conn client, long errCode) {
System.out.printf("Qot onDisConnect: %d\n", errCode);
}
@Override
public void onReply_GetOptionChain(FTAPI_Conn client, int nSerialNo, QotGetOptionChain.Response rsp) {
if (rsp.getRetType() != 0) {
System.out.printf("QotGetOptionChain failed: %s\n", rsp.getRetMsg());
}
else {
try {
String json = JsonFormat.printer().print(rsp);
System.out.printf("Receive QotGetOptionChain: %s\n", json);
} catch (InvalidProtocolBufferException e) {
e.printStackTrace();
}
}
}
public static void main(String[] args) {
FTAPI.init();
QotDemo qot = new QotDemo();
qot.start();
while (true) {
try {
Thread.sleep(1000 * 600);
} catch (InterruptedException exc) {
}
}
}
}
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
- Output
Send QotGetOptionChain: 2
Receive QotGetOptionChain: {
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"optionChain": [{
"strikeTime": "2021-06-29",
"option": [{
"call": {
"basic": {
"security": {
"market": 1,
"code": "TCH210629C295000"
},
"id": "80143386",
"lotSize": 100,
"secType": 8,
"name": "腾讯 210629 295.00 购",
"listTime": "",
"delisting": false
},
"optionExData": {
"type": 1,
"owner": {
"market": 1,
"code": "00700"
},
"strikeTime": "2021-06-29",
"strikePrice": 295.0,
"suspend": false,
"market": "",
"strikeTimestamp": 1.624896E9,
"expirationCycle": 1,
"optionStandardType": 1,
"optionSettlementMode": 2,
}
},
"put": {
"basic": {
"security": {
"market": 1,
"code": "TCH210629P295000"
},
"id": "80143074",
"lotSize": 100,
"secType": 8,
"name": "腾讯 210629 295.00 沽",
"listTime": "",
"delisting": false
},
"optionExData": {
"type": 2,
"owner": {
"market": 1,
"code": "00700"
},
"strikeTime": "2021-06-29",
"strikePrice": 295.0,
"suspend": false,
"market": "",
"strikeTimestamp": 1.624896E9,
"expirationCycle": 1,
"optionStandardType": 1,
"optionSettlementMode": 2,
}
}
}, ... {
"call": {
"basic": {
"security": {
"market": 1,
"code": "TCH210629C1050000"
},
"id": "80223489",
"lotSize": 100,
"secType": 8,
"name": "腾讯 210629 1050.00 购",
"listTime": "",
"delisting": false
},
"optionExData": {
"type": 1,
"owner": {
"market": 1,
"code": "00700"
},
"strikeTime": "2021-06-29",
"strikePrice": 1050.0,
"suspend": false,
"market": "",
"strikeTimestamp": 1.624896E9,
"expirationCycle": 1,
"optionStandardType": 1,
"optionSettlementMode": 2,
}
},
"put": {
"basic": {
"security": {
"market": 1,
"code": "TCH210629P1050000"
},
"id": "80223488",
"lotSize": 100,
"secType": 8,
"name": "腾讯 210629 1050.00 沽",
"listTime": "",
"delisting": false
},
"optionExData": {
"type": 2,
"owner": {
"market": 1,
"code": "00700"
},
"strikeTime": "2021-06-29",
"strikePrice": 1050.0,
"suspend": false,
"market": "",
"strikeTimestamp": 1.624896E9,
"expirationCycle": 1,
"optionStandardType": 1,
"optionSettlementMode": 2,
}
}
}],
"strikeTimestamp": 1.624896E9
}]
}
}
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
Futu::u32_t GetOptionChain(const Qot_GetOptionChain::Request &stReq);
virtual void OnReply_GetOptionChain(Futu::u32_t nSerialNo, const Qot_GetOptionChain::Response &stRsp) = 0;
概要
原資産株からオプションチェーンを照会します。このAPIはオプションチェーンの静的情報のみを返します。気配値や板情報などの動的情報を取得するには、このAPIが返す銘柄コードを使用して、必要なタイプを自身で 登録 してください。
パラメータ
enum OptionCondType
{
OptionCondType_Unknow = 0;
OptionCondType_WithIn = 1; //インザマネー
OptionCondType_Outside = 2; //アウトオブザマネー
}
//以下はデータフィールドフィルタ(任意フィールド)。未入力の場合はフィルタなし
message DataFilter
{
optional double impliedVolatilityMin = 1; //IV(インプライドボラティリティ)フィルタ下限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double impliedVolatilityMax = 2; //IV(インプライドボラティリティ)フィルタ上限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double deltaMin = 3; //グリークス Delta フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double deltaMax = 4; //グリークス Delta フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double gammaMin = 5; //グリークス Gamma フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double gammaMax = 6; //グリークス Gamma フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double vegaMin = 7; //グリークス Vega フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double vegaMax = 8; //グリークス Vega フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double thetaMin = 9; //グリークス Theta フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double thetaMax = 10; //グリークス Theta フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double rhoMin = 11; //グリークス Rho フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double rhoMax = 12; //グリークス Rho フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double netOpenInterestMin = 13; //ネット未決済建玉数フィルタ下限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double netOpenInterestMax = 14; //ネット未決済建玉数フィルタ上限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double openInterestMin = 15; //未決済建玉数フィルタ下限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double openInterestMax = 16; //未決済建玉数フィルタ上限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double volMin = 17; //出来高フィルタ下限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double volMax = 18; //出来高フィルタ上限(小数点以下 0 桁まで、超過分は切り捨てられます)
}
message C2S
{
required Qot_Common.Security owner = 1; //オプションの原資産株。現在は香港・米国の正株およびハンセン指数・国企指数・米国指数のみ対応
optional int32 indexOptionType = 6; //Qot_Common.IndexOptionType、指数オプションのタイプ。ハンセン指数・国企指数のみ使用
optional int32 type = 2; //Qot_Common.OptionType、オプションタイプ(任意フィールド)。未指定の場合はすべて返す
optional int32 condition = 3; //OptionCondType、インザマネー/アウトオブザマネー(任意フィールド)。未指定の場合はすべて返す
required string beginTime = 4; //オプション満期日開始時間(フォーマット:yyyy-MM-dd)
required string endTime = 5; //オプション満期日結束時間,時間跨度最大一個月(フォーマット:yyyy-MM-dd)
optional DataFilter dataFilter = 7; //データフィールドフィルタ
}
message Request
{
required C2S c2s = 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
43
44
45
46
47
48
49
50
51
52
53
- 株式構造は~を参照: Security
- オプションタイプ枚举参见 OptionType
- 指数オプション類别枚举参见 IndexOptionType
- 戻り値
message OptionItem
{
optional Qot_Common.SecurityStaticInfo call = 1; //コールオプション。このフィールドは必ずしも存在せず、リクエスト条件により決定
optional Qot_Common.SecurityStaticInfo put = 2; //プットオプション。このフィールドは必ずしも存在せず、リクエスト条件により決定
}
message OptionChain
{
required string strikeTime = 1; //行使日(フォーマット:yyyy-MM-dd)
repeated OptionItem option = 2; //オプション情報
optional double strikeTimestamp = 3; //行使日タイムスタンプ
}
message S2C
{
repeated OptionChain optionChain = 1; //オプション链
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType、戻り値
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
- 株式静態情報構造は~を参照: SecurityStaticInfo
- API 呼び出し結果,構造は~を参照: RetType
- Example
class Program : public FTSPI_Qot, public FTSPI_Trd, public FTSPI_Conn
{
public:
Program() {
m_pQotApi = FTAPI::CreateQotApi();
m_pQotApi->RegisterQotSpi(this);
m_pQotApi->RegisterConnSpi(this);
}
~Program() {
if (m_pQotApi != nullptr)
{
m_pQotApi->UnregisterQotSpi();
m_pQotApi->UnregisterConnSpi();
FTAPI::ReleaseQotApi(m_pQotApi);
m_pQotApi = nullptr;
}
}
void Start() {
m_pQotApi->InitConnect("127.0.0.1", 11111, false);
}
virtual void OnInitConnect(FTAPI_Conn* pConn, Futu::i64_t nErrCode, const char* strDesc) {
cout << "connect" << endl;
// パケット生成
Qot_GetOptionChain::Request req;
Qot_GetOptionChain::C2S *c2s = req.mutable_c2s();
Qot_Common::Security *sec = c2s->mutable_owner();
sec->set_code("00700");
sec->set_market(Qot_Common::QotMarket::QotMarket_HK_Security);
c2s->set_begintime("2021-06-07");
c2s->set_endtime("2021-07-01");
m_GetOptionChainSerialNo = m_pQotApi->GetOptionChain(req);
cout << "Request GetOptionChain SerialNo: " << m_GetOptionChainSerialNo << endl;
}
virtual void OnReply_GetOptionChain(Futu::u32_t nSerialNo, const Qot_GetOptionChain::Response &stRsp){
if(nSerialNo == m_GetOptionChainSerialNo)
{
cout << "OnReply_GetOptionChain SerialNo: " << nSerialNo << endl;
// 内部構造を解析して出力
// ProtoBufToBodyData と UTF8ToLocal 関数の定義は Sample の tool.h ファイルを参照
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
}
protected:
FTAPI_Qot *m_pQotApi;
Futu::u32_t m_GetOptionChainSerialNo;
};
int32_t main(int32_t argc, char** argv)
{
FTAPI::Init();
{
Program program;
program.Start();
getchar();
}
protobuf::ShutdownProtobufLibrary();
FTAPI::UnInit();
return 0;
}
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
- Output
connect
Request GetOptionChain SerialNo: 4
OnReply_GetOptionChain SerialNo: 4
{
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"optionChain": [
{
"strikeTime": "2021-06-29",
"option": [
{
"call": {
"basic": {
"security": {
"market": 1,
"code": "TCH210629C295000"
},
"id": "80143386",
"lotSize": 100,
"secType": 8,
"name": "腾讯 210629 295.00 购",
"listTime": "",
"delisting": false
},
"optionExData": {
"type": 1,
"owner": {
"market": 1,
"code": "00700"
},
"strikeTime": "2021-06-29",
"strikePrice": 295,
"suspend": false,
"market": "",
"strikeTimestamp": 1624896000,
"expirationCycle": 1,
"optionStandardType": 1,
"optionSettlementMode": 2,
}
},
"put": {
"basic": {
"security": {
"market": 1,
"code": "TCH210629P295000"
},
"id": "80143074",
"lotSize": 100,
"secType": 8,
"name": "腾讯 210629 295.00 沽",
"listTime": "",
"delisting": false
},
"optionExData": {
"type": 2,
"owner": {
"market": 1,
"code": "00700"
},
"strikeTime": "2021-06-29",
"strikePrice": 295,
"suspend": false,
"market": "",
"strikeTimestamp": 1624896000,
"expirationCycle": 1,
"optionStandardType": 1,
"optionSettlementMode": 2,
}
}
},
...
{
"call": {
"basic": {
"security": {
"market": 1,
"code": "TCH210629C1050000"
},
"id": "80223489",
"lotSize": 100,
"secType": 8,
"name": "腾讯 210629 1050.00 购",
"listTime": "",
"delisting": false
},
"optionExData": {
"type": 1,
"owner": {
"market": 1,
"code": "00700"
},
"strikeTime": "2021-06-29",
"strikePrice": 1050,
"suspend": false,
"market": "",
"strikeTimestamp": 1624896000,
"expirationCycle": 1,
"optionStandardType": 1,
"optionSettlementMode": 2,
}
},
"put": {
"basic": {
"security": {
"market": 1,
"code": "TCH210629P1050000"
},
"id": "80223488",
"lotSize": 100,
"secType": 8,
"name": "腾讯 210629 1050.00 沽",
"listTime": "",
"delisting": false
},
"optionExData": {
"type": 2,
"owner": {
"market": 1,
"code": "00700"
},
"strikeTime": "2021-06-29",
"strikePrice": 1050,
"suspend": false,
"market": "",
"strikeTimestamp": 1624896000,
"expirationCycle": 1,
"optionStandardType": 1,
"optionSettlementMode": 2,
}
}
}
],
"strikeTimestamp": 1624896000
}
]
}
}
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
GetOptionChain(req);
概要
原資産株からオプションチェーンを照会します。このAPIはオプションチェーンの静的情報のみを返します。気配値や板情報などの動的情報を取得するには、このAPIが返す銘柄コードを使用して、必要なタイプを自身で 登録 してください。
パラメータ
enum OptionCondType
{
OptionCondType_Unknow = 0;
OptionCondType_WithIn = 1; //インザマネー
OptionCondType_Outside = 2; //アウトオブザマネー
}
//以下はデータフィールドフィルタ(任意フィールド)。未入力の場合はフィルタなし
message DataFilter
{
optional double impliedVolatilityMin = 1; //IV(インプライドボラティリティ)フィルタ下限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double impliedVolatilityMax = 2; //IV(インプライドボラティリティ)フィルタ上限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double deltaMin = 3; //グリークス Delta フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double deltaMax = 4; //グリークス Delta フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double gammaMin = 5; //グリークス Gamma フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double gammaMax = 6; //グリークス Gamma フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double vegaMin = 7; //グリークス Vega フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double vegaMax = 8; //グリークス Vega フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double thetaMin = 9; //グリークス Theta フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double thetaMax = 10; //グリークス Theta フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double rhoMin = 11; //グリークス Rho フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double rhoMax = 12; //グリークス Rho フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double netOpenInterestMin = 13; //ネット未決済建玉数フィルタ下限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double netOpenInterestMax = 14; //ネット未決済建玉数フィルタ上限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double openInterestMin = 15; //未決済建玉数フィルタ下限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double openInterestMax = 16; //未決済建玉数フィルタ上限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double volMin = 17; //出来高フィルタ下限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double volMax = 18; //出来高フィルタ上限(小数点以下 0 桁まで、超過分は切り捨てられます)
}
message C2S
{
required Qot_Common.Security owner = 1; //オプションの原資産株。現在は香港・米国の正株およびハンセン指数・国企指数・米国指数のみ対応
optional int32 indexOptionType = 6; //Qot_Common.IndexOptionType、指数オプションのタイプ。ハンセン指数・国企指数のみ使用
optional int32 type = 2; //Qot_Common.OptionType、オプションタイプ(任意フィールド)。未指定の場合はすべて返す
optional int32 condition = 3; //OptionCondType、インザマネー/アウトオブザマネー(任意フィールド)。未指定の場合はすべて返す
required string beginTime = 4; //オプション満期日開始時間(フォーマット:yyyy-MM-dd)
required string endTime = 5; //オプション満期日結束時間,時間跨度最大一個月(フォーマット:yyyy-MM-dd)
optional DataFilter dataFilter = 7; //データフィールドフィルタ
}
message Request
{
required C2S c2s = 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
43
44
45
46
47
48
49
50
51
52
53
- 株式構造は~を参照: Security
- オプションタイプ枚举参见 OptionType
- 指数オプション類别枚举参见 IndexOptionType
- 戻り値
message OptionItem
{
optional Qot_Common.SecurityStaticInfo call = 1; //コールオプション。このフィールドは必ずしも存在せず、リクエスト条件により決定
optional Qot_Common.SecurityStaticInfo put = 2; //プットオプション。このフィールドは必ずしも存在せず、リクエスト条件により決定
}
message OptionChain
{
required string strikeTime = 1; //行使日(フォーマット:yyyy-MM-dd)
repeated OptionItem option = 2; //オプション情報
optional double strikeTimestamp = 3; //行使日タイムスタンプ
}
message S2C
{
repeated OptionChain optionChain = 1; //オプション链
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType、戻り値
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
- 株式静態情報構造は~を参照: SecurityStaticInfo
- API 呼び出し結果,構造は~を参照: RetType
- Example
import ftWebsocket from "futu-api";
import { ftCmdID } from "futu-api";
import { Common, Qot_Common } from "futu-api/proto";
import beautify from "js-beautify";
function QotGetOptionChain(){
const { RetType } = Common
const { QotMarket } = Qot_Common
let [addr, port, enable_ssl, key] = ["127.0.0.1", 33333, false, '7522027ccf5a06b1'];
let websocket = new ftWebsocket();
websocket.onlogin = (ret, msg)=>{
if (ret) { // ログイン成功
const req = {
c2s: {
owner:{
market: QotMarket.QotMarket_HK_Security,
code: "00700",
},
beginTime: "2021-09-01",
endTime: "2021-09-30",
},
};
websocket.GetOptionChain(req)
.then((res) => {
let { errCode, retMsg, retType,s2c } = res
console.log("OptionChain: errCode %d, retMsg %s, retType %d", errCode, retMsg, retType);
if(retType == RetType.RetType_Succeed){
let data = beautify(JSON.stringify(s2c), {
indent_size: 2,
space_in_empty_paren: true,
});
console.log(data);
}
})
.catch((error) => {
console.log("error:", error);
});
} else {
console.log("error", msg);
}
};
websocket.start(addr, port, enable_ssl, key);
//相場接続をクローズ。使用後は接続をクローズしてください。不要なリソース占有を防ぎます
//OpenD は最大 128 接続に制限されています
//1 ページまたは 1 プロジェクトで 1 接続を維持することも可能。ここではサンプルとしてリクエストごとに 1 接続を作成
setTimeout(()=>{
websocket.stop();
console.log("stop");
}, 5000); // 5 秒後に切断
}
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
47
48
49
50
51
52
53
54
55
- Output
OptionChain: errCode 0, retMsg , retType 0
{
"optionChain": [{
"strikeTime": "2021-09-29",
"option": [{
"call": {
"basic": {
"security": {
"market": 1,
"code": "TCH210929C300000"
},
"id": "80287116",
"lotSize": 100,
"secType": 8,
"name": "腾讯 210929 300.00 购",
"listTime": "",
"delisting": false
},
"optionExData": {
"type": 1,
"owner": {
"market": 1,
"code": "00700"
},
"strikeTime": "2021-09-29",
"strikePrice": 300,
"suspend": false,
"market": "",
"strikeTimestamp": 1632844800,
"expirationCycle": 1,
"optionStandardType": 1,
"optionSettlementMode": 2,
}
},
"put": {
"basic": {
"security": {
"market": 1,
"code": "TCH210929P300000"
},
"id": "80287124",
"lotSize": 100,
"secType": 8,
"name": "腾讯 210929 300.00 沽",
"listTime": "",
"delisting": false
},
"optionExData": {
"type": 2,
"owner": {
"market": 1,
"code": "00700"
},
"strikeTime": "2021-09-29",
"strikePrice": 300,
"suspend": false,
"market": "",
"strikeTimestamp": 1632844800,
"expirationCycle": 1,
"optionStandardType": 1,
"optionSettlementMode": 2,
}
}
}, ..., {
"call": {
"basic": {
"security": {
"market": 1,
"code": "TCH210929C950000"
},
"id": "80215136",
"lotSize": 100,
"secType": 8,
"name": "腾讯 210929 950.00 购",
"listTime": "",
"delisting": false
},
"optionExData": {
"type": 1,
"owner": {
"market": 1,
"code": "00700"
},
"strikeTime": "2021-09-29",
"strikePrice": 950,
"suspend": false,
"market": "",
"strikeTimestamp": 1632844800,
"expirationCycle": 1,
"optionStandardType": 1,
"optionSettlementMode": 2,
}
},
"put": {
"basic": {
"security": {
"market": 1,
"code": "TCH210929P950000"
},
"id": "80215157",
"lotSize": 100,
"secType": 8,
"name": "腾讯 210929 950.00 沽",
"listTime": "",
"delisting": false
},
"optionExData": {
"type": 2,
"owner": {
"market": 1,
"code": "00700"
},
"strikeTime": "2021-09-29",
"strikePrice": 950,
"suspend": false,
"market": "",
"strikeTimestamp": 1632844800,
"expirationCycle": 1,
"optionStandardType": 1,
"optionSettlementMode": 2,
}
}
}],
"strikeTimestamp": 1632844800
}]
}
stop
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
APIレート制限
- 30 秒以内に最大 10 回オプション链API
- 指定可能な時間範囲の上限は 30 日です
ご注意
- このAPIは期限切れのオプションチェーンの照会に対応していません。終了日付 パラメータには本日または将来の日付を入力してください
- Open interest (OI) データは毎日更新されます。更新タイミングは取引所により異なります。米国株オプションはプレマーケット時間帯に更新され、香港株オプションはアフターマーケットに更新されます。
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_option_chain(code, index_option_type=IndexOptionType.NORMAL, start=None, end=None, option_type=OptionType.ALL, option_cond_type=OptionCondType.ALL, data_filter=None)
概要
原資産株からオプションチェーンを照会します。このAPIはオプションチェーンの静的情報のみを返します。気配値や板情報などの動的情報を取得するには、このAPIが返す銘柄コードを使用して、必要なタイプを自身で 登録 してください。
パラメータ
パラメータ 型 説明 code str 原資産銘柄コード index_option_type IndexOptionType 指数オプションタイプ 香港株指数オプションのフィルタにのみ有効。正株、ETF、米国株指数オプションではこのパラメータは無視可能start str 開始日期,この日期指満期日 例如:“2017-08-01”end str 終了日付(その日を含む)。この日付は満期日を指します 例:"2017-08-30"option_type OptionType オプションコール/プットタイプ 未指定の場合、デフォルトはすべてoption_cond_type OptionCondType オプションイン/アウトオブザマネータイプ 未指定の場合、デフォルトはすべてdata_filter OptionDataFilter データフィルタ条件 未指定の場合、フィルタなしstart と end の組み合わせは以下の通りです:
Start タイプ End タイプ 説明 str str start と end がそれぞれ指定された日付 None str start 為 end 往前 30 天 str None end 為 start 往后30天 None None start は当日、end は30日後 OptionDataFilter フィールドは以下の通りです
フィールド タイプ 説明 implied_volatility_min float IV(インプライドボラティリティ)フィルタ下限 小数点以下 0 桁まで、超過分は切り捨てられます
このフィールドはパーセントフィールドで、デフォルトでは % を表示しません。20 は実際には 20% に対応しますimplied_volatility_max float IV(インプライドボラティリティ)フィルタ上限 小数点以下 0 桁まで、超過分は切り捨てられます
このフィールドはパーセントフィールドで、デフォルトでは % を表示しません。20 は実際には 20% に対応しますdelta_min float グリークス Delta フィルタ下限 小数点以下 3 桁まで、超過分は切り捨てられますdelta_max float グリークス Delta フィルタ上限 小数点以下 3 桁まで、超過分は切り捨てられますgamma_min float グリークス Gamma フィルタ下限 小数点以下 3 桁まで、超過分は切り捨てられますgamma_max float グリークス Gamma フィルタ上限 小数点以下 3 桁まで、超過分は切り捨てられますvega_min float グリークス Vega フィルタ下限 小数点以下 3 桁まで、超過分は切り捨てられますvega_max float グリークス Vega フィルタ上限 小数点以下 3 桁まで、超過分は切り捨てられますtheta_min float グリークス Theta フィルタ下限 小数点以下 3 桁まで、超過分は切り捨てられますtheta_max float グリークス Theta フィルタ上限 小数点以下 3 桁まで、超過分は切り捨てられますrho_min float グリークス Rho フィルタ下限 小数点以下 3 桁まで、超過分は切り捨てられますrho_max float グリークス Rho フィルタ上限 小数点以下 3 桁まで、超過分は切り捨てられますnet_open_interest_min float ネット未決済建玉数フィルタ下限 小数点以下 0 桁まで、超過分は切り捨てられますnet_open_interest_max float ネット未決済建玉数フィルタ上限 小数点以下 0 桁まで、超過分は切り捨てられますopen_interest_min float 未決済建玉数フィルタ下限 小数点以下 0 桁まで、超過分は切り捨てられますopen_interest_max float 未決済建玉数フィルタ上限 小数点以下 0 桁まで、超過分は切り捨てられますvol_min float 出来高フィルタ下限 小数点以下 0 桁まで、超過分は切り捨てられますvol_max float 出来高フィルタ上限 小数点以下 0 桁まで、超過分は切り捨てられます
戻り値
パラメータ 型 説明 ret RET_CODE API呼び出し結果 data pd.DataFrame ret == RET_OK の場合、オプション链データ str ret != RET_OK の場合、エラーの説明を返す - オプションチェーンデータフォーマットは以下の通りです:
フィールド タイプ 説明 code str 銘柄コード name str 名字 lot_size int 1手あたりの株数。オプションの場合は1枚あたりの株数 指数オプションにはこのフィールドはありませんstock_type SecurityType 株式タイプ option_type OptionType オプションタイプ stock_owner str 原資産株 strike_time str 行使日 フォーマット:yyyy-MM-dd
香港株と A 株市場のデフォルトは北京時間、米国株市場のデフォルトは米国東部時間strike_price float 行使価格 suspension bool かどうか売買停止 True:売買停止中
False:未売買停止stock_id int 株式 ID index_option_type IndexOptionType 指数オプションタイプ expiration_cycle ExpirationCycle 受渡周期 option_standard_type OptionStandardType オプション標準タイプ option_settlement_mode OptionSettlementMode オプション結算方式
- オプションチェーンデータフォーマットは以下の通りです:
Example
from moomoo import *
import time
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret1, data1 = quote_ctx.get_option_expiration_date(code='HK.00700')
filter1 = OptionDataFilter()
filter1.delta_min = 0
filter1.delta_max = 0.1
if ret1 == RET_OK:
expiration_date_list = data1['strike_time'].values.tolist()
for date in expiration_date_list:
ret2, data2 = quote_ctx.get_option_chain(code='HK.00700', start=date, end=date, data_filter=filter1)
if ret2 == RET_OK:
print(data2)
print(data2['code'][0]) # 最初のレコードの銘柄コードを取得
print(data2['code'].values.tolist()) # list に変換
else:
print('error:', data2)
time.sleep(3)
else:
print('error:', data1)
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
- Output
code name lot_size stock_type option_type stock_owner strike_time strike_price suspension stock_id index_option_type expiration_cycle option_standard_type option_settlement_mode
0 HK.TCH210429C350000 腾讯 210429 350.00 购 100 DRVT CALL HK.00700 2021-04-29 350.0 False 80235167 N/A WEEK STANDARD N/A
1 HK.TCH210429P350000 腾讯 210429 350.00 沽 100 DRVT PUT HK.00700 2021-04-29 350.0 False 80235247 N/A WEEK STANDARD N/A
2 HK.TCH210429C360000 腾讯 210429 360.00 购 100 DRVT CALL HK.00700 2021-04-29 360.0 False 80235163 N/A WEEK STANDARD N/A
3 HK.TCH210429P360000 腾讯 210429 360.00 沽 100 DRVT PUT HK.00700 2021-04-29 360.0 False 80235246 N/A WEEK STANDARD N/A
4 HK.TCH210429C370000 腾讯 210429 370.00 购 100 DRVT CALL HK.00700 2021-04-29 370.0 False 80235165 N/A WEEK STANDARD N/A
5 HK.TCH210429P370000 腾讯 210429 370.00 沽 100 DRVT PUT HK.00700 2021-04-29 370.0 False 80235248 N/A WEEK STANDARD N/A
HK.TCH210429C350000
['HK.TCH210429C350000', 'HK.TCH210429P350000', 'HK.TCH210429C360000', 'HK.TCH210429P360000', 'HK.TCH210429C370000', 'HK.TCH210429P370000']
...
code name lot_size stock_type option_type stock_owner strike_time strike_price suspension stock_id index_option_type expiration_cycle option_standard_type option_settlement_mode
0 HK.TCH220330C490000 腾讯 220330 490.00 购 100 DRVT CALL HK.00700 2022-03-30 490.0 False 80235143 N/A WEEK STANDARD N/A
1 HK.TCH220330P490000 腾讯 220330 490.00 沽 100 DRVT PUT HK.00700 2022-03-30 490.0 False 80235193 N/A WEEK STANDARD N/A
2 HK.TCH220330C500000 腾讯 220330 500.00 购 100 DRVT CALL HK.00700 2022-03-30 500.0 False 80233887 N/A WEEK STANDARD N/A
3 HK.TCH220330P500000 腾讯 220330 500.00 沽 100 DRVT PUT HK.00700 2022-03-30 500.0 False 80233912 N/A WEEK STANDARD N/A
4 HK.TCH220330C510000 腾讯 220330 510.00 购 100 DRVT CALL HK.00700 2022-03-30 510.0 False 80233747 N/A WEEK STANDARD N/A
5 HK.TCH220330P510000 腾讯 220330 510.00 沽 100 DRVT PUT HK.00700 2022-03-30 510.0 False 80233766 N/A WEEK STANDARD N/A
HK.TCH220330C490000
['HK.TCH220330C490000', 'HK.TCH220330P490000', 'HK.TCH220330C500000', 'HK.TCH220330P500000', 'HK.TCH220330C510000', 'HK.TCH220330P510000']
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Qot_GetOptionChain.proto
概要
原資産株からオプションチェーンを照会します。このAPIはオプションチェーンの静的情報のみを返します。気配値や板情報などの動的情報を取得するには、このAPIが返す銘柄コードを使用して、必要なタイプを自身で 登録 してください。
プロトコル ID
3209
パラメータ
enum OptionCondType
{
OptionCondType_Unknow = 0;
OptionCondType_WithIn = 1; //インザマネー
OptionCondType_Outside = 2; //アウトオブザマネー
}
//以下はデータフィールドフィルタ(任意フィールド)。未入力の場合はフィルタなし
message DataFilter
{
optional double impliedVolatilityMin = 1; //IV(インプライドボラティリティ)フィルタ下限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double impliedVolatilityMax = 2; //IV(インプライドボラティリティ)フィルタ上限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double deltaMin = 3; //グリークス Delta フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double deltaMax = 4; //グリークス Delta フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double gammaMin = 5; //グリークス Gamma フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double gammaMax = 6; //グリークス Gamma フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double vegaMin = 7; //グリークス Vega フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double vegaMax = 8; //グリークス Vega フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double thetaMin = 9; //グリークス Theta フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double thetaMax = 10; //グリークス Theta フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double rhoMin = 11; //グリークス Rho フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double rhoMax = 12; //グリークス Rho フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double netOpenInterestMin = 13; //ネット未決済建玉数フィルタ下限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double netOpenInterestMax = 14; //ネット未決済建玉数フィルタ上限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double openInterestMin = 15; //未決済建玉数フィルタ下限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double openInterestMax = 16; //未決済建玉数フィルタ上限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double volMin = 17; //出来高フィルタ下限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double volMax = 18; //出来高フィルタ上限(小数点以下 0 桁まで、超過分は切り捨てられます)
}
message C2S
{
required Qot_Common.Security owner = 1; //オプションの原資産株。現在は香港・米国の正株およびハンセン指数・国企指数・米国指数のみ対応
optional int32 indexOptionType = 6; //Qot_Common.IndexOptionType、指数オプションのタイプ。ハンセン指数・国企指数のみ使用
optional int32 type = 2; //Qot_Common.OptionType、オプションタイプ(任意フィールド)。未指定の場合はすべて返す
optional int32 condition = 3; //OptionCondType、インザマネー/アウトオブザマネー(任意フィールド)。未指定の場合はすべて返す
required string beginTime = 4; //オプション満期日開始時間(フォーマット:yyyy-MM-dd)
required string endTime = 5; //オプション満期日結束時間,時間跨度最大一個月(フォーマット:yyyy-MM-dd)
optional DataFilter dataFilter = 7; //データフィールドフィルタ
}
message Request
{
required C2S c2s = 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
43
44
45
46
47
48
49
50
51
52
53
- 株式構造は~を参照: Security
- オプションタイプ枚举参见 OptionType
- 指数オプション類别枚举参见 IndexOptionType
- 戻り値
message OptionItem
{
optional Qot_Common.SecurityStaticInfo call = 1; //コールオプション。このフィールドは必ずしも存在せず、リクエスト条件により決定
optional Qot_Common.SecurityStaticInfo put = 2; //プットオプション。このフィールドは必ずしも存在せず、リクエスト条件により決定
}
message OptionChain
{
required string strikeTime = 1; //行使日(フォーマット:yyyy-MM-dd)
repeated OptionItem option = 2; //オプション情報
optional double strikeTimestamp = 3; //行使日タイムスタンプ
}
message S2C
{
repeated OptionChain optionChain = 1; //オプション链
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType、戻り値
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
- 株式静態情報構造は~を参照: SecurityStaticInfo
- API 呼び出し結果,構造は~を参照: RetType
プロトコル ID
3209
uint GetOptionChain(QotGetOptionChain.Request req);
virtual void OnReply_GetOptionChain(MMAPI_Conn client, uint nSerialNo, QotGetOptionChain.Response rsp);
概要
原資産株からオプションチェーンを照会します。このAPIはオプションチェーンの静的情報のみを返します。気配値や板情報などの動的情報を取得するには、このAPIが返す銘柄コードを使用して、必要なタイプを自身で 登録 してください。
パラメータ
enum OptionCondType
{
OptionCondType_Unknow = 0;
OptionCondType_WithIn = 1; //インザマネー
OptionCondType_Outside = 2; //アウトオブザマネー
}
//以下はデータフィールドフィルタ(任意フィールド)。未入力の場合はフィルタなし
message DataFilter
{
optional double impliedVolatilityMin = 1; //IV(インプライドボラティリティ)フィルタ下限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double impliedVolatilityMax = 2; //IV(インプライドボラティリティ)フィルタ上限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double deltaMin = 3; //グリークス Delta フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double deltaMax = 4; //グリークス Delta フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double gammaMin = 5; //グリークス Gamma フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double gammaMax = 6; //グリークス Gamma フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double vegaMin = 7; //グリークス Vega フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double vegaMax = 8; //グリークス Vega フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double thetaMin = 9; //グリークス Theta フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double thetaMax = 10; //グリークス Theta フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double rhoMin = 11; //グリークス Rho フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double rhoMax = 12; //グリークス Rho フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double netOpenInterestMin = 13; //ネット未決済建玉数フィルタ下限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double netOpenInterestMax = 14; //ネット未決済建玉数フィルタ上限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double openInterestMin = 15; //未決済建玉数フィルタ下限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double openInterestMax = 16; //未決済建玉数フィルタ上限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double volMin = 17; //出来高フィルタ下限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double volMax = 18; //出来高フィルタ上限(小数点以下 0 桁まで、超過分は切り捨てられます)
}
message C2S
{
required Qot_Common.Security owner = 1; //オプションの原資産株。現在は香港・米国の正株およびハンセン指数・国企指数・米国指数のみ対応
optional int32 indexOptionType = 6; //Qot_Common.IndexOptionType、指数オプションのタイプ。ハンセン指数・国企指数のみ使用
optional int32 type = 2; //Qot_Common.OptionType、オプションタイプ(任意フィールド)。未指定の場合はすべて返す
optional int32 condition = 3; //OptionCondType、インザマネー/アウトオブザマネー(任意フィールド)。未指定の場合はすべて返す
required string beginTime = 4; //オプション満期日開始時間(フォーマット:yyyy-MM-dd)
required string endTime = 5; //オプション満期日結束時間,時間跨度最大一個月(フォーマット:yyyy-MM-dd)
optional DataFilter dataFilter = 7; //データフィールドフィルタ
}
message Request
{
required C2S c2s = 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
43
44
45
46
47
48
49
50
51
52
53
- 株式構造は~を参照: Security
- オプションタイプ枚举参见 OptionType
- 指数オプション類别枚举参见 IndexOptionType
- 戻り値
message OptionItem
{
optional Qot_Common.SecurityStaticInfo call = 1; //コールオプション。このフィールドは必ずしも存在せず、リクエスト条件により決定
optional Qot_Common.SecurityStaticInfo put = 2; //プットオプション。このフィールドは必ずしも存在せず、リクエスト条件により決定
}
message OptionChain
{
required string strikeTime = 1; //行使日(フォーマット:yyyy-MM-dd)
repeated OptionItem option = 2; //オプション情報
optional double strikeTimestamp = 3; //行使日タイムスタンプ
}
message S2C
{
repeated OptionChain optionChain = 1; //オプション链
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType、戻り値
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
- 株式静態情報構造は~を参照: SecurityStaticInfo
- API 呼び出し結果,構造は~を参照: RetType
- Example
public class Program : MMSPI_Qot, MMSPI_Conn {
MMAPI_Qot qot = new MMAPI_Qot();
public Program() {
qot.SetClientInfo("csharp", 1); //クライアント情報の設定
qot.SetConnCallback(this); //接続コールバックの設定
qot.SetQotCallback(this); //取引コールバックの設定
}
public void Start() {
qot.InitConnect("127.0.0.1", (ushort)11111, false);
}
public void OnInitConnect(MMAPI_Conn client, long errCode, String desc)
{
Console.Write("Qot onInitConnect: ret={0} desc={1} connID={2}\n", errCode, desc, client.GetConnectID());
if (errCode != 0)
return;
QotCommon.Security sec = QotCommon.Security.CreateBuilder()
.SetMarket((int)QotCommon.QotMarket.QotMarket_HK_Security)
.SetCode("00700")
.Build();
QotGetOptionChain.C2S c2s = QotGetOptionChain.C2S.CreateBuilder()
.SetOwner(sec)
.SetBeginTime("2020-11-01")
.SetEndTime("2020-12-01")
.Build();
QotGetOptionChain.Request req = QotGetOptionChain.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetOptionChain(req);
Console.Write("Send QotGetOptionChain: {0}\n", seqNo);
}
public void OnDisconnect(MMAPI_Conn client, long errCode) {
Console.Write("Qot onDisConnect: {0}\n", errCode);
}
public void OnReply_GetOptionChain(MMAPI_Conn client, uint nSerialNo, QotGetOptionChain.Response rsp)
{
Console.Write("Reply: QotGetOptionChain: {0}\n", nSerialNo);
Console.Write("strikeTime: {0}, name: {1} \n",
rsp.S2C.OptionChainList[0].StrikeTime,
rsp.S2C.OptionChainList[0].OptionList[0].Call.Basic.Name);
}
public static void Main(String[] args) {
MMAPI.Init();
Program qot = new Program();
qot.Start();
while (true)
Thread.Sleep(1000 * 600);
}
}
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
47
48
49
50
51
52
53
54
55
56
57
- Output
Qot onInitConnect: ret=0 desc= connID=6825705573658441031
Send QotGetOptionChain: 3
Reply: QotGetOptionChain: 3
strikeTime: 2021-07-29, name: 腾讯 210729 400.00 购
2
3
4
int getOptionChain(QotGetOptionChain.Request req);
void onReply_GetOptionChain(MMAPI_Conn client, int nSerialNo, QotGetOptionChain.Response rsp);
概要
原資産株からオプションチェーンを照会します。このAPIはオプションチェーンの静的情報のみを返します。気配値や板情報などの動的情報を取得するには、このAPIが返す銘柄コードを使用して、必要なタイプを自身で 登録 してください。
パラメータ
enum OptionCondType
{
OptionCondType_Unknow = 0;
OptionCondType_WithIn = 1; //インザマネー
OptionCondType_Outside = 2; //アウトオブザマネー
}
//以下はデータフィールドフィルタ(任意フィールド)。未入力の場合はフィルタなし
message DataFilter
{
optional double impliedVolatilityMin = 1; //IV(インプライドボラティリティ)フィルタ下限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double impliedVolatilityMax = 2; //IV(インプライドボラティリティ)フィルタ上限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double deltaMin = 3; //グリークス Delta フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double deltaMax = 4; //グリークス Delta フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double gammaMin = 5; //グリークス Gamma フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double gammaMax = 6; //グリークス Gamma フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double vegaMin = 7; //グリークス Vega フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double vegaMax = 8; //グリークス Vega フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double thetaMin = 9; //グリークス Theta フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double thetaMax = 10; //グリークス Theta フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double rhoMin = 11; //グリークス Rho フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double rhoMax = 12; //グリークス Rho フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double netOpenInterestMin = 13; //ネット未決済建玉数フィルタ下限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double netOpenInterestMax = 14; //ネット未決済建玉数フィルタ上限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double openInterestMin = 15; //未決済建玉数フィルタ下限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double openInterestMax = 16; //未決済建玉数フィルタ上限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double volMin = 17; //出来高フィルタ下限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double volMax = 18; //出来高フィルタ上限(小数点以下 0 桁まで、超過分は切り捨てられます)
}
message C2S
{
required Qot_Common.Security owner = 1; //オプションの原資産株。現在は香港・米国の正株およびハンセン指数・国企指数・米国指数のみ対応
optional int32 indexOptionType = 6; //Qot_Common.IndexOptionType、指数オプションのタイプ。ハンセン指数・国企指数のみ使用
optional int32 type = 2; //Qot_Common.OptionType、オプションタイプ(任意フィールド)。未指定の場合はすべて返す
optional int32 condition = 3; //OptionCondType、インザマネー/アウトオブザマネー(任意フィールド)。未指定の場合はすべて返す
required string beginTime = 4; //オプション満期日開始時間(フォーマット:yyyy-MM-dd)
required string endTime = 5; //オプション満期日結束時間,時間跨度最大一個月(フォーマット:yyyy-MM-dd)
optional DataFilter dataFilter = 7; //データフィールドフィルタ
}
message Request
{
required C2S c2s = 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
43
44
45
46
47
48
49
50
51
52
53
- 株式構造は~を参照: Security
- オプションタイプ枚举参见 OptionType
- 指数オプション類别枚举参见 IndexOptionType
- 戻り値
message OptionItem
{
optional Qot_Common.SecurityStaticInfo call = 1; //コールオプション。このフィールドは必ずしも存在せず、リクエスト条件により決定
optional Qot_Common.SecurityStaticInfo put = 2; //プットオプション。このフィールドは必ずしも存在せず、リクエスト条件により決定
}
message OptionChain
{
required string strikeTime = 1; //行使日(フォーマット:yyyy-MM-dd)
repeated OptionItem option = 2; //オプション情報
optional double strikeTimestamp = 3; //行使日タイムスタンプ
}
message S2C
{
repeated OptionChain optionChain = 1; //オプション链
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType、戻り値
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
- 株式静態情報構造は~を参照: SecurityStaticInfo
- API 呼び出し結果,構造は~を参照: RetType
- Example
public class QotDemo implements MMSPI_Qot, MMSPI_Conn {
MMAPI_Conn_Qot qot = new MMAPI_Conn_Qot();
public QotDemo() {
qot.setClientInfo("javaclient", 1); //クライアント情報の設定
qot.setConnSpi(this); //接続コールバックの設定
qot.setQotSpi(this); //取引コールバックの設定
}
public void start() {
qot.initConnect("127.0.0.1", (short)11111, false);
}
@Override
public void onInitConnect(MMAPI_Conn client, long errCode, String desc)
{
System.out.printf("Qot onInitConnect: ret=%b desc=%s connID=%d\n", errCode, desc, client.getConnectID());
if (errCode != 0)
return;
QotCommon.Security sec = QotCommon.Security.newBuilder()
.setMarket(QotCommon.QotMarket.QotMarket_HK_Security_VALUE)
.setCode("00700")
.build();
QotGetOptionChain.C2S c2s = QotGetOptionChain.C2S.newBuilder()
.setOwner(sec)
.setBeginTime("2021-06-01")
.setEndTime("2021-07-01")
.build();
QotGetOptionChain.Request req = QotGetOptionChain.Request.newBuilder().setC2S(c2s).build();
int seqNo = qot.getOptionChain(req);
System.out.printf("Send QotGetOptionChain: %d\n", seqNo);
}
@Override
public void onDisconnect(MMAPI_Conn client, long errCode) {
System.out.printf("Qot onDisConnect: %d\n", errCode);
}
@Override
public void onReply_GetOptionChain(MMAPI_Conn client, int nSerialNo, QotGetOptionChain.Response rsp) {
if (rsp.getRetType() != 0) {
System.out.printf("QotGetOptionChain failed: %s\n", rsp.getRetMsg());
}
else {
try {
String json = JsonFormat.printer().print(rsp);
System.out.printf("Receive QotGetOptionChain: %s\n", json);
} catch (InvalidProtocolBufferException e) {
e.printStackTrace();
}
}
}
public static void main(String[] args) {
MMAPI.init();
QotDemo qot = new QotDemo();
qot.start();
while (true) {
try {
Thread.sleep(1000 * 600);
} catch (InterruptedException exc) {
}
}
}
}
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
- Output
Send QotGetOptionChain: 2
Receive QotGetOptionChain: {
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"optionChain": [{
"strikeTime": "2021-06-29",
"option": [{
"call": {
"basic": {
"security": {
"market": 1,
"code": "TCH210629C295000"
},
"id": "80143386",
"lotSize": 100,
"secType": 8,
"name": "腾讯 210629 295.00 购",
"listTime": "",
"delisting": false
},
"optionExData": {
"type": 1,
"owner": {
"market": 1,
"code": "00700"
},
"strikeTime": "2021-06-29",
"strikePrice": 295.0,
"suspend": false,
"market": "",
"strikeTimestamp": 1.624896E9,
"expirationCycle": 1,
"optionStandardType": 1,
"optionSettlementMode": 2,
}
},
"put": {
"basic": {
"security": {
"market": 1,
"code": "TCH210629P295000"
},
"id": "80143074",
"lotSize": 100,
"secType": 8,
"name": "腾讯 210629 295.00 沽",
"listTime": "",
"delisting": false
},
"optionExData": {
"type": 2,
"owner": {
"market": 1,
"code": "00700"
},
"strikeTime": "2021-06-29",
"strikePrice": 295.0,
"suspend": false,
"market": "",
"strikeTimestamp": 1.624896E9,
"expirationCycle": 1,
"optionStandardType": 1,
"optionSettlementMode": 2,
}
}
}, ... {
"call": {
"basic": {
"security": {
"market": 1,
"code": "TCH210629C1050000"
},
"id": "80223489",
"lotSize": 100,
"secType": 8,
"name": "腾讯 210629 1050.00 购",
"listTime": "",
"delisting": false
},
"optionExData": {
"type": 1,
"owner": {
"market": 1,
"code": "00700"
},
"strikeTime": "2021-06-29",
"strikePrice": 1050.0,
"suspend": false,
"market": "",
"strikeTimestamp": 1.624896E9,
"expirationCycle": 1,
"optionStandardType": 1,
"optionSettlementMode": 2,
}
},
"put": {
"basic": {
"security": {
"market": 1,
"code": "TCH210629P1050000"
},
"id": "80223488",
"lotSize": 100,
"secType": 8,
"name": "腾讯 210629 1050.00 沽",
"listTime": "",
"delisting": false
},
"optionExData": {
"type": 2,
"owner": {
"market": 1,
"code": "00700"
},
"strikeTime": "2021-06-29",
"strikePrice": 1050.0,
"suspend": false,
"market": "",
"strikeTimestamp": 1.624896E9,
"expirationCycle": 1,
"optionStandardType": 1,
"optionSettlementMode": 2,
}
}
}],
"strikeTimestamp": 1.624896E9
}]
}
}
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
moomoo::u32_t GetOptionChain(const Qot_GetOptionChain::Request &stReq);
virtual void OnReply_GetOptionChain(moomoo::u32_t nSerialNo, const Qot_GetOptionChain::Response &stRsp) = 0;
概要
原資産株からオプションチェーンを照会します。このAPIはオプションチェーンの静的情報のみを返します。気配値や板情報などの動的情報を取得するには、このAPIが返す銘柄コードを使用して、必要なタイプを自身で 登録 してください。
パラメータ
enum OptionCondType
{
OptionCondType_Unknow = 0;
OptionCondType_WithIn = 1; //インザマネー
OptionCondType_Outside = 2; //アウトオブザマネー
}
//以下はデータフィールドフィルタ(任意フィールド)。未入力の場合はフィルタなし
message DataFilter
{
optional double impliedVolatilityMin = 1; //IV(インプライドボラティリティ)フィルタ下限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double impliedVolatilityMax = 2; //IV(インプライドボラティリティ)フィルタ上限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double deltaMin = 3; //グリークス Delta フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double deltaMax = 4; //グリークス Delta フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double gammaMin = 5; //グリークス Gamma フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double gammaMax = 6; //グリークス Gamma フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double vegaMin = 7; //グリークス Vega フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double vegaMax = 8; //グリークス Vega フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double thetaMin = 9; //グリークス Theta フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double thetaMax = 10; //グリークス Theta フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double rhoMin = 11; //グリークス Rho フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double rhoMax = 12; //グリークス Rho フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double netOpenInterestMin = 13; //ネット未決済建玉数フィルタ下限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double netOpenInterestMax = 14; //ネット未決済建玉数フィルタ上限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double openInterestMin = 15; //未決済建玉数フィルタ下限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double openInterestMax = 16; //未決済建玉数フィルタ上限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double volMin = 17; //出来高フィルタ下限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double volMax = 18; //出来高フィルタ上限(小数点以下 0 桁まで、超過分は切り捨てられます)
}
message C2S
{
required Qot_Common.Security owner = 1; //オプションの原資産株。現在は香港・米国の正株およびハンセン指数・国企指数・米国指数のみ対応
optional int32 indexOptionType = 6; //Qot_Common.IndexOptionType、指数オプションのタイプ。ハンセン指数・国企指数のみ使用
optional int32 type = 2; //Qot_Common.OptionType、オプションタイプ(任意フィールド)。未指定の場合はすべて返す
optional int32 condition = 3; //OptionCondType、インザマネー/アウトオブザマネー(任意フィールド)。未指定の場合はすべて返す
required string beginTime = 4; //オプション満期日開始時間(フォーマット:yyyy-MM-dd)
required string endTime = 5; //オプション満期日結束時間,時間跨度最大一個月(フォーマット:yyyy-MM-dd)
optional DataFilter dataFilter = 7; //データフィールドフィルタ
}
message Request
{
required C2S c2s = 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
43
44
45
46
47
48
49
50
51
52
53
- 株式構造は~を参照: Security
- オプションタイプ枚举参见 OptionType
- 指数オプション類别枚举参见 IndexOptionType
- 戻り値
message OptionItem
{
optional Qot_Common.SecurityStaticInfo call = 1; //コールオプション。このフィールドは必ずしも存在せず、リクエスト条件により決定
optional Qot_Common.SecurityStaticInfo put = 2; //プットオプション。このフィールドは必ずしも存在せず、リクエスト条件により決定
}
message OptionChain
{
required string strikeTime = 1; //行使日(フォーマット:yyyy-MM-dd)
repeated OptionItem option = 2; //オプション情報
optional double strikeTimestamp = 3; //行使日タイムスタンプ
}
message S2C
{
repeated OptionChain optionChain = 1; //オプション链
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType、戻り値
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
- 株式静態情報構造は~を参照: SecurityStaticInfo
- API 呼び出し結果,構造は~を参照: RetType
- Example
class Program : public MMSPI_Qot, public MMSPI_Trd, public MMSPI_Conn
{
public:
Program() {
m_pQotApi = MMAPI::CreateQotApi();
m_pQotApi->RegisterQotSpi(this);
m_pQotApi->RegisterConnSpi(this);
}
~Program() {
if (m_pQotApi != nullptr)
{
m_pQotApi->UnregisterQotSpi();
m_pQotApi->UnregisterConnSpi();
MMAPI::ReleaseQotApi(m_pQotApi);
m_pQotApi = nullptr;
}
}
void Start() {
m_pQotApi->InitConnect("127.0.0.1", 11111, false);
}
virtual void OnInitConnect(MMAPI_Conn* pConn, moomoo::i64_t nErrCode, const char* strDesc) {
cout << "connect" << endl;
// パケット生成
Qot_GetOptionChain::Request req;
Qot_GetOptionChain::C2S *c2s = req.mutable_c2s();
Qot_Common::Security *sec = c2s->mutable_owner();
sec->set_code("00700");
sec->set_market(Qot_Common::QotMarket::QotMarket_HK_Security);
c2s->set_begintime("2021-06-07");
c2s->set_endtime("2021-07-01");
m_GetOptionChainSerialNo = m_pQotApi->GetOptionChain(req);
cout << "Request GetOptionChain SerialNo: " << m_GetOptionChainSerialNo << endl;
}
virtual void OnReply_GetOptionChain(moomoo::u32_t nSerialNo, const Qot_GetOptionChain::Response &stRsp){
if(nSerialNo == m_GetOptionChainSerialNo)
{
cout << "OnReply_GetOptionChain SerialNo: " << nSerialNo << endl;
// 内部構造を解析して出力
// ProtoBufToBodyData と UTF8ToLocal 関数の定義は Sample の tool.h ファイルを参照
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
}
protected:
MMAPI_Qot *m_pQotApi;
moomoo::u32_t m_GetOptionChainSerialNo;
};
int32_t main(int32_t argc, char** argv)
{
MMAPI::Init();
{
Program program;
program.Start();
getchar();
}
protobuf::ShutdownProtobufLibrary();
MMAPI::UnInit();
return 0;
}
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
- Output
connect
Request GetOptionChain SerialNo: 4
OnReply_GetOptionChain SerialNo: 4
{
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"optionChain": [
{
"strikeTime": "2021-06-29",
"option": [
{
"call": {
"basic": {
"security": {
"market": 1,
"code": "TCH210629C295000"
},
"id": "80143386",
"lotSize": 100,
"secType": 8,
"name": "腾讯 210629 295.00 购",
"listTime": "",
"delisting": false
},
"optionExData": {
"type": 1,
"owner": {
"market": 1,
"code": "00700"
},
"strikeTime": "2021-06-29",
"strikePrice": 295,
"suspend": false,
"market": "",
"strikeTimestamp": 1624896000,
"expirationCycle": 1,
"optionStandardType": 1,
"optionSettlementMode": 2,
}
},
"put": {
"basic": {
"security": {
"market": 1,
"code": "TCH210629P295000"
},
"id": "80143074",
"lotSize": 100,
"secType": 8,
"name": "腾讯 210629 295.00 沽",
"listTime": "",
"delisting": false
},
"optionExData": {
"type": 2,
"owner": {
"market": 1,
"code": "00700"
},
"strikeTime": "2021-06-29",
"strikePrice": 295,
"suspend": false,
"market": "",
"strikeTimestamp": 1624896000,
"expirationCycle": 1,
"optionStandardType": 1,
"optionSettlementMode": 2,
}
}
},
...
{
"call": {
"basic": {
"security": {
"market": 1,
"code": "TCH210629C1050000"
},
"id": "80223489",
"lotSize": 100,
"secType": 8,
"name": "腾讯 210629 1050.00 购",
"listTime": "",
"delisting": false
},
"optionExData": {
"type": 1,
"owner": {
"market": 1,
"code": "00700"
},
"strikeTime": "2021-06-29",
"strikePrice": 1050,
"suspend": false,
"market": "",
"strikeTimestamp": 1624896000,
"expirationCycle": 1,
"optionStandardType": 1,
"optionSettlementMode": 2,
}
},
"put": {
"basic": {
"security": {
"market": 1,
"code": "TCH210629P1050000"
},
"id": "80223488",
"lotSize": 100,
"secType": 8,
"name": "腾讯 210629 1050.00 沽",
"listTime": "",
"delisting": false
},
"optionExData": {
"type": 2,
"owner": {
"market": 1,
"code": "00700"
},
"strikeTime": "2021-06-29",
"strikePrice": 1050,
"suspend": false,
"market": "",
"strikeTimestamp": 1624896000,
"expirationCycle": 1,
"optionStandardType": 1,
"optionSettlementMode": 2,
}
}
}
],
"strikeTimestamp": 1624896000
}
]
}
}
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
GetOptionChain(req);
概要
原資産株からオプションチェーンを照会します。このAPIはオプションチェーンの静的情報のみを返します。気配値や板情報などの動的情報を取得するには、このAPIが返す銘柄コードを使用して、必要なタイプを自身で 登録 してください。
パラメータ
enum OptionCondType
{
OptionCondType_Unknow = 0;
OptionCondType_WithIn = 1; //インザマネー
OptionCondType_Outside = 2; //アウトオブザマネー
}
//以下はデータフィールドフィルタ(任意フィールド)。未入力の場合はフィルタなし
message DataFilter
{
optional double impliedVolatilityMin = 1; //IV(インプライドボラティリティ)フィルタ下限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double impliedVolatilityMax = 2; //IV(インプライドボラティリティ)フィルタ上限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double deltaMin = 3; //グリークス Delta フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double deltaMax = 4; //グリークス Delta フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double gammaMin = 5; //グリークス Gamma フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double gammaMax = 6; //グリークス Gamma フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double vegaMin = 7; //グリークス Vega フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double vegaMax = 8; //グリークス Vega フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double thetaMin = 9; //グリークス Theta フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double thetaMax = 10; //グリークス Theta フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double rhoMin = 11; //グリークス Rho フィルタ下限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double rhoMax = 12; //グリークス Rho フィルタ上限(小数点以下 3 桁まで、超過分は切り捨てられます)
optional double netOpenInterestMin = 13; //ネット未決済建玉数フィルタ下限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double netOpenInterestMax = 14; //ネット未決済建玉数フィルタ上限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double openInterestMin = 15; //未決済建玉数フィルタ下限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double openInterestMax = 16; //未決済建玉数フィルタ上限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double volMin = 17; //出来高フィルタ下限(小数点以下 0 桁まで、超過分は切り捨てられます)
optional double volMax = 18; //出来高フィルタ上限(小数点以下 0 桁まで、超過分は切り捨てられます)
}
message C2S
{
required Qot_Common.Security owner = 1; //オプションの原資産株。現在は香港・米国の正株およびハンセン指数・国企指数・米国指数のみ対応
optional int32 indexOptionType = 6; //Qot_Common.IndexOptionType、指数オプションのタイプ。ハンセン指数・国企指数のみ使用
optional int32 type = 2; //Qot_Common.OptionType、オプションタイプ(任意フィールド)。未指定の場合はすべて返す
optional int32 condition = 3; //OptionCondType、インザマネー/アウトオブザマネー(任意フィールド)。未指定の場合はすべて返す
required string beginTime = 4; //オプション満期日開始時間(フォーマット:yyyy-MM-dd)
required string endTime = 5; //オプション満期日結束時間,時間跨度最大一個月(フォーマット:yyyy-MM-dd)
optional DataFilter dataFilter = 7; //データフィールドフィルタ
}
message Request
{
required C2S c2s = 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
43
44
45
46
47
48
49
50
51
52
53
- 株式構造は~を参照: Security
- オプションタイプ枚举参见 OptionType
- 指数オプション類别枚举参见 IndexOptionType
- 戻り値
message OptionItem
{
optional Qot_Common.SecurityStaticInfo call = 1; //コールオプション。このフィールドは必ずしも存在せず、リクエスト条件により決定
optional Qot_Common.SecurityStaticInfo put = 2; //プットオプション。このフィールドは必ずしも存在せず、リクエスト条件により決定
}
message OptionChain
{
required string strikeTime = 1; //行使日(フォーマット:yyyy-MM-dd)
repeated OptionItem option = 2; //オプション情報
optional double strikeTimestamp = 3; //行使日タイムスタンプ
}
message S2C
{
repeated OptionChain optionChain = 1; //オプション链
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType、戻り値
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
- 株式静態情報構造は~を参照: SecurityStaticInfo
- API 呼び出し結果,構造は~を参照: RetType
- Example
import mmWebsocket from "moomoo-api";
import { mmCmdID } from "moomoo-api";
import { Common, Qot_Common } from "moomoo-api/proto";
import beautify from "js-beautify";
function QotGetOptionChain(){
const { RetType } = Common
const { QotMarket } = Qot_Common
let [addr, port, enable_ssl, key] = ["127.0.0.1", 33333, false, '7522027ccf5a06b1'];
let websocket = new mmWebsocket();
websocket.onlogin = (ret, msg)=>{
if (ret) { // ログイン成功
const req = {
c2s: {
owner:{
market: QotMarket.QotMarket_HK_Security,
code: "00700",
},
beginTime: "2021-09-01",
endTime: "2021-09-30",
},
};
websocket.GetOptionChain(req)
.then((res) => {
let { errCode, retMsg, retType,s2c } = res
console.log("OptionChain: errCode %d, retMsg %s, retType %d", errCode, retMsg, retType);
if(retType == RetType.RetType_Succeed){
let data = beautify(JSON.stringify(s2c), {
indent_size: 2,
space_in_empty_paren: true,
});
console.log(data);
}
})
.catch((error) => {
console.log("error:", error);
});
} else {
console.log("error", msg);
}
};
websocket.start(addr, port, enable_ssl, key);
//相場接続をクローズ。使用後は接続をクローズしてください。不要なリソース占有を防ぎます
//OpenD は最大 128 接続に制限されています
//1 ページまたは 1 プロジェクトで 1 接続を維持することも可能。ここではサンプルとしてリクエストごとに 1 接続を作成
setTimeout(()=>{
websocket.stop();
console.log("stop");
}, 5000); // 5 秒後に切断
}
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
47
48
49
50
51
52
53
54
55
- Output
OptionChain: errCode 0, retMsg , retType 0
{
"optionChain": [{
"strikeTime": "2021-09-29",
"option": [{
"call": {
"basic": {
"security": {
"market": 1,
"code": "TCH210929C300000"
},
"id": "80287116",
"lotSize": 100,
"secType": 8,
"name": "腾讯 210929 300.00 购",
"listTime": "",
"delisting": false
},
"optionExData": {
"type": 1,
"owner": {
"market": 1,
"code": "00700"
},
"strikeTime": "2021-09-29",
"strikePrice": 300,
"suspend": false,
"market": "",
"strikeTimestamp": 1632844800,
"expirationCycle": 1,
"optionStandardType": 1,
"optionSettlementMode": 2,
}
},
"put": {
"basic": {
"security": {
"market": 1,
"code": "TCH210929P300000"
},
"id": "80287124",
"lotSize": 100,
"secType": 8,
"name": "腾讯 210929 300.00 沽",
"listTime": "",
"delisting": false
},
"optionExData": {
"type": 2,
"owner": {
"market": 1,
"code": "00700"
},
"strikeTime": "2021-09-29",
"strikePrice": 300,
"suspend": false,
"market": "",
"strikeTimestamp": 1632844800,
"expirationCycle": 1,
"optionStandardType": 1,
"optionSettlementMode": 2,
}
}
}, ..., {
"call": {
"basic": {
"security": {
"market": 1,
"code": "TCH210929C950000"
},
"id": "80215136",
"lotSize": 100,
"secType": 8,
"name": "腾讯 210929 950.00 购",
"listTime": "",
"delisting": false
},
"optionExData": {
"type": 1,
"owner": {
"market": 1,
"code": "00700"
},
"strikeTime": "2021-09-29",
"strikePrice": 950,
"suspend": false,
"market": "",
"strikeTimestamp": 1632844800,
"expirationCycle": 1,
"optionStandardType": 1,
"optionSettlementMode": 2,
}
},
"put": {
"basic": {
"security": {
"market": 1,
"code": "TCH210929P950000"
},
"id": "80215157",
"lotSize": 100,
"secType": 8,
"name": "腾讯 210929 950.00 沽",
"listTime": "",
"delisting": false
},
"optionExData": {
"type": 2,
"owner": {
"market": 1,
"code": "00700"
},
"strikeTime": "2021-09-29",
"strikePrice": 950,
"suspend": false,
"market": "",
"strikeTimestamp": 1632844800,
"expirationCycle": 1,
"optionStandardType": 1,
"optionSettlementMode": 2,
}
}
}],
"strikeTimestamp": 1632844800
}]
}
stop
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
APIレート制限
- 30 秒以内に最大 10 回オプション链API
- 指定可能な時間範囲の上限は 30 日です
ご注意
- このAPIは期限切れのオプションチェーンの照会に対応していません。終了日付 パラメータには本日または将来の日付を入力してください
- Open interest (OI) データは毎日更新されます。更新タイミングは取引所により異なります。米国株オプションはプレマーケット時間帯に更新され、香港株オプションはアフターマーケットに更新されます。
← 取得オプション链満期日 ワラントのフィルタ →