# Get Option Quote
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_option_quote(combo_leg_list)
Description
Get option snapshot quotes from a combo leg list, suitable for multi-leg strategy batch quote queries.
Parameters
Parameter Type Description combo_leg_list list Combo leg list Elements are OptionStrategyLeg; structure see get_option_strategyReturn
Parameter Type Description ret RET_CODE API call result data pd.DataFrame When ret == RET_OK, returns option snapshot data str When ret != RET_OK, returns error description DataFrame fields:
Field Type Description price float Combo price change_val float Change value change_rate float Change rate volume str Volume turnover str Turnover high_price str High price low_price str Low price mid_price str Mid price open_price str Open price last_close_price float Last close price open_interest str Open interest premium str Premium implied_volatility str Implied volatility delta float Delta gamma float Gamma vega float Vega theta float Theta rho float Rho option_type str Option type expire_time str Expiration date strike_price str Strike price contract_size float Contract size contract_multiplier float Contract multiplier exercise_type str Exercise type days_to_expiry int Days to expiry net_open_interest str Net open interest contract_value str Contract value equal_underlying str Equivalent underlying index_option_type str Index option type intrinsic_value float Intrinsic value time_value float Time value breakeven_point list Breakeven points dist_to_breakeven list Distance to breakeven prob_of_profit float Probability of profit This field is in percentage form, so 20 is equivalent to 20%.seller_roi str Seller ROI This field is in percentage form, so 20 is equivalent to 20%.mark_price float Mark price leverage_ratio str Leverage ratio effective_gearing str Effective gearing
Example
from futu import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data = quote_ctx.get_option_strategy(code='HK.00700', option_strategy=OptionStrategyType.STRADDLE)
if ret == RET_OK:
index=0
print(data['legs'][index])
ret2,data2 = quote_ctx.get_option_quote(data['legs'][index])
if ret2 == RET_OK:
print(data2)
else:
print("get_analysis,error:",data2)
else:
print('error:', data)
quote_ctx.close() # Remember to close the connection to avoid exhausting connection quota
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
- Output
[OptionStrategyLeg(code=HK.TCH260522P330000, action=BUY, quantity=1.0), OptionStrategyLeg(code=HK.TCH260522C330000, action=BUY, quantity=1.0)]
price change_val change_rate volume turnover high_price low_price mid_price open_price last_close_price open_interest premium implied_volatility delta gamma vega theta rho option_type expire_time strike_price contract_size contract_multiplier exercise_type days_to_expiry net_open_interest contract_value equal_underlying index_option_type intrinsic_value time_value breakeven_point dist_to_breakeven prob_of_profit seller_roi mark_price leverage_ratio effective_gearing
0 131.65 0.0 0.0 N/A N/A N/A N/A N/A N/A 131.65 N/A N/A N/A 0.974369 0.000797 0.019825 -0.785757 0.016246 N/A 2026-05-22 N/A 100.0 100.0 N/A 2 N/A N/A N/A N/A 125.2 6.45 [199.56, 460.44] [255.64, -5.240000000000009] 0.315418 N/A 130.4 N/A N/A
2
3
# Qot_GetOptionQuote.proto
Description
Get option combo snapshot quotes
Parameters
message C2S
{
repeated OptionStrategyLeg comboLegList = 1; // Combo leg list
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
- Combo leg structure: OptionStrategyLeg
- Return
message S2C
{
// Option snapshot list; fields per protocol definition
}
message Response
{
required int32 retType = 1 [default = -400]; // Return result,详见 Common.RetType
optional string retMsg = 2; // Return result description
optional int32 errCode = 3; // Error code
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
- API call result structure: RetType
- OptionType enum: OptionType
- IndexOptionType enum: IndexOptionType
uint GetOptionQuote(QotGetOptionQuote.Request req);
virtual void OnReply_GetOptionQuote(FTAPI_Conn client, uint nSerialNo, QotGetOptionQuote.Response rsp);
Description
Get option combo snapshot quotes. Pass multi_legs in the request; they can be obtained from GetOptionStrategy. A single leg returns one quote; multiple legs return one aggregated strategy quote.
Parameters
message C2S
{
repeated Qot_Common.ComboLeg multi_legs = 1;
optional Qot_Common.QotHeader header = 100;
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
- multi_legs can be obtained from GetOptionStrategy
- Return
message OptionQuote
{
optional double price = 1;
optional double chg = 2;
optional double chg_rate = 3;
optional int64 vol = 4;
optional double turnover = 5;
optional double high = 6;
optional double low = 7;
optional double mid = 8;
optional double open = 9;
optional double pre_close = 10;
optional int32 open_interest = 11;
optional double premium = 12;
optional double IV = 13;
optional double delta = 14;
optional double gamma = 15;
optional double vega = 16;
optional double theta = 17;
optional double rho = 18;
optional int32 option_type = 19;
optional string expire_time = 20;
optional double strike = 21;
optional double contract_size = 22;
optional double contract_multiplier = 23;
optional int32 exercise_type = 24;
optional int32 days_to_expiry = 25;
optional int32 net_open_interest = 26;
optional double contract_value = 27;
optional double equal_underlying = 28;
optional int32 index_option_type = 29;
optional double intrinsic_value = 30;
optional double time_value = 31;
repeated double breakeven_point = 32;
repeated double dist_to_breakeven = 33;
optional double prob_of_profit = 34;
optional double seller_roi = 35;
optional double mark_price = 36;
optional double leverage_ratio = 37;
optional double effective_gearing = 38;
}
message S2C
{
repeated OptionQuote optionQuoteList = 1;
}
message Response
{
required int32 retType = 1 [default = -400];
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
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
- 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.ComboLeg leg = QotCommon.ComboLeg.CreateBuilder()
.SetSecurity(QotCommon.Security.CreateBuilder()
.SetMarket((int)QotCommon.QotMarket.QotMarket_HK_Security)
.SetCode("TCH260622C330000")
.Build())
.SetSide((int)TrdCommon.TrdSide.TrdSide_Buy)
.SetQtyRatio(1)
.Build();
QotGetOptionQuote.C2S c2s = QotGetOptionQuote.C2S.CreateBuilder()
.AddMultiLegs(leg)
.Build();
QotGetOptionQuote.Request req = QotGetOptionQuote.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetOptionQuote(req);
Console.Write("Send QotGetOptionQuote: {0}\n", seqNo);
}
public void OnDisconnect(FTAPI_Conn client, long errCode)
{
Console.Write("Qot onDisConnect: {0}\n", errCode);
}
public void OnReply_GetOptionQuote(FTAPI_Conn client, uint nSerialNo, QotGetOptionQuote.Response rsp)
{
Console.Write("Reply: QotGetOptionQuote: {0} {1}\n", nSerialNo, rsp.ToString());
}
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
58
59
60
- Output
Qot onInitConnect: ret=0 desc= connID=7459213669204006063
Send QotGetOptionQuote: 3
Reply: QotGetOptionQuote: 3 retType: 0 ...
2
3
int getOptionQuote(QotGetOptionQuote.Request req);
void onReply_GetOptionQuote(FTAPI_Conn client, int nSerialNo, QotGetOptionQuote.Response rsp);
Description
Get option combo snapshot quotes. Pass multi_legs in the request; they can be obtained from GetOptionStrategy. A single leg returns one quote; multiple legs return one aggregated strategy quote.
Parameters
message C2S
{
repeated Qot_Common.ComboLeg multi_legs = 1;
optional Qot_Common.QotHeader header = 100;
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
- multi_legs can be obtained from GetOptionStrategy
- Return
message OptionQuote
{
optional double price = 1;
optional double chg = 2;
optional double chg_rate = 3;
optional int64 vol = 4;
optional double turnover = 5;
optional double high = 6;
optional double low = 7;
optional double mid = 8;
optional double open = 9;
optional double pre_close = 10;
optional int32 open_interest = 11;
optional double premium = 12;
optional double IV = 13;
optional double delta = 14;
optional double gamma = 15;
optional double vega = 16;
optional double theta = 17;
optional double rho = 18;
optional int32 option_type = 19;
optional string expire_time = 20;
optional double strike = 21;
optional double contract_size = 22;
optional double contract_multiplier = 23;
optional int32 exercise_type = 24;
optional int32 days_to_expiry = 25;
optional int32 net_open_interest = 26;
optional double contract_value = 27;
optional double equal_underlying = 28;
optional int32 index_option_type = 29;
optional double intrinsic_value = 30;
optional double time_value = 31;
repeated double breakeven_point = 32;
repeated double dist_to_breakeven = 33;
optional double prob_of_profit = 34;
optional double seller_roi = 35;
optional double mark_price = 36;
optional double leverage_ratio = 37;
optional double effective_gearing = 38;
}
message S2C
{
repeated OptionQuote optionQuoteList = 1;
}
message Response
{
required int32 retType = 1 [default = -400];
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
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
- 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.ComboLeg leg = QotCommon.ComboLeg.newBuilder()
.setSecurity(QotCommon.Security.newBuilder()
.setMarket(QotCommon.QotMarket.QotMarket_HK_Security_VALUE)
.setCode("TCH260622C330000")
.build())
.setSide(TrdCommon.TrdSide.TrdSide_Buy_VALUE)
.setQtyRatio(1)
.build();
QotGetOptionQuote.C2S c2s = QotGetOptionQuote.C2S.newBuilder()
.addMultiLegs(leg)
.build();
QotGetOptionQuote.Request req = QotGetOptionQuote.Request.newBuilder().setC2S(c2s).build();
int seqNo = qot.getOptionQuote(req);
System.out.printf("Send QotGetOptionQuote: %d\n", seqNo);
}
@Override
public void onDisconnect(FTAPI_Conn client, long errCode) {
System.out.printf("Qot onDisConnect: %d\n", errCode);
}
@Override
public void onReply_GetOptionQuote(FTAPI_Conn client, int nSerialNo, QotGetOptionQuote.Response rsp) {
if (rsp.getRetType() != 0) {
System.out.printf("QotGetOptionQuote failed: %s\n", rsp.getRetMsg());
}
else {
try {
String json = JsonFormat.printer().print(rsp);
System.out.printf("Receive QotGetOptionQuote: %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
69
70
- Output
Qot onInitConnect: ret=0 desc= connID=7459213669204006063
Send QotGetOptionQuote: 2
Receive QotGetOptionQuote: {
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"optionQuoteList": [
{
"strike": 330,
"price": 131.65,
"chg": 0,
"chgRate": 0,
"delta": 0.974369,
"gamma": 0.000797,
"vega": 0.019825,
"theta": -0.785757,
"rho": 0.016246,
"expireTime": "2026-06-22",
"contractSize": 100,
"contractMultiplier": 100,
"daysToExpiry": 21,
"intrinsicValue": 125.2,
"timeValue": 6.45,
"breakevenPoint": [460.44],
"distToBreakeven": [-5.24],
"probOfProfit": 0.315418,
"markPrice": 130.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
26
27
28
29
30
31
32
Futu::u32_t GetOptionQuote(const Qot_GetOptionQuote::Request &stReq);
virtual void OnReply_GetOptionQuote(Futu::u32_t nSerialNo, const Qot_GetOptionQuote::Response &stRsp) = 0;
Description
Get option combo snapshot quote. Pass the combo leg list
multi_legsin the request — typically obtained from themulti_legsfield returned by Get Option Strategy. For a single leg, one record matching that leg is returned; for multiple legs, one record aggregated per strategy is returned.Parameters
message C2S
{
repeated Qot_Common.ComboLeg multi_legs = 1; //Combo strategy contract leg list (actual leg qty = outer qty * leg.qty_ratio)
optional Qot_Common.QotHeader header = 100; //Common quote header
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
multi_legscan be obtained from themulti_legsreturned by Get Option Strategy
- Return
message OptionQuote
{
//--- Basic quote ---
optional double price = 1; //Latest price
optional double chg = 2; //Change
optional double chg_rate = 3; //Change rate (percent; e.g. 20 means 20%)
optional int64 vol = 4; //Volume
optional double turnover = 5; //Turnover
optional double high = 6; //High
optional double low = 7; //Low
optional double mid = 8; //Mid price (average of bid1 and ask1)
optional double open = 9; //Open
optional double pre_close = 10; //Previous close
//--- Derived quote ---
optional int32 open_interest = 11; //Open interest
optional double premium = 12; //Premium (percent)
optional double IV = 13; //Implied volatility (percent)
optional double delta = 14; //Delta
optional double gamma = 15; //Gamma
optional double vega = 16; //Vega
optional double theta = 17; //Theta
optional double rho = 18; //Rho
//--- Static contract attributes ---
optional int32 option_type = 19; //Qot_Common.OptionType, CALL/PUT
optional string expire_time = 20; //Expiration date
optional double strike = 21; //Strike price
optional double contract_size = 22; //Contract size
optional double contract_multiplier = 23; //Contract multiplier
optional int32 exercise_type = 24; //Qot_Common.OptionAreaType, exercise type (American/European/Bermudan)
optional int32 days_to_expiry = 25; //Days to expiry (negative means already expired)
optional int32 net_open_interest = 26; //Net open interest (HK options only)
optional double contract_value = 27; //Contract value (HK options only)
optional double equal_underlying = 28; //Equivalent underlying lot size (HK options only)
optional int32 index_option_type = 29; //Qot_Common.IndexOptionType, index option type
//--- Option-specific analytics ---
optional double intrinsic_value = 30; //Intrinsic value
optional double time_value = 31; //Time value
repeated double breakeven_point = 32; //Breakeven point list
repeated double dist_to_breakeven = 33; //Distances aligned 1:1 with breakeven_point
optional double prob_of_profit = 34; //Probability of profit
optional double seller_roi = 35; //Seller return on investment (percent)
optional double mark_price = 36; //Mark price
optional double leverage_ratio = 37; //Leverage ratio
optional double effective_gearing = 38; //Effective gearing
}
message S2C
{
repeated OptionQuote optionQuoteList = 1; //Option real-time quote list
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType, return result
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
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
- API call result structure: RetType
- OptionType enum: OptionType
- IndexOptionType enum: IndexOptionType
- 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;
// Build request
Qot_GetOptionQuote::Request req;
Qot_GetOptionQuote::C2S *c2s = req.mutable_c2s();
// Combo leg list (typically obtained from GetOptionStrategy's multi_legs)
Qot_Common::ComboLeg *leg = c2s->add_multi_legs();
Qot_Common::Security *sec = leg->mutable_security();
sec->set_market(Qot_Common::QotMarket::QotMarket_HK_Security);
sec->set_code("TCH260622C330000"); // Option code: Tencent Call, expires 2026-06-22, strike 330
leg->set_side(Trd_Common::TrdSide::TrdSide_Buy);
leg->set_qtyratio(1);
m_GetOptionQuoteSerialNo = m_pQotApi->GetOptionQuote(req);
cout << "Request GetOptionQuote SerialNo: " << m_GetOptionQuoteSerialNo << endl;
}
virtual void OnReply_GetOptionQuote(Futu::u32_t nSerialNo, const Qot_GetOptionQuote::Response &stRsp) {
if (nSerialNo != m_GetOptionQuoteSerialNo) return;
cout << "OnReply_GetOptionQuote SerialNo: " << nSerialNo << endl;
// Parse the internal structure and print
// ProtoBufToBodyData and UTF8ToLocal are defined in tool.h under Sample
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
FTAPI_Qot *m_pQotApi;
Futu::u32_t m_GetOptionQuoteSerialNo = 0;
};
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
74
- Output
connect
Request GetOptionQuote SerialNo: 3
OnReply_GetOptionQuote SerialNo: 3
{
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"optionQuoteList": [
{
"strike": 330,
"price": 131.65,
"chg": 0,
"chgRate": 0,
"delta": 0.974369,
"gamma": 0.000797,
"vega": 0.019825,
"theta": -0.785757,
"rho": 0.016246,
"expireTime": "2026-06-22",
"contractSize": 100,
"contractMultiplier": 100,
"daysToExpiry": 21,
"intrinsicValue": 125.2,
"timeValue": 6.45,
"breakevenPoint": [460.44],
"distToBreakeven": [-5.24],
"probOfProfit": 0.315418,
"markPrice": 130.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
26
27
28
29
30
31
32
33
GetOptionQuote(req);
Description
Get option combo snapshot quotes
Parameters
message C2S
{
repeated Qot_Common.ComboLeg multi_legs = 1; //Combo strategy leg list
optional Qot_Common.QotHeader header = 100; //Quote common header
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
- multiLegs can be obtained from the multiLegs returned by GetOptionStrategy
- Return
message OptionQuote
{
optional double price = 1; //Latest price
optional double chg = 2; //Change
optional double chg_rate = 3; //Change rate (percentage)
optional int64 vol = 4; //Volume
optional double turnover = 5; //Turnover
optional double high = 6; //Highest price
optional double low = 7; //Lowest price
optional double mid = 8; //Mid price
optional double open = 9; //Open price
optional double pre_close = 10; //Previous close
optional int32 open_interest = 11; //Open interest
optional double premium = 12; //Premium (percentage)
optional double IV = 13; //Implied volatility (percentage)
optional double delta = 14; //Delta
optional double gamma = 15; //Gamma
optional double vega = 16; //Vega
optional double theta = 17; //Theta
optional double rho = 18; //Rho
optional int32 option_type = 19; //OptionType, CALL/PUT
optional string expire_time = 20; //Expiry date
optional double strike = 21; //Strike price
optional double contract_size = 22; //Contract size
optional double contract_multiplier = 23; //Contract multiplier
optional int32 exercise_type = 24; //Exercise type
optional int32 days_to_expiry = 25; //Days to expiry
optional int32 net_open_interest = 26; //Net open interest
optional double contract_value = 27; //Contract value
optional double equal_underlying = 28; //Equivalent underlying lots
optional int32 index_option_type = 29; //Index option type
optional double intrinsic_value = 30; //Intrinsic value
optional double time_value = 31; //Time value
repeated double breakeven_point = 32; //Breakeven point list
repeated double dist_to_breakeven = 33; //Distance to breakeven point
optional double prob_of_profit = 34; //Probability of profit
optional double seller_roi = 35; //Seller ROI (percentage)
optional double mark_price = 36; //Mark price
optional double leverage_ratio = 37; //Leverage ratio
optional double effective_gearing = 38; //Effective gearing
}
message S2C
{
repeated OptionQuote optionQuoteList = 1; //Option realtime quote list
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType, return result
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
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
- API call result structure: 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 QotGetOptionQuote(){
const { RetType } = Common
const { QotMarket, OptionStrategyType } = 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) { // 登录成功
// 先获取期权策略,取其中一组组合腿
websocket.GetOptionStrategy({
c2s: {
owner: { market: QotMarket.QotMarket_HK_Security, code: "00700" },
optionStrategy: OptionStrategyType.OptionStrategyType_Straddle,
},
})
.then((res) => {
let { retType, s2c: { strategyList } } = res
if(retType == RetType.RetType_Succeed && strategyList.length > 0){
const req = {
c2s: {
multiLegs: strategyList[0].multiLegs,
},
};
websocket.GetOptionQuote(req)
.then((res) => {
let { errCode, retMsg, retType, s2c } = res
console.log("GetOptionQuote: 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);
});
}
})
.catch((error) => {
console.log("GetOptionStrategy error:", error);
});
} else {
console.log("start error", msg);
}
};
websocket.start(addr, port, enable_ssl, key);
//关闭行情连接,连接不再使用之后,要关闭,否则占用不必要资源
//同时OpenD也限制了最多128条连接
//也可以一个页面或者一个项目维护一条连接,这里范例请求一次创建一条连接
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
56
57
58
59
60
61
62
63
64
- Output
GetOptionQuote: errCode 0, retMsg , retType 0
{
"optionQuoteList": [{
"price": 131.65,
"chg": 0,
"chgRate": 0,
"delta": 0.974369,
"gamma": 0.000797,
"vega": 0.019825,
"theta": -0.785757,
"rho": 0.016246,
"expireTime": "2026-05-22",
"contractSize": 100,
"contractMultiplier": 100,
"daysToExpiry": 2,
"intrinsicValue": 125.2,
"timeValue": 6.45,
"breakevenPoint": [199.56, 460.44],
"distToBreakeven": [255.64, -5.24],
"probOfProfit": 0.315418,
"markPrice": 130.4
}]
}
stop
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
API Restrictions
- Maximum 120 requests per 30 seconds.
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_option_quote(combo_leg_list)
Description
Get option snapshot quotes from a combo leg list, suitable for multi-leg strategy batch quote queries.
Parameters
Parameter Type Description combo_leg_list list Combo leg list Elements are OptionStrategyLeg; structure see get_option_strategyReturn
Parameter Type Description ret RET_CODE API call result data pd.DataFrame When ret == RET_OK, returns option snapshot data str When ret != RET_OK, returns error description DataFrame fields:
Field Type Description price float Combo price change_val float Change value change_rate float Change rate volume str Volume turnover str Turnover high_price str High price low_price str Low price mid_price str Mid price open_price str Open price last_close_price float Last close price open_interest str Open interest premium str Premium implied_volatility str Implied volatility delta float Delta gamma float Gamma vega float Vega theta float Theta rho float Rho option_type str Option type expire_time str Expiration date strike_price str Strike price contract_size float Contract size contract_multiplier float Contract multiplier exercise_type str Exercise type days_to_expiry int Days to expiry net_open_interest str Net open interest contract_value str Contract value equal_underlying str Equivalent underlying index_option_type str Index option type intrinsic_value float Intrinsic value time_value float Time value breakeven_point list Breakeven points dist_to_breakeven list Distance to breakeven prob_of_profit float Probability of profit This field is in percentage form, so 20 is equivalent to 20%.seller_roi str Seller ROI This field is in percentage form, so 20 is equivalent to 20%.mark_price float Mark price leverage_ratio str Leverage ratio effective_gearing str Effective gearing
Example
from moomoo import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data = quote_ctx.get_option_strategy(code='HK.00700', option_strategy=OptionStrategyType.STRADDLE)
if ret == RET_OK:
index=0
print(data['legs'][index])
ret2,data2 = quote_ctx.get_option_quote(data['legs'][index])
if ret2 == RET_OK:
print(data2)
else:
print("get_analysis,error:",data2)
else:
print('error:', data)
quote_ctx.close() # Remember to close the connection to avoid exhausting connection quota
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
- Output
[OptionStrategyLeg(code=HK.TCH260522P330000, action=BUY, quantity=1.0), OptionStrategyLeg(code=HK.TCH260522C330000, action=BUY, quantity=1.0)]
price change_val change_rate volume turnover high_price low_price mid_price open_price last_close_price open_interest premium implied_volatility delta gamma vega theta rho option_type expire_time strike_price contract_size contract_multiplier exercise_type days_to_expiry net_open_interest contract_value equal_underlying index_option_type intrinsic_value time_value breakeven_point dist_to_breakeven prob_of_profit seller_roi mark_price leverage_ratio effective_gearing
0 131.65 0.0 0.0 N/A N/A N/A N/A N/A N/A 131.65 N/A N/A N/A 0.974369 0.000797 0.019825 -0.785757 0.016246 N/A 2026-05-22 N/A 100.0 100.0 N/A 2 N/A N/A N/A N/A 125.2 6.45 [199.56, 460.44] [255.64, -5.240000000000009] 0.315418 N/A 130.4 N/A N/A
2
3
# Qot_GetOptionQuote.proto
Description
Get option combo snapshot quotes
Parameters
message C2S
{
repeated OptionStrategyLeg comboLegList = 1; // Combo leg list
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
- Combo leg structure: OptionStrategyLeg
- Return
message S2C
{
// Option snapshot list; fields per protocol definition
}
message Response
{
required int32 retType = 1 [default = -400]; // Return result,详见 Common.RetType
optional string retMsg = 2; // Return result description
optional int32 errCode = 3; // Error code
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
- API call result structure: RetType
- OptionType enum: OptionType
- IndexOptionType enum: IndexOptionType
uint GetOptionQuote(QotGetOptionQuote.Request req);
virtual void OnReply_GetOptionQuote(MMAPI_Conn client, uint nSerialNo, QotGetOptionQuote.Response rsp);
Description
Get option combo snapshot quotes. Pass multi_legs in the request; they can be obtained from GetOptionStrategy. A single leg returns one quote; multiple legs return one aggregated strategy quote.
Parameters
message C2S
{
repeated Qot_Common.ComboLeg multi_legs = 1;
optional Qot_Common.QotHeader header = 100;
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
- multi_legs can be obtained from GetOptionStrategy
- Return
message OptionQuote
{
optional double price = 1;
optional double chg = 2;
optional double chg_rate = 3;
optional int64 vol = 4;
optional double turnover = 5;
optional double high = 6;
optional double low = 7;
optional double mid = 8;
optional double open = 9;
optional double pre_close = 10;
optional int32 open_interest = 11;
optional double premium = 12;
optional double IV = 13;
optional double delta = 14;
optional double gamma = 15;
optional double vega = 16;
optional double theta = 17;
optional double rho = 18;
optional int32 option_type = 19;
optional string expire_time = 20;
optional double strike = 21;
optional double contract_size = 22;
optional double contract_multiplier = 23;
optional int32 exercise_type = 24;
optional int32 days_to_expiry = 25;
optional int32 net_open_interest = 26;
optional double contract_value = 27;
optional double equal_underlying = 28;
optional int32 index_option_type = 29;
optional double intrinsic_value = 30;
optional double time_value = 31;
repeated double breakeven_point = 32;
repeated double dist_to_breakeven = 33;
optional double prob_of_profit = 34;
optional double seller_roi = 35;
optional double mark_price = 36;
optional double leverage_ratio = 37;
optional double effective_gearing = 38;
}
message S2C
{
repeated OptionQuote optionQuoteList = 1;
}
message Response
{
required int32 retType = 1 [default = -400];
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
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
- 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.ComboLeg leg = QotCommon.ComboLeg.CreateBuilder()
.SetSecurity(QotCommon.Security.CreateBuilder()
.SetMarket((int)QotCommon.QotMarket.QotMarket_HK_Security)
.SetCode("TCH260622C330000")
.Build())
.SetSide((int)TrdCommon.TrdSide.TrdSide_Buy)
.SetQtyRatio(1)
.Build();
QotGetOptionQuote.C2S c2s = QotGetOptionQuote.C2S.CreateBuilder()
.AddMultiLegs(leg)
.Build();
QotGetOptionQuote.Request req = QotGetOptionQuote.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetOptionQuote(req);
Console.Write("Send QotGetOptionQuote: {0}\n", seqNo);
}
public void OnDisconnect(MMAPI_Conn client, long errCode)
{
Console.Write("Qot onDisConnect: {0}\n", errCode);
}
public void OnReply_GetOptionQuote(MMAPI_Conn client, uint nSerialNo, QotGetOptionQuote.Response rsp)
{
Console.Write("Reply: QotGetOptionQuote: {0} {1}\n", nSerialNo, rsp.ToString());
}
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
58
59
60
- Output
Qot onInitConnect: ret=0 desc= connID=7459213669204006063
Send QotGetOptionQuote: 3
Reply: QotGetOptionQuote: 3 retType: 0 ...
2
3
int getOptionQuote(QotGetOptionQuote.Request req);
void onReply_GetOptionQuote(MMAPI_Conn client, int nSerialNo, QotGetOptionQuote.Response rsp);
Description
Get option combo snapshot quotes. Pass multi_legs in the request; they can be obtained from GetOptionStrategy. A single leg returns one quote; multiple legs return one aggregated strategy quote.
Parameters
message C2S
{
repeated Qot_Common.ComboLeg multi_legs = 1;
optional Qot_Common.QotHeader header = 100;
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
- multi_legs can be obtained from GetOptionStrategy
- Return
message OptionQuote
{
optional double price = 1;
optional double chg = 2;
optional double chg_rate = 3;
optional int64 vol = 4;
optional double turnover = 5;
optional double high = 6;
optional double low = 7;
optional double mid = 8;
optional double open = 9;
optional double pre_close = 10;
optional int32 open_interest = 11;
optional double premium = 12;
optional double IV = 13;
optional double delta = 14;
optional double gamma = 15;
optional double vega = 16;
optional double theta = 17;
optional double rho = 18;
optional int32 option_type = 19;
optional string expire_time = 20;
optional double strike = 21;
optional double contract_size = 22;
optional double contract_multiplier = 23;
optional int32 exercise_type = 24;
optional int32 days_to_expiry = 25;
optional int32 net_open_interest = 26;
optional double contract_value = 27;
optional double equal_underlying = 28;
optional int32 index_option_type = 29;
optional double intrinsic_value = 30;
optional double time_value = 31;
repeated double breakeven_point = 32;
repeated double dist_to_breakeven = 33;
optional double prob_of_profit = 34;
optional double seller_roi = 35;
optional double mark_price = 36;
optional double leverage_ratio = 37;
optional double effective_gearing = 38;
}
message S2C
{
repeated OptionQuote optionQuoteList = 1;
}
message Response
{
required int32 retType = 1 [default = -400];
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
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
- 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.ComboLeg leg = QotCommon.ComboLeg.newBuilder()
.setSecurity(QotCommon.Security.newBuilder()
.setMarket(QotCommon.QotMarket.QotMarket_HK_Security_VALUE)
.setCode("TCH260622C330000")
.build())
.setSide(TrdCommon.TrdSide.TrdSide_Buy_VALUE)
.setQtyRatio(1)
.build();
QotGetOptionQuote.C2S c2s = QotGetOptionQuote.C2S.newBuilder()
.addMultiLegs(leg)
.build();
QotGetOptionQuote.Request req = QotGetOptionQuote.Request.newBuilder().setC2S(c2s).build();
int seqNo = qot.getOptionQuote(req);
System.out.printf("Send QotGetOptionQuote: %d\n", seqNo);
}
@Override
public void onDisconnect(MMAPI_Conn client, long errCode) {
System.out.printf("Qot onDisConnect: %d\n", errCode);
}
@Override
public void onReply_GetOptionQuote(MMAPI_Conn client, int nSerialNo, QotGetOptionQuote.Response rsp) {
if (rsp.getRetType() != 0) {
System.out.printf("QotGetOptionQuote failed: %s\n", rsp.getRetMsg());
}
else {
try {
String json = JsonFormat.printer().print(rsp);
System.out.printf("Receive QotGetOptionQuote: %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
69
70
- Output
Qot onInitConnect: ret=0 desc= connID=7459213669204006063
Send QotGetOptionQuote: 2
Receive QotGetOptionQuote: {
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"optionQuoteList": [
{
"strike": 330,
"price": 131.65,
"chg": 0,
"chgRate": 0,
"delta": 0.974369,
"gamma": 0.000797,
"vega": 0.019825,
"theta": -0.785757,
"rho": 0.016246,
"expireTime": "2026-06-22",
"contractSize": 100,
"contractMultiplier": 100,
"daysToExpiry": 21,
"intrinsicValue": 125.2,
"timeValue": 6.45,
"breakevenPoint": [460.44],
"distToBreakeven": [-5.24],
"probOfProfit": 0.315418,
"markPrice": 130.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
26
27
28
29
30
31
32
moomoo::u32_t GetOptionQuote(const Qot_GetOptionQuote::Request &stReq);
virtual void OnReply_GetOptionQuote(moomoo::u32_t nSerialNo, const Qot_GetOptionQuote::Response &stRsp) = 0;
Description
Get option combo snapshot quote. Pass the combo leg list
multi_legsin the request — typically obtained from themulti_legsfield returned by Get Option Strategy. For a single leg, one record matching that leg is returned; for multiple legs, one record aggregated per strategy is returned.Parameters
message C2S
{
repeated Qot_Common.ComboLeg multi_legs = 1; //Combo strategy contract leg list (actual leg qty = outer qty * leg.qty_ratio)
optional Qot_Common.QotHeader header = 100; //Common quote header
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
multi_legscan be obtained from themulti_legsreturned by Get Option Strategy
- Return
message OptionQuote
{
//--- Basic quote ---
optional double price = 1; //Latest price
optional double chg = 2; //Change
optional double chg_rate = 3; //Change rate (percent; e.g. 20 means 20%)
optional int64 vol = 4; //Volume
optional double turnover = 5; //Turnover
optional double high = 6; //High
optional double low = 7; //Low
optional double mid = 8; //Mid price (average of bid1 and ask1)
optional double open = 9; //Open
optional double pre_close = 10; //Previous close
//--- Derived quote ---
optional int32 open_interest = 11; //Open interest
optional double premium = 12; //Premium (percent)
optional double IV = 13; //Implied volatility (percent)
optional double delta = 14; //Delta
optional double gamma = 15; //Gamma
optional double vega = 16; //Vega
optional double theta = 17; //Theta
optional double rho = 18; //Rho
//--- Static contract attributes ---
optional int32 option_type = 19; //Qot_Common.OptionType, CALL/PUT
optional string expire_time = 20; //Expiration date
optional double strike = 21; //Strike price
optional double contract_size = 22; //Contract size
optional double contract_multiplier = 23; //Contract multiplier
optional int32 exercise_type = 24; //Qot_Common.OptionAreaType, exercise type (American/European/Bermudan)
optional int32 days_to_expiry = 25; //Days to expiry (negative means already expired)
optional int32 net_open_interest = 26; //Net open interest (HK options only)
optional double contract_value = 27; //Contract value (HK options only)
optional double equal_underlying = 28; //Equivalent underlying lot size (HK options only)
optional int32 index_option_type = 29; //Qot_Common.IndexOptionType, index option type
//--- Option-specific analytics ---
optional double intrinsic_value = 30; //Intrinsic value
optional double time_value = 31; //Time value
repeated double breakeven_point = 32; //Breakeven point list
repeated double dist_to_breakeven = 33; //Distances aligned 1:1 with breakeven_point
optional double prob_of_profit = 34; //Probability of profit
optional double seller_roi = 35; //Seller return on investment (percent)
optional double mark_price = 36; //Mark price
optional double leverage_ratio = 37; //Leverage ratio
optional double effective_gearing = 38; //Effective gearing
}
message S2C
{
repeated OptionQuote optionQuoteList = 1; //Option real-time quote list
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType, return result
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
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
- API call result structure: RetType
- OptionType enum: OptionType
- IndexOptionType enum: IndexOptionType
- 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;
// Build request
Qot_GetOptionQuote::Request req;
Qot_GetOptionQuote::C2S *c2s = req.mutable_c2s();
// Combo leg list (typically obtained from GetOptionStrategy's multi_legs)
Qot_Common::ComboLeg *leg = c2s->add_multi_legs();
Qot_Common::Security *sec = leg->mutable_security();
sec->set_market(Qot_Common::QotMarket::QotMarket_HK_Security);
sec->set_code("TCH260622C330000"); // Option code: Tencent Call, expires 2026-06-22, strike 330
leg->set_side(Trd_Common::TrdSide::TrdSide_Buy);
leg->set_qtyratio(1);
m_GetOptionQuoteSerialNo = m_pQotApi->GetOptionQuote(req);
cout << "Request GetOptionQuote SerialNo: " << m_GetOptionQuoteSerialNo << endl;
}
virtual void OnReply_GetOptionQuote(moomoo::u32_t nSerialNo, const Qot_GetOptionQuote::Response &stRsp) {
if (nSerialNo != m_GetOptionQuoteSerialNo) return;
cout << "OnReply_GetOptionQuote SerialNo: " << nSerialNo << endl;
// Parse the internal structure and print
// ProtoBufToBodyData and UTF8ToLocal are defined in tool.h under Sample
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
MMAPI_Qot *m_pQotApi;
moomoo::u32_t m_GetOptionQuoteSerialNo = 0;
};
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
74
- Output
connect
Request GetOptionQuote SerialNo: 3
OnReply_GetOptionQuote SerialNo: 3
{
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"optionQuoteList": [
{
"strike": 330,
"price": 131.65,
"chg": 0,
"chgRate": 0,
"delta": 0.974369,
"gamma": 0.000797,
"vega": 0.019825,
"theta": -0.785757,
"rho": 0.016246,
"expireTime": "2026-06-22",
"contractSize": 100,
"contractMultiplier": 100,
"daysToExpiry": 21,
"intrinsicValue": 125.2,
"timeValue": 6.45,
"breakevenPoint": [460.44],
"distToBreakeven": [-5.24],
"probOfProfit": 0.315418,
"markPrice": 130.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
26
27
28
29
30
31
32
33
GetOptionQuote(req);
Description
Get option combo snapshot quotes
Parameters
message C2S
{
repeated Qot_Common.ComboLeg multi_legs = 1; //Combo strategy leg list
optional Qot_Common.QotHeader header = 100; //Quote common header
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
- multiLegs can be obtained from the multiLegs returned by GetOptionStrategy
- Return
message OptionQuote
{
optional double price = 1; //Latest price
optional double chg = 2; //Change
optional double chg_rate = 3; //Change rate (percentage)
optional int64 vol = 4; //Volume
optional double turnover = 5; //Turnover
optional double high = 6; //Highest price
optional double low = 7; //Lowest price
optional double mid = 8; //Mid price
optional double open = 9; //Open price
optional double pre_close = 10; //Previous close
optional int32 open_interest = 11; //Open interest
optional double premium = 12; //Premium (percentage)
optional double IV = 13; //Implied volatility (percentage)
optional double delta = 14; //Delta
optional double gamma = 15; //Gamma
optional double vega = 16; //Vega
optional double theta = 17; //Theta
optional double rho = 18; //Rho
optional int32 option_type = 19; //OptionType, CALL/PUT
optional string expire_time = 20; //Expiry date
optional double strike = 21; //Strike price
optional double contract_size = 22; //Contract size
optional double contract_multiplier = 23; //Contract multiplier
optional int32 exercise_type = 24; //Exercise type
optional int32 days_to_expiry = 25; //Days to expiry
optional int32 net_open_interest = 26; //Net open interest
optional double contract_value = 27; //Contract value
optional double equal_underlying = 28; //Equivalent underlying lots
optional int32 index_option_type = 29; //Index option type
optional double intrinsic_value = 30; //Intrinsic value
optional double time_value = 31; //Time value
repeated double breakeven_point = 32; //Breakeven point list
repeated double dist_to_breakeven = 33; //Distance to breakeven point
optional double prob_of_profit = 34; //Probability of profit
optional double seller_roi = 35; //Seller ROI (percentage)
optional double mark_price = 36; //Mark price
optional double leverage_ratio = 37; //Leverage ratio
optional double effective_gearing = 38; //Effective gearing
}
message S2C
{
repeated OptionQuote optionQuoteList = 1; //Option realtime quote list
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType, return result
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
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
- API call result structure: 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 QotGetOptionQuote(){
const { RetType } = Common
const { QotMarket, OptionStrategyType } = 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) { // 登录成功
// 先获取期权策略,取其中一组组合腿
websocket.GetOptionStrategy({
c2s: {
owner: { market: QotMarket.QotMarket_HK_Security, code: "00700" },
optionStrategy: OptionStrategyType.OptionStrategyType_Straddle,
},
})
.then((res) => {
let { retType, s2c: { strategyList } } = res
if(retType == RetType.RetType_Succeed && strategyList.length > 0){
const req = {
c2s: {
multiLegs: strategyList[0].multiLegs,
},
};
websocket.GetOptionQuote(req)
.then((res) => {
let { errCode, retMsg, retType, s2c } = res
console.log("GetOptionQuote: 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);
});
}
})
.catch((error) => {
console.log("GetOptionStrategy error:", error);
});
} else {
console.log("start error", msg);
}
};
websocket.start(addr, port, enable_ssl, key);
//关闭行情连接,连接不再使用之后,要关闭,否则占用不必要资源
//同时OpenD也限制了最多128条连接
//也可以一个页面或者一个项目维护一条连接,这里范例请求一次创建一条连接
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
56
57
58
59
60
61
62
63
64
- Output
GetOptionQuote: errCode 0, retMsg , retType 0
{
"optionQuoteList": [{
"price": 131.65,
"chg": 0,
"chgRate": 0,
"delta": 0.974369,
"gamma": 0.000797,
"vega": 0.019825,
"theta": -0.785757,
"rho": 0.016246,
"expireTime": "2026-05-22",
"contractSize": 100,
"contractMultiplier": 100,
"daysToExpiry": 2,
"intrinsicValue": 125.2,
"timeValue": 6.45,
"breakevenPoint": [199.56, 460.44],
"distToBreakeven": [255.64, -5.24],
"probOfProfit": 0.315418,
"markPrice": 130.4
}]
}
stop
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
API Restrictions
- Maximum 120 requests per 30 seconds.