# 期权标的总览
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_option_underlying_overview(code_list, index_option_type=IndexOptionType.NORMAL)
介绍
批量获取期权标的总览数据,包含成交量、持仓量、隐含波动率(IV)及多周期历史波动率(HV)等核心指标的最新快照。
参数
参数 类型 说明 code_list list[str] 标的股票代码列表 如 ['US.AAPL', 'US.TSLA'],最多 500 个index_option_type IndexOptionType 指数期权类型 NORMAL=普通期权(默认)、SMALL=小型指数期权,仅恒指/国指需要返回
参数 类型 说明 ret RET_CODE 接口调用结果 data pandas.DataFrame 当 ret == RET_OK,返回标的总览数据 str 当 ret != RET_OK,返回错误描述 返回 DataFrame 字段:
字段 类型 说明 code str 股票代码 name str 标的名称 call_volume int 看涨期权成交量 put_volume int 看跌期权成交量 call_open_interest int 看涨期权持仓量(T-1 延迟) put_open_interest int 看跌期权持仓量(T-1 延迟) iv float 隐含波动率(百分比) iv_rank float IV 排名百分位(百分比) iv_percentile float IV 百分位(百分比) pre_iv float 前一交易日 IV(百分比) hv_30d float 30 日历史波动率(百分比) hv_30d_percentile float 30 日 HV 百分位 hv_60d float 60 日历史波动率(百分比) hv_60d_percentile float 60 日 HV 百分位 hv_90d float 90 日历史波动率(百分比) hv_90d_percentile float 90 日 HV 百分位 hv_120d float 120 日历史波动率(百分比) hv_120d_percentile float 120 日 HV 百分位 hv_365d float 365 日历史波动率(百分比) hv_365d_percentile float 365 日 HV 百分位
Example
from futu import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data = quote_ctx.get_option_underlying_overview(['US.AAPL', 'US.TSLA', 'US.NVDA'])
if ret == RET_OK:
print(data)
else:
print('error:', data)
quote_ctx.close()
2
3
4
5
6
7
8
9
10
11
- Output
code name call_volume put_volume call_open_interest put_open_interest iv iv_rank iv_percentile pre_iv hv_30d hv_30d_percentile hv_60d hv_60d_percentile hv_90d hv_90d_percentile hv_120d hv_120d_percentile hv_365d hv_365d_percentile
0 US.AAPL Apple 782941 490299 3165108 2237950 25.126 37.702 19.841 25.617 23.324 59.126 24.641 65.476 23.019 46.825 23.582 47.619 22.619 8.333
1 US.TSLA Tesla 2197764 1425740 4178685 2909774 55.053 39.265 64.285 55.401 49.359 68.254 46.536 58.730 44.990 46.031 41.688 29.761 44.500 1.190
2 US.NVDA NVIDIA 1980405 1176926 9096278 7648683 41.975 27.062 42.460 45.135 45.921 96.825 42.646 99.206 39.980 92.460 38.971 81.746 34.989 17.063
2
3
4
# Qot_GetOptionUnderlyingOverview.proto
介绍
获取期权标的总览数据
参数
message C2S
{
repeated Qot_Common.Security ownerList = 1; //期权标的股列表,最多500个
optional int32 indexOptionType = 2; //Qot_Common.IndexOptionType,指数期权的类型,仅用于恒指国指
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
- 返回
message HVItem
{
required int32 timeRange = 1; //Qot_OptionCommon.OptionHVTimeRange,HV时间范围
required double hv = 2; //历史波动率(百分比)
optional double hvPercentile = 3; //HV百分位(百分比)
}
message UnderlyingData
{
required Qot_Common.Security owner = 1; //期权标的股
optional string code = 2; //股票代码
optional string name = 3; //标的名称
optional int64 callVolume = 4; //看涨期权成交量
optional int64 putVolume = 5; //看跌期权成交量
optional int64 callOpenInterest = 6; //看涨期权持仓量(T-1延迟)
optional int64 putOpenInterest = 7; //看跌期权持仓量(T-1延迟)
optional double iv = 8; //隐含波动率(百分比)
optional double ivRank = 9; //IV排名百分位(百分比)
optional double ivPercentile = 10; //IV百分位(百分比)
repeated HVItem hvList = 11; //历史波动率列表(多个时间范围)
optional double preIV = 12; //前一交易日IV(百分比)
}
message S2C
{
repeated UnderlyingData underlyingDataList = 1; //标的最新数据列表
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType,返回结果
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
- 接口调用结果,结构参见 RetType
协议 ID
3303
uint GetOptionUnderlyingOverview(Qot_GetOptionUnderlyingOverview.Request req); virtual void OnReply_GetOptionUnderlyingOverview(FTAPI_Conn client, uint nSerialNo, Qot_GetOptionUnderlyingOverview.Response rsp);
介绍
获取期权标的总览数据
参数
message C2S
{
repeated Qot_Common.Security ownerList = 1; //期权标的股列表,最多500个
optional int32 indexOptionType = 2; //Qot_Common.IndexOptionType,指数期权的类型,仅用于恒指国指
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
- 返回
message HVItem
{
required int32 timeRange = 1; //Qot_OptionCommon.OptionHVTimeRange,HV时间范围
required double hv = 2; //历史波动率(百分比)
optional double hvPercentile = 3; //HV百分位(百分比)
}
message UnderlyingData
{
required Qot_Common.Security owner = 1; //期权标的股
optional string code = 2; //股票代码
optional string name = 3; //标的名称
optional int64 callVolume = 4; //看涨期权成交量
optional int64 putVolume = 5; //看跌期权成交量
optional int64 callOpenInterest = 6; //看涨期权持仓量(T-1延迟)
optional int64 putOpenInterest = 7; //看跌期权持仓量(T-1延迟)
optional double iv = 8; //隐含波动率(百分比)
optional double ivRank = 9; //IV排名百分位(百分比)
optional double ivPercentile = 10; //IV百分位(百分比)
repeated HVItem hvList = 11; //历史波动率列表(多个时间范围)
optional double preIV = 12; //前一交易日IV(百分比)
}
message S2C
{
repeated UnderlyingData underlyingDataList = 1; //标的最新数据列表
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType,返回结果
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
- 接口调用结果,结构参见 RetType
协议 ID
3303
int getOptionUnderlyingOverview(Qot_GetOptionUnderlyingOverview.Request req) onReply_GetOptionUnderlyingOverview(FTAPI_Conn client, int nSerialNo, Qot_GetOptionUnderlyingOverview.Response rsp)
介绍
获取期权标的总览数据
参数
message C2S
{
repeated Qot_Common.Security ownerList = 1; //期权标的股列表,最多500个
optional int32 indexOptionType = 2; //Qot_Common.IndexOptionType,指数期权的类型,仅用于恒指国指
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
- 返回
message HVItem
{
required int32 timeRange = 1; //Qot_OptionCommon.OptionHVTimeRange,HV时间范围
required double hv = 2; //历史波动率(百分比)
optional double hvPercentile = 3; //HV百分位(百分比)
}
message UnderlyingData
{
required Qot_Common.Security owner = 1; //期权标的股
optional string code = 2; //股票代码
optional string name = 3; //标的名称
optional int64 callVolume = 4; //看涨期权成交量
optional int64 putVolume = 5; //看跌期权成交量
optional int64 callOpenInterest = 6; //看涨期权持仓量(T-1延迟)
optional int64 putOpenInterest = 7; //看跌期权持仓量(T-1延迟)
optional double iv = 8; //隐含波动率(百分比)
optional double ivRank = 9; //IV排名百分位(百分比)
optional double ivPercentile = 10; //IV百分位(百分比)
repeated HVItem hvList = 11; //历史波动率列表(多个时间范围)
optional double preIV = 12; //前一交易日IV(百分比)
}
message S2C
{
repeated UnderlyingData underlyingDataList = 1; //标的最新数据列表
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType,返回结果
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
- 接口调用结果,结构参见 RetType
协议 ID
3303
Futu::u32_t GetOptionUnderlyingOverview(const Qot_GetOptionUnderlyingOverview::Request &stReq);
virtual void OnReply_GetOptionUnderlyingOverview(Futu::u32_t nSerialNo, const Qot_GetOptionUnderlyingOverview::Response &stRsp) = 0;
介绍
获取期权标的总览数据
参数
message C2S
{
repeated Qot_Common.Security ownerList = 1; //期权标的股列表,最多500个
optional int32 indexOptionType = 2; //Qot_Common.IndexOptionType,指数期权的类型,仅用于恒指国指
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
- 返回
message HVItem
{
required int32 timeRange = 1; //Qot_OptionCommon.OptionHVTimeRange,HV时间范围
required double hv = 2; //历史波动率(百分比)
optional double hvPercentile = 3; //HV百分位(百分比)
}
message UnderlyingData
{
required Qot_Common.Security owner = 1; //期权标的股
optional string code = 2; //股票代码
optional string name = 3; //标的名称
optional int64 callVolume = 4; //看涨期权成交量
optional int64 putVolume = 5; //看跌期权成交量
optional int64 callOpenInterest = 6; //看涨期权持仓量(T-1延迟)
optional int64 putOpenInterest = 7; //看跌期权持仓量(T-1延迟)
optional double iv = 8; //隐含波动率(百分比)
optional double ivRank = 9; //IV排名百分位(百分比)
optional double ivPercentile = 10; //IV百分位(百分比)
repeated HVItem hvList = 11; //历史波动率列表(多个时间范围)
optional double preIV = 12; //前一交易日IV(百分比)
}
message S2C
{
repeated UnderlyingData underlyingDataList = 1; //标的最新数据列表
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType,返回结果
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
- 接口调用结果,结构参见 RetType
协议 ID
3303
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_GetOptionUnderlyingOverview::Request req;
Qot_GetOptionUnderlyingOverview::C2S *c2s = req.mutable_c2s();
// TODO: 按 proto 填充 c2s 字段
m_GetOptionUnderlyingOverviewSerialNo = m_pQotApi->GetOptionUnderlyingOverview(req);
}
virtual void OnReply_GetOptionUnderlyingOverview(Futu::u32_t nSerialNo, const Qot_GetOptionUnderlyingOverview::Response &stRsp) {
if (nSerialNo != m_GetOptionUnderlyingOverviewSerialNo) return;
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
FTAPI_Qot *m_pQotApi;
Futu::u32_t m_GetOptionUnderlyingOverviewSerialNo = 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
getOptionUnderlyingOverview(qotGetOptionUnderlyingOverview)
介绍
获取期权标的总览数据
参数
message C2S
{
repeated Qot_Common.Security ownerList = 1; //期权标的股列表,最多500个
optional int32 indexOptionType = 2; //Qot_Common.IndexOptionType,指数期权的类型,仅用于恒指国指
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
- 返回
message HVItem
{
required int32 timeRange = 1; //Qot_OptionCommon.OptionHVTimeRange,HV时间范围
required double hv = 2; //历史波动率(百分比)
optional double hvPercentile = 3; //HV百分位(百分比)
}
message UnderlyingData
{
required Qot_Common.Security owner = 1; //期权标的股
optional string code = 2; //股票代码
optional string name = 3; //标的名称
optional int64 callVolume = 4; //看涨期权成交量
optional int64 putVolume = 5; //看跌期权成交量
optional int64 callOpenInterest = 6; //看涨期权持仓量(T-1延迟)
optional int64 putOpenInterest = 7; //看跌期权持仓量(T-1延迟)
optional double iv = 8; //隐含波动率(百分比)
optional double ivRank = 9; //IV排名百分位(百分比)
optional double ivPercentile = 10; //IV百分位(百分比)
repeated HVItem hvList = 11; //历史波动率列表(多个时间范围)
optional double preIV = 12; //前一交易日IV(百分比)
}
message S2C
{
repeated UnderlyingData underlyingDataList = 1; //标的最新数据列表
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType,返回结果
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
- 接口调用结果,结构参见 RetType
协议 ID
3303
Example
import ftWebsocket from "futu-api";
import { Common, Qot_Common } from "futu-api/proto";
import beautify from "js-beautify";
function QotGetOptionUnderlyingOverview(){
const { RetType } = Common
const { QotMarket } = Qot_Common
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: {
ownerList: [
{ market: QotMarket.QotMarket_US_Security, code: 'AAPL' },
{ market: QotMarket.QotMarket_US_Security, code: 'TSLA' },
],
},
};
websocket.GetOptionUnderlyingOverview(req)
.then((res)=>{
let { errCode, retMsg, retType, s2c } = res
console.log("GetOptionUnderlyingOverview: 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);
}
QotGetOptionUnderlyingOverview()
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
GetOptionUnderlyingOverview: errCode 0, retMsg , retType 0
{
"underlyingDataList": [
{
"owner": { "market": 1, "code": "AAPL" },
"code": "US.AAPL",
"name": "Apple",
"callVolume": 782941,
"putVolume": 490299,
"callOpenInterest": 3165108,
"putOpenInterest": 2237950,
"iv": 25.126,
"ivRank": 37.702,
"ivPercentile": 19.841,
"hvList": [
{ "timeRange": 1, "hv": 23.324, "hvPercentile": 59.126 },
{ "timeRange": 2, "hv": 24.641, "hvPercentile": 65.476 },
{ "timeRange": 3, "hv": 23.019, "hvPercentile": 46.825 }
],
"preIV": 25.617
},
{
"owner": { "market": 1, "code": "TSLA" },
"code": "US.TSLA",
"name": "Tesla",
"callVolume": 2197764,
"putVolume": 1425740,
"callOpenInterest": 4178685,
"putOpenInterest": 2909774,
"iv": 55.053,
"ivRank": 39.265,
"ivPercentile": 64.285,
"hvList": [
{ "timeRange": 1, "hv": 49.359, "hvPercentile": 68.254 },
{ "timeRange": 2, "hv": 46.536, "hvPercentile": 58.73 },
{ "timeRange": 3, "hv": 44.99, "hvPercentile": 46.031 }
],
"preIV": 55.401
}
]
}
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
接口限制
- 30 秒内最多请求 60 次期权标的总览接口
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_option_underlying_overview(code_list, index_option_type=IndexOptionType.NORMAL)
介绍
批量获取期权标的总览数据,包含成交量、持仓量、隐含波动率(IV)及多周期历史波动率(HV)等核心指标的最新快照。
参数
参数 类型 说明 code_list list[str] 标的股票代码列表 如 ['US.AAPL', 'US.TSLA'],最多 500 个index_option_type IndexOptionType 指数期权类型 NORMAL=普通期权(默认)、SMALL=小型指数期权,仅恒指/国指需要返回
参数 类型 说明 ret RET_CODE 接口调用结果 data pandas.DataFrame 当 ret == RET_OK,返回标的总览数据 str 当 ret != RET_OK,返回错误描述 返回 DataFrame 字段:
字段 类型 说明 code str 股票代码 name str 标的名称 call_volume int 看涨期权成交量 put_volume int 看跌期权成交量 call_open_interest int 看涨期权持仓量(T-1 延迟) put_open_interest int 看跌期权持仓量(T-1 延迟) iv float 隐含波动率(百分比) iv_rank float IV 排名百分位(百分比) iv_percentile float IV 百分位(百分比) pre_iv float 前一交易日 IV(百分比) hv_30d float 30 日历史波动率(百分比) hv_30d_percentile float 30 日 HV 百分位 hv_60d float 60 日历史波动率(百分比) hv_60d_percentile float 60 日 HV 百分位 hv_90d float 90 日历史波动率(百分比) hv_90d_percentile float 90 日 HV 百分位 hv_120d float 120 日历史波动率(百分比) hv_120d_percentile float 120 日 HV 百分位 hv_365d float 365 日历史波动率(百分比) hv_365d_percentile float 365 日 HV 百分位
Example
from moomoo import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data = quote_ctx.get_option_underlying_overview(['US.AAPL', 'US.TSLA', 'US.NVDA'])
if ret == RET_OK:
print(data)
else:
print('error:', data)
quote_ctx.close()
2
3
4
5
6
7
8
9
10
11
- Output
code name call_volume put_volume call_open_interest put_open_interest iv iv_rank iv_percentile pre_iv hv_30d hv_30d_percentile hv_60d hv_60d_percentile hv_90d hv_90d_percentile hv_120d hv_120d_percentile hv_365d hv_365d_percentile
0 US.AAPL Apple 782941 490299 3165108 2237950 25.126 37.702 19.841 25.617 23.324 59.126 24.641 65.476 23.019 46.825 23.582 47.619 22.619 8.333
1 US.TSLA Tesla 2197764 1425740 4178685 2909774 55.053 39.265 64.285 55.401 49.359 68.254 46.536 58.730 44.990 46.031 41.688 29.761 44.500 1.190
2 US.NVDA NVIDIA 1980405 1176926 9096278 7648683 41.975 27.062 42.460 45.135 45.921 96.825 42.646 99.206 39.980 92.460 38.971 81.746 34.989 17.063
2
3
4
# Qot_GetOptionUnderlyingOverview.proto
介绍
获取期权标的总览数据
参数
message C2S
{
repeated Qot_Common.Security ownerList = 1; //期权标的股列表,最多500个
optional int32 indexOptionType = 2; //Qot_Common.IndexOptionType,指数期权的类型,仅用于恒指国指
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
- 返回
message HVItem
{
required int32 timeRange = 1; //Qot_OptionCommon.OptionHVTimeRange,HV时间范围
required double hv = 2; //历史波动率(百分比)
optional double hvPercentile = 3; //HV百分位(百分比)
}
message UnderlyingData
{
required Qot_Common.Security owner = 1; //期权标的股
optional string code = 2; //股票代码
optional string name = 3; //标的名称
optional int64 callVolume = 4; //看涨期权成交量
optional int64 putVolume = 5; //看跌期权成交量
optional int64 callOpenInterest = 6; //看涨期权持仓量(T-1延迟)
optional int64 putOpenInterest = 7; //看跌期权持仓量(T-1延迟)
optional double iv = 8; //隐含波动率(百分比)
optional double ivRank = 9; //IV排名百分位(百分比)
optional double ivPercentile = 10; //IV百分位(百分比)
repeated HVItem hvList = 11; //历史波动率列表(多个时间范围)
optional double preIV = 12; //前一交易日IV(百分比)
}
message S2C
{
repeated UnderlyingData underlyingDataList = 1; //标的最新数据列表
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType,返回结果
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
- 接口调用结果,结构参见 RetType
协议 ID
3303
uint GetOptionUnderlyingOverview(Qot_GetOptionUnderlyingOverview.Request req); virtual void OnReply_GetOptionUnderlyingOverview(MMAPI_Conn client, uint nSerialNo, Qot_GetOptionUnderlyingOverview.Response rsp);
介绍
获取期权标的总览数据
参数
message C2S
{
repeated Qot_Common.Security ownerList = 1; //期权标的股列表,最多500个
optional int32 indexOptionType = 2; //Qot_Common.IndexOptionType,指数期权的类型,仅用于恒指国指
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
- 返回
message HVItem
{
required int32 timeRange = 1; //Qot_OptionCommon.OptionHVTimeRange,HV时间范围
required double hv = 2; //历史波动率(百分比)
optional double hvPercentile = 3; //HV百分位(百分比)
}
message UnderlyingData
{
required Qot_Common.Security owner = 1; //期权标的股
optional string code = 2; //股票代码
optional string name = 3; //标的名称
optional int64 callVolume = 4; //看涨期权成交量
optional int64 putVolume = 5; //看跌期权成交量
optional int64 callOpenInterest = 6; //看涨期权持仓量(T-1延迟)
optional int64 putOpenInterest = 7; //看跌期权持仓量(T-1延迟)
optional double iv = 8; //隐含波动率(百分比)
optional double ivRank = 9; //IV排名百分位(百分比)
optional double ivPercentile = 10; //IV百分位(百分比)
repeated HVItem hvList = 11; //历史波动率列表(多个时间范围)
optional double preIV = 12; //前一交易日IV(百分比)
}
message S2C
{
repeated UnderlyingData underlyingDataList = 1; //标的最新数据列表
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType,返回结果
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
- 接口调用结果,结构参见 RetType
协议 ID
3303
int getOptionUnderlyingOverview(Qot_GetOptionUnderlyingOverview.Request req) onReply_GetOptionUnderlyingOverview(MMAPI_Conn client, int nSerialNo, Qot_GetOptionUnderlyingOverview.Response rsp)
介绍
获取期权标的总览数据
参数
message C2S
{
repeated Qot_Common.Security ownerList = 1; //期权标的股列表,最多500个
optional int32 indexOptionType = 2; //Qot_Common.IndexOptionType,指数期权的类型,仅用于恒指国指
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
- 返回
message HVItem
{
required int32 timeRange = 1; //Qot_OptionCommon.OptionHVTimeRange,HV时间范围
required double hv = 2; //历史波动率(百分比)
optional double hvPercentile = 3; //HV百分位(百分比)
}
message UnderlyingData
{
required Qot_Common.Security owner = 1; //期权标的股
optional string code = 2; //股票代码
optional string name = 3; //标的名称
optional int64 callVolume = 4; //看涨期权成交量
optional int64 putVolume = 5; //看跌期权成交量
optional int64 callOpenInterest = 6; //看涨期权持仓量(T-1延迟)
optional int64 putOpenInterest = 7; //看跌期权持仓量(T-1延迟)
optional double iv = 8; //隐含波动率(百分比)
optional double ivRank = 9; //IV排名百分位(百分比)
optional double ivPercentile = 10; //IV百分位(百分比)
repeated HVItem hvList = 11; //历史波动率列表(多个时间范围)
optional double preIV = 12; //前一交易日IV(百分比)
}
message S2C
{
repeated UnderlyingData underlyingDataList = 1; //标的最新数据列表
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType,返回结果
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
- 接口调用结果,结构参见 RetType
协议 ID
3303
Moomoo::u32_t GetOptionUnderlyingOverview(const Qot_GetOptionUnderlyingOverview::Request &stReq);
virtual void OnReply_GetOptionUnderlyingOverview(Moomoo::u32_t nSerialNo, const Qot_GetOptionUnderlyingOverview::Response &stRsp) = 0;
介绍
获取期权标的总览数据
参数
message C2S
{
repeated Qot_Common.Security ownerList = 1; //期权标的股列表,最多500个
optional int32 indexOptionType = 2; //Qot_Common.IndexOptionType,指数期权的类型,仅用于恒指国指
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
- 返回
message HVItem
{
required int32 timeRange = 1; //Qot_OptionCommon.OptionHVTimeRange,HV时间范围
required double hv = 2; //历史波动率(百分比)
optional double hvPercentile = 3; //HV百分位(百分比)
}
message UnderlyingData
{
required Qot_Common.Security owner = 1; //期权标的股
optional string code = 2; //股票代码
optional string name = 3; //标的名称
optional int64 callVolume = 4; //看涨期权成交量
optional int64 putVolume = 5; //看跌期权成交量
optional int64 callOpenInterest = 6; //看涨期权持仓量(T-1延迟)
optional int64 putOpenInterest = 7; //看跌期权持仓量(T-1延迟)
optional double iv = 8; //隐含波动率(百分比)
optional double ivRank = 9; //IV排名百分位(百分比)
optional double ivPercentile = 10; //IV百分位(百分比)
repeated HVItem hvList = 11; //历史波动率列表(多个时间范围)
optional double preIV = 12; //前一交易日IV(百分比)
}
message S2C
{
repeated UnderlyingData underlyingDataList = 1; //标的最新数据列表
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType,返回结果
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
- 接口调用结果,结构参见 RetType
协议 ID
3303
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_GetOptionUnderlyingOverview::Request req;
Qot_GetOptionUnderlyingOverview::C2S *c2s = req.mutable_c2s();
// TODO: 按 proto 填充 c2s 字段
m_GetOptionUnderlyingOverviewSerialNo = m_pQotApi->GetOptionUnderlyingOverview(req);
}
virtual void OnReply_GetOptionUnderlyingOverview(Moomoo::u32_t nSerialNo, const Qot_GetOptionUnderlyingOverview::Response &stRsp) {
if (nSerialNo != m_GetOptionUnderlyingOverviewSerialNo) return;
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
MMAPI_Qot *m_pQotApi;
Moomoo::u32_t m_GetOptionUnderlyingOverviewSerialNo = 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
getOptionUnderlyingOverview(qotGetOptionUnderlyingOverview)
介绍
获取期权标的总览数据
参数
message C2S
{
repeated Qot_Common.Security ownerList = 1; //期权标的股列表,最多500个
optional int32 indexOptionType = 2; //Qot_Common.IndexOptionType,指数期权的类型,仅用于恒指国指
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
- 返回
message HVItem
{
required int32 timeRange = 1; //Qot_OptionCommon.OptionHVTimeRange,HV时间范围
required double hv = 2; //历史波动率(百分比)
optional double hvPercentile = 3; //HV百分位(百分比)
}
message UnderlyingData
{
required Qot_Common.Security owner = 1; //期权标的股
optional string code = 2; //股票代码
optional string name = 3; //标的名称
optional int64 callVolume = 4; //看涨期权成交量
optional int64 putVolume = 5; //看跌期权成交量
optional int64 callOpenInterest = 6; //看涨期权持仓量(T-1延迟)
optional int64 putOpenInterest = 7; //看跌期权持仓量(T-1延迟)
optional double iv = 8; //隐含波动率(百分比)
optional double ivRank = 9; //IV排名百分位(百分比)
optional double ivPercentile = 10; //IV百分位(百分比)
repeated HVItem hvList = 11; //历史波动率列表(多个时间范围)
optional double preIV = 12; //前一交易日IV(百分比)
}
message S2C
{
repeated UnderlyingData underlyingDataList = 1; //标的最新数据列表
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType,返回结果
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
- 接口调用结果,结构参见 RetType
协议 ID
3303
Example
import mmWebsocket from "moomoo-api";
import { Common, Qot_Common } from "moomoo-api/proto";
import beautify from "js-beautify";
function QotGetOptionUnderlyingOverview(){
const { RetType } = Common
const { QotMarket } = Qot_Common
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: {
ownerList: [
{ market: QotMarket.QotMarket_US_Security, code: 'AAPL' },
{ market: QotMarket.QotMarket_US_Security, code: 'TSLA' },
],
},
};
websocket.GetOptionUnderlyingOverview(req)
.then((res)=>{
let { errCode, retMsg, retType, s2c } = res
console.log("GetOptionUnderlyingOverview: 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);
}
QotGetOptionUnderlyingOverview()
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
GetOptionUnderlyingOverview: errCode 0, retMsg , retType 0
{
"underlyingDataList": [
{
"owner": { "market": 1, "code": "AAPL" },
"code": "US.AAPL",
"name": "Apple",
"callVolume": 782941,
"putVolume": 490299,
"callOpenInterest": 3165108,
"putOpenInterest": 2237950,
"iv": 25.126,
"ivRank": 37.702,
"ivPercentile": 19.841,
"hvList": [
{ "timeRange": 1, "hv": 23.324, "hvPercentile": 59.126 },
{ "timeRange": 2, "hv": 24.641, "hvPercentile": 65.476 },
{ "timeRange": 3, "hv": 23.019, "hvPercentile": 46.825 }
],
"preIV": 25.617
},
{
"owner": { "market": 1, "code": "TSLA" },
"code": "US.TSLA",
"name": "Tesla",
"callVolume": 2197764,
"putVolume": 1425740,
"callOpenInterest": 4178685,
"putOpenInterest": 2909774,
"iv": 55.053,
"ivRank": 39.265,
"ivPercentile": 64.285,
"hvList": [
{ "timeRange": 1, "hv": 49.359, "hvPercentile": 68.254 },
{ "timeRange": 2, "hv": 46.536, "hvPercentile": 58.73 },
{ "timeRange": 3, "hv": 44.99, "hvPercentile": 46.031 }
],
"preIV": 55.401
}
]
}
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
接口限制
- 30 秒内最多请求 60 次期权标的总览接口