# 期权市场统计
- 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 次期权市场统计接口(支持分页的接口,仅首次调用纳入统计)