# 期權市場統計
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_option_market_statistic(option_market, data_type, begin_time=None, end_time=None, page_req_key=None)
介紹
獲取期權市場統計數據(成交量/持倉量),按交易日粒度返回看漲、看跌及合計值,支持分頁拉取。
參數
參數 類型 說明 option_market OptionMarket 期權市場類型 US_SECURITY=美股股票期權、US_INDEX=美股指數期權、HK_SECURITY=港股股票期權、HK_INDEX=港股指數期權data_type OptionStatisticDataType 數據類型 VOLUME=成交量、OPEN_INTEREST=持倉量begin_time str 開始日期,格式 'YYYY-MM-DD' 不傳默認取近一年數據end_time str 結束日期,格式 'YYYY-MM-DD' 與 begin_time 跨度不超過一年page_req_key bytes 分頁請求 key 首次傳 None,續拉傳上次返回值返回
參數 類型 說明 ret RET_CODE 接口調用結果 data pandas.DataFrame 當 ret == RET_OK,返回統計數據 str 當 ret != RET_OK,返回錯誤描述 page_req_key bytes 下一頁 key,None 表示無更多數據 返回 DataFrame 字段:
字段 類型 說明 time str 交易日時間字符串 timestamp float 交易日時間戳(Unix 秒) call_value int 看漲期權合計值 put_value int 看跌期權合計值 total_value int 總值(call_value + put_value) ratio float Put/Call 比值 call_value 為 0 時為 N/A
Example
from futu import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data, page_req_key = quote_ctx.get_option_market_statistic(
OptionMarket.US_SECURITY,
OptionStatisticDataType.VOLUME,
begin_time='2026-06-01',
end_time='2026-06-15'
)
if ret == RET_OK:
print(data)
else:
print('error:', data)
quote_ctx.close()
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
- Output
time timestamp call_value put_value total_value ratio
0 2026-06-12 1.781237e+09 45658870 28723978 74382848 0.629100
1 2026-06-11 1.781150e+09 38303062 30520043 68823105 0.796804
2 2026-06-10 1.781064e+09 35371830 30180004 65551834 0.853221
3 2026-06-09 1.780978e+09 42880655 36646152 79526807 0.854608
4 2026-06-08 1.780891e+09 35442266 25811533 61253799 0.728270
5 2026-06-05 1.780632e+09 52362998 44023321 96386319 0.840733
6 2026-06-04 1.780546e+09 38082169 24572137 62654306 0.645240
7 2026-06-03 1.780459e+09 36858233 23035404 59893637 0.624973
8 2026-06-02 1.780373e+09 36822706 21026201 57848907 0.571012
9 2026-06-01 1.780286e+09 42932185 24084036 67016221 0.560979
2
3
4
5
6
7
8
9
10
11
# Qot_GetOptionMarketStatistic.proto
介紹
獲取期權市場統計數據
參數
message C2S
{
required int32 optionMarket = 1; //Qot_OptionCommon.OptionMarket,期權市場類型
required int32 dataType = 2; //Qot_OptionCommon.OptionStatisticDataType,數據類型(成交量或持倉量)
required string beginTime = 3; //開始時間字符串
required string endTime = 4; //結束時間字符串,時間跨度超過一年時自動分頁
optional bytes nextPageKey = 5; //分頁請求的key,首頁不填,續頁填入上一頁返回的nextPageKey
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
- 返回
//每日統計數據
message StatisticItem
{
required string time = 1; //交易日時間字符串
optional double timestamp = 2; //交易日時間戳
required int64 callValue = 3; //看漲期權合計值(成交量或持倉量,由請求的dataType決定)
required int64 putValue = 4; //看跌期權合計值
optional int64 totalValue = 5; //總值(callValue + putValue)
optional double ratio = 6; //Put/Call比值(callValue爲0時不設置)
}
message S2C
{
required int32 optionMarket = 1; //Qot_OptionCommon.OptionMarket,期權市場類型
required int32 dataType = 2; //Qot_OptionCommon.OptionStatisticDataType,數據類型
repeated StatisticItem statisticList = 3; //統計數據列表,按交易日降序排列
optional bytes nextPageKey = 4; //分頁請求的key,有值表示還有更多數據
}
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
26
- 接口調用結果,結構參見 RetType
協議 ID
3301
uint GetOptionMarketStatistic(Qot_GetOptionMarketStatistic.Request req); virtual void OnReply_GetOptionMarketStatistic(FTAPI_Conn client, uint nSerialNo, Qot_GetOptionMarketStatistic.Response rsp);
介紹
獲取期權市場統計數據
參數
message C2S
{
required int32 optionMarket = 1; //Qot_OptionCommon.OptionMarket,期權市場類型
required int32 dataType = 2; //Qot_OptionCommon.OptionStatisticDataType,數據類型(成交量或持倉量)
required string beginTime = 3; //開始時間字符串
required string endTime = 4; //結束時間字符串,時間跨度超過一年時自動分頁
optional bytes nextPageKey = 5; //分頁請求的key,首頁不填,續頁填入上一頁返回的nextPageKey
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
- 返回
//每日統計數據
message StatisticItem
{
required string time = 1; //交易日時間字符串
optional double timestamp = 2; //交易日時間戳
required int64 callValue = 3; //看漲期權合計值(成交量或持倉量,由請求的dataType決定)
required int64 putValue = 4; //看跌期權合計值
optional int64 totalValue = 5; //總值(callValue + putValue)
optional double ratio = 6; //Put/Call比值(callValue爲0時不設置)
}
message S2C
{
required int32 optionMarket = 1; //Qot_OptionCommon.OptionMarket,期權市場類型
required int32 dataType = 2; //Qot_OptionCommon.OptionStatisticDataType,數據類型
repeated StatisticItem statisticList = 3; //統計數據列表,按交易日降序排列
optional bytes nextPageKey = 4; //分頁請求的key,有值表示還有更多數據
}
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
26
- 接口調用結果,結構參見 RetType
協議 ID
3301
int getOptionMarketStatistic(Qot_GetOptionMarketStatistic.Request req) onReply_GetOptionMarketStatistic(FTAPI_Conn client, int nSerialNo, Qot_GetOptionMarketStatistic.Response rsp)
介紹
獲取期權市場統計數據
參數
message C2S
{
required int32 optionMarket = 1; //Qot_OptionCommon.OptionMarket,期權市場類型
required int32 dataType = 2; //Qot_OptionCommon.OptionStatisticDataType,數據類型(成交量或持倉量)
required string beginTime = 3; //開始時間字符串
required string endTime = 4; //結束時間字符串,時間跨度超過一年時自動分頁
optional bytes nextPageKey = 5; //分頁請求的key,首頁不填,續頁填入上一頁返回的nextPageKey
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
- 返回
//每日統計數據
message StatisticItem
{
required string time = 1; //交易日時間字符串
optional double timestamp = 2; //交易日時間戳
required int64 callValue = 3; //看漲期權合計值(成交量或持倉量,由請求的dataType決定)
required int64 putValue = 4; //看跌期權合計值
optional int64 totalValue = 5; //總值(callValue + putValue)
optional double ratio = 6; //Put/Call比值(callValue爲0時不設置)
}
message S2C
{
required int32 optionMarket = 1; //Qot_OptionCommon.OptionMarket,期權市場類型
required int32 dataType = 2; //Qot_OptionCommon.OptionStatisticDataType,數據類型
repeated StatisticItem statisticList = 3; //統計數據列表,按交易日降序排列
optional bytes nextPageKey = 4; //分頁請求的key,有值表示還有更多數據
}
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
26
- 接口調用結果,結構參見 RetType
協議 ID
3301
Futu::u32_t GetOptionMarketStatistic(const Qot_GetOptionMarketStatistic::Request &stReq);
virtual void OnReply_GetOptionMarketStatistic(Futu::u32_t nSerialNo, const Qot_GetOptionMarketStatistic::Response &stRsp) = 0;
介紹
獲取期權市場統計數據
參數
message C2S
{
required int32 optionMarket = 1; //Qot_OptionCommon.OptionMarket,期權市場類型
required int32 dataType = 2; //Qot_OptionCommon.OptionStatisticDataType,數據類型(成交量或持倉量)
required string beginTime = 3; //開始時間字符串
required string endTime = 4; //結束時間字符串,時間跨度超過一年時自動分頁
optional bytes nextPageKey = 5; //分頁請求的key,首頁不填,續頁填入上一頁返回的nextPageKey
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
- 返回
//每日統計數據
message StatisticItem
{
required string time = 1; //交易日時間字符串
optional double timestamp = 2; //交易日時間戳
required int64 callValue = 3; //看漲期權合計值(成交量或持倉量,由請求的dataType決定)
required int64 putValue = 4; //看跌期權合計值
optional int64 totalValue = 5; //總值(callValue + putValue)
optional double ratio = 6; //Put/Call比值(callValue爲0時不設置)
}
message S2C
{
required int32 optionMarket = 1; //Qot_OptionCommon.OptionMarket,期權市場類型
required int32 dataType = 2; //Qot_OptionCommon.OptionStatisticDataType,數據類型
repeated StatisticItem statisticList = 3; //統計數據列表,按交易日降序排列
optional bytes nextPageKey = 4; //分頁請求的key,有值表示還有更多數據
}
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
26
- 接口調用結果,結構參見 RetType
協議 ID
3301
Example
class Program : public FTSPI_Qot, 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) {
Qot_GetOptionMarketStatistic::Request req;
Qot_GetOptionMarketStatistic::C2S *c2s = req.mutable_c2s();
// TODO: 按 proto 填充 c2s 字段
m_GetOptionMarketStatisticSerialNo = m_pQotApi->GetOptionMarketStatistic(req);
}
virtual void OnReply_GetOptionMarketStatistic(Futu::u32_t nSerialNo, const Qot_GetOptionMarketStatistic::Response &stRsp) {
if (nSerialNo != m_GetOptionMarketStatisticSerialNo) return;
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
FTAPI_Qot *m_pQotApi;
Futu::u32_t m_GetOptionMarketStatisticSerialNo = 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
getOptionMarketStatistic(qotGetOptionMarketStatistic)
介紹
獲取期權市場統計數據
參數
message C2S
{
required int32 optionMarket = 1; //Qot_OptionCommon.OptionMarket,期權市場類型
required int32 dataType = 2; //Qot_OptionCommon.OptionStatisticDataType,數據類型(成交量或持倉量)
required string beginTime = 3; //開始時間字符串
required string endTime = 4; //結束時間字符串,時間跨度超過一年時自動分頁
optional bytes nextPageKey = 5; //分頁請求的key,首頁不填,續頁填入上一頁返回的nextPageKey
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
- 返回
//每日統計數據
message StatisticItem
{
required string time = 1; //交易日時間字符串
optional double timestamp = 2; //交易日時間戳
required int64 callValue = 3; //看漲期權合計值(成交量或持倉量,由請求的dataType決定)
required int64 putValue = 4; //看跌期權合計值
optional int64 totalValue = 5; //總值(callValue + putValue)
optional double ratio = 6; //Put/Call比值(callValue爲0時不設置)
}
message S2C
{
required int32 optionMarket = 1; //Qot_OptionCommon.OptionMarket,期權市場類型
required int32 dataType = 2; //Qot_OptionCommon.OptionStatisticDataType,數據類型
repeated StatisticItem statisticList = 3; //統計數據列表,按交易日降序排列
optional bytes nextPageKey = 4; //分頁請求的key,有值表示還有更多數據
}
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
26
- 接口調用結果,結構參見 RetType
協議 ID
3301
Example
import ftWebsocket from "futu-api";
import { Common, Qot_OptionCommon } from "futu-api/proto";
import beautify from "js-beautify";
function QotGetOptionMarketStatistic(){
const { RetType } = Common
const { OptionMarket, OptionStatisticDataType } = Qot_OptionCommon
let [addr, port, enable_ssl, key] = ["127.0.0.1", 11112, false, ''];
let websocket = new ftWebsocket();
websocket.onlogin = (ret, msg)=>{
if (ret) {
const req = {
c2s: {
optionMarket: OptionMarket.OptionMarket_US_Security,
dataType: OptionStatisticDataType.OptionStatisticDataType_Volume,
beginTime: '2026-06-01',
endTime: '2026-06-15',
},
};
websocket.GetOptionMarketStatistic(req)
.then((res)=>{
let { errCode, retMsg, retType, s2c } = res
console.log("GetOptionMarketStatistic: 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("start error", msg);
}
};
websocket.start(addr, port, enable_ssl, key);
setTimeout(()=>{ websocket.stop(); process.exit(); }, 5000);
}
QotGetOptionMarketStatistic()
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
- Output
GetOptionMarketStatistic: errCode 0, retMsg , retType 0
{
"optionMarket": 1,
"dataType": 0,
"statisticList": [
{
"time": "2026-06-12",
"timestamp": 1781237000,
"callValue": 45658870,
"putValue": 28723978,
"totalValue": 74382848,
"ratio": 0.6291
},
{
"time": "2026-06-11",
"timestamp": 1781150000,
"callValue": 38303062,
"putValue": 30520043,
"totalValue": 68823105,
"ratio": 0.796804
},
{
"time": "2026-06-10",
"timestamp": 1781064000,
"callValue": 35371830,
"putValue": 30180004,
"totalValue": 65551834,
"ratio": 0.853221
}
]
}
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
接口限制
- 30 秒內最多請求 60 次期權市場統計接口(支持分頁的接口,僅首次調用納入統計)
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_option_market_statistic(option_market, data_type, begin_time=None, end_time=None, page_req_key=None)
介紹
獲取期權市場統計數據(成交量/持倉量),按交易日粒度返回看漲、看跌及合計值,支持分頁拉取。
參數
參數 類型 說明 option_market OptionMarket 期權市場類型 US_SECURITY=美股股票期權、US_INDEX=美股指數期權、HK_SECURITY=港股股票期權、HK_INDEX=港股指數期權data_type OptionStatisticDataType 數據類型 VOLUME=成交量、OPEN_INTEREST=持倉量begin_time str 開始日期,格式 'YYYY-MM-DD' 不傳默認取近一年數據end_time str 結束日期,格式 'YYYY-MM-DD' 與 begin_time 跨度不超過一年page_req_key bytes 分頁請求 key 首次傳 None,續拉傳上次返回值返回
參數 類型 說明 ret RET_CODE 接口調用結果 data pandas.DataFrame 當 ret == RET_OK,返回統計數據 str 當 ret != RET_OK,返回錯誤描述 page_req_key bytes 下一頁 key,None 表示無更多數據 返回 DataFrame 字段:
字段 類型 說明 time str 交易日時間字符串 timestamp float 交易日時間戳(Unix 秒) call_value int 看漲期權合計值 put_value int 看跌期權合計值 total_value int 總值(call_value + put_value) ratio float Put/Call 比值 call_value 為 0 時為 N/A
Example
from moomoo import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data, page_req_key = quote_ctx.get_option_market_statistic(
OptionMarket.US_SECURITY,
OptionStatisticDataType.VOLUME,
begin_time='2026-06-01',
end_time='2026-06-15'
)
if ret == RET_OK:
print(data)
else:
print('error:', data)
quote_ctx.close()
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
- Output
time timestamp call_value put_value total_value ratio
0 2026-06-12 1.781237e+09 45658870 28723978 74382848 0.629100
1 2026-06-11 1.781150e+09 38303062 30520043 68823105 0.796804
2 2026-06-10 1.781064e+09 35371830 30180004 65551834 0.853221
3 2026-06-09 1.780978e+09 42880655 36646152 79526807 0.854608
4 2026-06-08 1.780891e+09 35442266 25811533 61253799 0.728270
5 2026-06-05 1.780632e+09 52362998 44023321 96386319 0.840733
6 2026-06-04 1.780546e+09 38082169 24572137 62654306 0.645240
7 2026-06-03 1.780459e+09 36858233 23035404 59893637 0.624973
8 2026-06-02 1.780373e+09 36822706 21026201 57848907 0.571012
9 2026-06-01 1.780286e+09 42932185 24084036 67016221 0.560979
2
3
4
5
6
7
8
9
10
11
# Qot_GetOptionMarketStatistic.proto
介紹
獲取期權市場統計數據
參數
message C2S
{
required int32 optionMarket = 1; //Qot_OptionCommon.OptionMarket,期權市場類型
required int32 dataType = 2; //Qot_OptionCommon.OptionStatisticDataType,數據類型(成交量或持倉量)
required string beginTime = 3; //開始時間字符串
required string endTime = 4; //結束時間字符串,時間跨度超過一年時自動分頁
optional bytes nextPageKey = 5; //分頁請求的key,首頁不填,續頁填入上一頁返回的nextPageKey
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
- 返回
//每日統計數據
message StatisticItem
{
required string time = 1; //交易日時間字符串
optional double timestamp = 2; //交易日時間戳
required int64 callValue = 3; //看漲期權合計值(成交量或持倉量,由請求的dataType決定)
required int64 putValue = 4; //看跌期權合計值
optional int64 totalValue = 5; //總值(callValue + putValue)
optional double ratio = 6; //Put/Call比值(callValue爲0時不設置)
}
message S2C
{
required int32 optionMarket = 1; //Qot_OptionCommon.OptionMarket,期權市場類型
required int32 dataType = 2; //Qot_OptionCommon.OptionStatisticDataType,數據類型
repeated StatisticItem statisticList = 3; //統計數據列表,按交易日降序排列
optional bytes nextPageKey = 4; //分頁請求的key,有值表示還有更多數據
}
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
26
- 接口調用結果,結構參見 RetType
協議 ID
3301
uint GetOptionMarketStatistic(Qot_GetOptionMarketStatistic.Request req); virtual void OnReply_GetOptionMarketStatistic(MMAPI_Conn client, uint nSerialNo, Qot_GetOptionMarketStatistic.Response rsp);
介紹
獲取期權市場統計數據
參數
message C2S
{
required int32 optionMarket = 1; //Qot_OptionCommon.OptionMarket,期權市場類型
required int32 dataType = 2; //Qot_OptionCommon.OptionStatisticDataType,數據類型(成交量或持倉量)
required string beginTime = 3; //開始時間字符串
required string endTime = 4; //結束時間字符串,時間跨度超過一年時自動分頁
optional bytes nextPageKey = 5; //分頁請求的key,首頁不填,續頁填入上一頁返回的nextPageKey
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
- 返回
//每日統計數據
message StatisticItem
{
required string time = 1; //交易日時間字符串
optional double timestamp = 2; //交易日時間戳
required int64 callValue = 3; //看漲期權合計值(成交量或持倉量,由請求的dataType決定)
required int64 putValue = 4; //看跌期權合計值
optional int64 totalValue = 5; //總值(callValue + putValue)
optional double ratio = 6; //Put/Call比值(callValue爲0時不設置)
}
message S2C
{
required int32 optionMarket = 1; //Qot_OptionCommon.OptionMarket,期權市場類型
required int32 dataType = 2; //Qot_OptionCommon.OptionStatisticDataType,數據類型
repeated StatisticItem statisticList = 3; //統計數據列表,按交易日降序排列
optional bytes nextPageKey = 4; //分頁請求的key,有值表示還有更多數據
}
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
26
- 接口調用結果,結構參見 RetType
協議 ID
3301
int getOptionMarketStatistic(Qot_GetOptionMarketStatistic.Request req) onReply_GetOptionMarketStatistic(MMAPI_Conn client, int nSerialNo, Qot_GetOptionMarketStatistic.Response rsp)
介紹
獲取期權市場統計數據
參數
message C2S
{
required int32 optionMarket = 1; //Qot_OptionCommon.OptionMarket,期權市場類型
required int32 dataType = 2; //Qot_OptionCommon.OptionStatisticDataType,數據類型(成交量或持倉量)
required string beginTime = 3; //開始時間字符串
required string endTime = 4; //結束時間字符串,時間跨度超過一年時自動分頁
optional bytes nextPageKey = 5; //分頁請求的key,首頁不填,續頁填入上一頁返回的nextPageKey
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
- 返回
//每日統計數據
message StatisticItem
{
required string time = 1; //交易日時間字符串
optional double timestamp = 2; //交易日時間戳
required int64 callValue = 3; //看漲期權合計值(成交量或持倉量,由請求的dataType決定)
required int64 putValue = 4; //看跌期權合計值
optional int64 totalValue = 5; //總值(callValue + putValue)
optional double ratio = 6; //Put/Call比值(callValue爲0時不設置)
}
message S2C
{
required int32 optionMarket = 1; //Qot_OptionCommon.OptionMarket,期權市場類型
required int32 dataType = 2; //Qot_OptionCommon.OptionStatisticDataType,數據類型
repeated StatisticItem statisticList = 3; //統計數據列表,按交易日降序排列
optional bytes nextPageKey = 4; //分頁請求的key,有值表示還有更多數據
}
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
26
- 接口調用結果,結構參見 RetType
協議 ID
3301
Moomoo::u32_t GetOptionMarketStatistic(const Qot_GetOptionMarketStatistic::Request &stReq);
virtual void OnReply_GetOptionMarketStatistic(Moomoo::u32_t nSerialNo, const Qot_GetOptionMarketStatistic::Response &stRsp) = 0;
介紹
獲取期權市場統計數據
參數
message C2S
{
required int32 optionMarket = 1; //Qot_OptionCommon.OptionMarket,期權市場類型
required int32 dataType = 2; //Qot_OptionCommon.OptionStatisticDataType,數據類型(成交量或持倉量)
required string beginTime = 3; //開始時間字符串
required string endTime = 4; //結束時間字符串,時間跨度超過一年時自動分頁
optional bytes nextPageKey = 5; //分頁請求的key,首頁不填,續頁填入上一頁返回的nextPageKey
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
- 返回
//每日統計數據
message StatisticItem
{
required string time = 1; //交易日時間字符串
optional double timestamp = 2; //交易日時間戳
required int64 callValue = 3; //看漲期權合計值(成交量或持倉量,由請求的dataType決定)
required int64 putValue = 4; //看跌期權合計值
optional int64 totalValue = 5; //總值(callValue + putValue)
optional double ratio = 6; //Put/Call比值(callValue爲0時不設置)
}
message S2C
{
required int32 optionMarket = 1; //Qot_OptionCommon.OptionMarket,期權市場類型
required int32 dataType = 2; //Qot_OptionCommon.OptionStatisticDataType,數據類型
repeated StatisticItem statisticList = 3; //統計數據列表,按交易日降序排列
optional bytes nextPageKey = 4; //分頁請求的key,有值表示還有更多數據
}
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
26
- 接口調用結果,結構參見 RetType
協議 ID
3301
Example
class Program : public MMSPI_Qot, 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) {
Qot_GetOptionMarketStatistic::Request req;
Qot_GetOptionMarketStatistic::C2S *c2s = req.mutable_c2s();
// TODO: 按 proto 填充 c2s 字段
m_GetOptionMarketStatisticSerialNo = m_pQotApi->GetOptionMarketStatistic(req);
}
virtual void OnReply_GetOptionMarketStatistic(Moomoo::u32_t nSerialNo, const Qot_GetOptionMarketStatistic::Response &stRsp) {
if (nSerialNo != m_GetOptionMarketStatisticSerialNo) return;
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
MMAPI_Qot *m_pQotApi;
Moomoo::u32_t m_GetOptionMarketStatisticSerialNo = 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
getOptionMarketStatistic(qotGetOptionMarketStatistic)
介紹
獲取期權市場統計數據
參數
message C2S
{
required int32 optionMarket = 1; //Qot_OptionCommon.OptionMarket,期權市場類型
required int32 dataType = 2; //Qot_OptionCommon.OptionStatisticDataType,數據類型(成交量或持倉量)
required string beginTime = 3; //開始時間字符串
required string endTime = 4; //結束時間字符串,時間跨度超過一年時自動分頁
optional bytes nextPageKey = 5; //分頁請求的key,首頁不填,續頁填入上一頁返回的nextPageKey
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
- 返回
//每日統計數據
message StatisticItem
{
required string time = 1; //交易日時間字符串
optional double timestamp = 2; //交易日時間戳
required int64 callValue = 3; //看漲期權合計值(成交量或持倉量,由請求的dataType決定)
required int64 putValue = 4; //看跌期權合計值
optional int64 totalValue = 5; //總值(callValue + putValue)
optional double ratio = 6; //Put/Call比值(callValue爲0時不設置)
}
message S2C
{
required int32 optionMarket = 1; //Qot_OptionCommon.OptionMarket,期權市場類型
required int32 dataType = 2; //Qot_OptionCommon.OptionStatisticDataType,數據類型
repeated StatisticItem statisticList = 3; //統計數據列表,按交易日降序排列
optional bytes nextPageKey = 4; //分頁請求的key,有值表示還有更多數據
}
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
26
- 接口調用結果,結構參見 RetType
協議 ID
3301
Example
import mmWebsocket from "moomoo-api";
import { Common, Qot_OptionCommon } from "moomoo-api/proto";
import beautify from "js-beautify";
function QotGetOptionMarketStatistic(){
const { RetType } = Common
const { OptionMarket, OptionStatisticDataType } = Qot_OptionCommon
let [addr, port, enable_ssl, key] = ["127.0.0.1", 11112, false, ''];
let websocket = new mmWebsocket();
websocket.onlogin = (ret, msg)=>{
if (ret) {
const req = {
c2s: {
optionMarket: OptionMarket.OptionMarket_US_Security,
dataType: OptionStatisticDataType.OptionStatisticDataType_Volume,
beginTime: '2026-06-01',
endTime: '2026-06-15',
},
};
websocket.GetOptionMarketStatistic(req)
.then((res)=>{
let { errCode, retMsg, retType, s2c } = res
console.log("GetOptionMarketStatistic: 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("start error", msg);
}
};
websocket.start(addr, port, enable_ssl, key);
setTimeout(()=>{ websocket.stop(); process.exit(); }, 5000);
}
QotGetOptionMarketStatistic()
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
- Output
GetOptionMarketStatistic: errCode 0, retMsg , retType 0
{
"optionMarket": 1,
"dataType": 0,
"statisticList": [
{
"time": "2026-06-12",
"timestamp": 1781237000,
"callValue": 45658870,
"putValue": 28723978,
"totalValue": 74382848,
"ratio": 0.6291
},
{
"time": "2026-06-11",
"timestamp": 1781150000,
"callValue": 38303062,
"putValue": 30520043,
"totalValue": 68823105,
"ratio": 0.796804
},
{
"time": "2026-06-10",
"timestamp": 1781064000,
"callValue": 35371830,
"putValue": 30180004,
"totalValue": 65551834,
"ratio": 0.853221
}
]
}
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
接口限制
- 30 秒內最多請求 60 次期權市場統計接口(支持分頁的接口,僅首次調用納入統計)