# Option Underlying Overview
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_option_underlying_overview(code_list, index_option_type=IndexOptionType.NORMAL)
Description
Batch retrieve option underlying overview data, including the latest snapshot of core metrics such as volume, open interest, implied volatility (IV), and multi-period historical volatility (HV).
Parameters
Parameter Type Description code_list list[str] List of underlying stock codes e.g. ['US.AAPL', 'US.TSLA'], max 500index_option_type IndexOptionType Index option type NORMAL=standard options (default), SMALL=mini index options, only needed for HSI/HSCEIReturns
Parameter Type Description ret RET_CODE Interface call result data pandas.DataFrame When ret == RET_OK, returns underlying overview data str When ret != RET_OK, returns error description Return DataFrame fields:
Field Type Description code str Stock code name str Underlying name call_volume int Call option volume put_volume int Put option volume call_open_interest int Call option open interest (T-1 delayed) put_open_interest int Put option open interest (T-1 delayed) iv float Implied volatility (percentage) iv_rank float IV rank percentile (percentage) iv_percentile float IV percentile (percentage) pre_iv float Previous trading day IV (percentage) hv_30d float 30-day historical volatility (percentage) hv_30d_percentile float 30-day HV percentile hv_60d float 60-day historical volatility (percentage) hv_60d_percentile float 60-day HV percentile hv_90d float 90-day historical volatility (percentage) hv_90d_percentile float 90-day HV percentile hv_120d float 120-day historical volatility (percentage) hv_120d_percentile float 120-day HV percentile hv_365d float 365-day historical volatility (percentage) hv_365d_percentile float 365-day HV percentile
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
Description
Get option underlying overview data
Parameters
message C2S
{
repeated Qot_Common.Security ownerList = 1; //Option underlying stock list, max 500
optional int32 indexOptionType = 2; //Qot_Common.IndexOptionType, index option type, for HSI/HSCEI only
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
- Returns
message HVItem
{
required int32 timeRange = 1; //Qot_OptionCommon.OptionHVTimeRange, HV time range
required double hv = 2; //Historical volatility (percentage)
optional double hvPercentile = 3; //HV percentile (percentage)
}
message UnderlyingData
{
required Qot_Common.Security owner = 1; //Option underlying stock
optional string code = 2; //Stock code
optional string name = 3; //Underlying name
optional int64 callVolume = 4; //Call option volume
optional int64 putVolume = 5; //Put option volume
optional int64 callOpenInterest = 6; //Call option open interest (T-1 delayed)
optional int64 putOpenInterest = 7; //Put option open interest (T-1 delayed)
optional double iv = 8; //Implied volatility (percentage)
optional double ivRank = 9; //IV rank percentile (percentage)
optional double ivPercentile = 10; //IV percentile (percentage)
repeated HVItem hvList = 11; //Historical volatility list (multiple time ranges)
optional double preIV = 12; //Previous trading day IV (percentage)
}
message S2C
{
repeated UnderlyingData underlyingDataList = 1; //Underlying latest data 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
- Interface call result, structure refer to RetType
Protocol ID
3303
uint GetOptionUnderlyingOverview(Qot_GetOptionUnderlyingOverview.Request req); virtual void OnReply_GetOptionUnderlyingOverview(FTAPI_Conn client, uint nSerialNo, Qot_GetOptionUnderlyingOverview.Response rsp);
Description
Get option underlying overview data
Parameters
message C2S
{
repeated Qot_Common.Security ownerList = 1; //Option underlying stock list, max 500
optional int32 indexOptionType = 2; //Qot_Common.IndexOptionType, index option type, for HSI/HSCEI only
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
- Returns
message HVItem
{
required int32 timeRange = 1; //Qot_OptionCommon.OptionHVTimeRange, HV time range
required double hv = 2; //Historical volatility (percentage)
optional double hvPercentile = 3; //HV percentile (percentage)
}
message UnderlyingData
{
required Qot_Common.Security owner = 1; //Option underlying stock
optional string code = 2; //Stock code
optional string name = 3; //Underlying name
optional int64 callVolume = 4; //Call option volume
optional int64 putVolume = 5; //Put option volume
optional int64 callOpenInterest = 6; //Call option open interest (T-1 delayed)
optional int64 putOpenInterest = 7; //Put option open interest (T-1 delayed)
optional double iv = 8; //Implied volatility (percentage)
optional double ivRank = 9; //IV rank percentile (percentage)
optional double ivPercentile = 10; //IV percentile (percentage)
repeated HVItem hvList = 11; //Historical volatility list (multiple time ranges)
optional double preIV = 12; //Previous trading day IV (percentage)
}
message S2C
{
repeated UnderlyingData underlyingDataList = 1; //Underlying latest data 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
- Interface call result, structure refer to RetType
Protocol ID
3303
int getOptionUnderlyingOverview(Qot_GetOptionUnderlyingOverview.Request req) onReply_GetOptionUnderlyingOverview(FTAPI_Conn client, int nSerialNo, Qot_GetOptionUnderlyingOverview.Response rsp)
Description
Get option underlying overview data
Parameters
message C2S
{
repeated Qot_Common.Security ownerList = 1; //Option underlying stock list, max 500
optional int32 indexOptionType = 2; //Qot_Common.IndexOptionType, index option type, for HSI/HSCEI only
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
- Returns
message HVItem
{
required int32 timeRange = 1; //Qot_OptionCommon.OptionHVTimeRange, HV time range
required double hv = 2; //Historical volatility (percentage)
optional double hvPercentile = 3; //HV percentile (percentage)
}
message UnderlyingData
{
required Qot_Common.Security owner = 1; //Option underlying stock
optional string code = 2; //Stock code
optional string name = 3; //Underlying name
optional int64 callVolume = 4; //Call option volume
optional int64 putVolume = 5; //Put option volume
optional int64 callOpenInterest = 6; //Call option open interest (T-1 delayed)
optional int64 putOpenInterest = 7; //Put option open interest (T-1 delayed)
optional double iv = 8; //Implied volatility (percentage)
optional double ivRank = 9; //IV rank percentile (percentage)
optional double ivPercentile = 10; //IV percentile (percentage)
repeated HVItem hvList = 11; //Historical volatility list (multiple time ranges)
optional double preIV = 12; //Previous trading day IV (percentage)
}
message S2C
{
repeated UnderlyingData underlyingDataList = 1; //Underlying latest data 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
- Interface call result, structure refer to RetType
Protocol 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;
Description
Get option underlying overview data
Parameters
message C2S
{
repeated Qot_Common.Security ownerList = 1; //Option underlying stock list, max 500
optional int32 indexOptionType = 2; //Qot_Common.IndexOptionType, index option type, for HSI/HSCEI only
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
- Returns
message HVItem
{
required int32 timeRange = 1; //Qot_OptionCommon.OptionHVTimeRange, HV time range
required double hv = 2; //Historical volatility (percentage)
optional double hvPercentile = 3; //HV percentile (percentage)
}
message UnderlyingData
{
required Qot_Common.Security owner = 1; //Option underlying stock
optional string code = 2; //Stock code
optional string name = 3; //Underlying name
optional int64 callVolume = 4; //Call option volume
optional int64 putVolume = 5; //Put option volume
optional int64 callOpenInterest = 6; //Call option open interest (T-1 delayed)
optional int64 putOpenInterest = 7; //Put option open interest (T-1 delayed)
optional double iv = 8; //Implied volatility (percentage)
optional double ivRank = 9; //IV rank percentile (percentage)
optional double ivPercentile = 10; //IV percentile (percentage)
repeated HVItem hvList = 11; //Historical volatility list (multiple time ranges)
optional double preIV = 12; //Previous trading day IV (percentage)
}
message S2C
{
repeated UnderlyingData underlyingDataList = 1; //Underlying latest data 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
- Interface call result, structure refer to RetType
Protocol 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: populate c2s fields per proto
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)
Description
Get option underlying overview data
Parameters
message C2S
{
repeated Qot_Common.Security ownerList = 1; //Option underlying stock list, max 500
optional int32 indexOptionType = 2; //Qot_Common.IndexOptionType, index option type, for HSI/HSCEI only
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
- Returns
message HVItem
{
required int32 timeRange = 1; //Qot_OptionCommon.OptionHVTimeRange, HV time range
required double hv = 2; //Historical volatility (percentage)
optional double hvPercentile = 3; //HV percentile (percentage)
}
message UnderlyingData
{
required Qot_Common.Security owner = 1; //Option underlying stock
optional string code = 2; //Stock code
optional string name = 3; //Underlying name
optional int64 callVolume = 4; //Call option volume
optional int64 putVolume = 5; //Put option volume
optional int64 callOpenInterest = 6; //Call option open interest (T-1 delayed)
optional int64 putOpenInterest = 7; //Put option open interest (T-1 delayed)
optional double iv = 8; //Implied volatility (percentage)
optional double ivRank = 9; //IV rank percentile (percentage)
optional double ivPercentile = 10; //IV percentile (percentage)
repeated HVItem hvList = 11; //Historical volatility list (multiple time ranges)
optional double preIV = 12; //Previous trading day IV (percentage)
}
message S2C
{
repeated UnderlyingData underlyingDataList = 1; //Underlying latest data 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
- Interface call result, structure refer to RetType
Protocol 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
Rate Limit
- Maximum 60 requests per 30 seconds
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_option_underlying_overview(code_list, index_option_type=IndexOptionType.NORMAL)
Description
Batch retrieve option underlying overview data, including the latest snapshot of core metrics such as volume, open interest, implied volatility (IV), and multi-period historical volatility (HV).
Parameters
Parameter Type Description code_list list[str] List of underlying stock codes e.g. ['US.AAPL', 'US.TSLA'], max 500index_option_type IndexOptionType Index option type NORMAL=standard options (default), SMALL=mini index options, only needed for HSI/HSCEIReturns
Parameter Type Description ret RET_CODE Interface call result data pandas.DataFrame When ret == RET_OK, returns underlying overview data str When ret != RET_OK, returns error description Return DataFrame fields:
Field Type Description code str Stock code name str Underlying name call_volume int Call option volume put_volume int Put option volume call_open_interest int Call option open interest (T-1 delayed) put_open_interest int Put option open interest (T-1 delayed) iv float Implied volatility (percentage) iv_rank float IV rank percentile (percentage) iv_percentile float IV percentile (percentage) pre_iv float Previous trading day IV (percentage) hv_30d float 30-day historical volatility (percentage) hv_30d_percentile float 30-day HV percentile hv_60d float 60-day historical volatility (percentage) hv_60d_percentile float 60-day HV percentile hv_90d float 90-day historical volatility (percentage) hv_90d_percentile float 90-day HV percentile hv_120d float 120-day historical volatility (percentage) hv_120d_percentile float 120-day HV percentile hv_365d float 365-day historical volatility (percentage) hv_365d_percentile float 365-day HV percentile
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
Description
Get option underlying overview data
Parameters
message C2S
{
repeated Qot_Common.Security ownerList = 1; //Option underlying stock list, max 500
optional int32 indexOptionType = 2; //Qot_Common.IndexOptionType, index option type, for HSI/HSCEI only
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
- Returns
message HVItem
{
required int32 timeRange = 1; //Qot_OptionCommon.OptionHVTimeRange, HV time range
required double hv = 2; //Historical volatility (percentage)
optional double hvPercentile = 3; //HV percentile (percentage)
}
message UnderlyingData
{
required Qot_Common.Security owner = 1; //Option underlying stock
optional string code = 2; //Stock code
optional string name = 3; //Underlying name
optional int64 callVolume = 4; //Call option volume
optional int64 putVolume = 5; //Put option volume
optional int64 callOpenInterest = 6; //Call option open interest (T-1 delayed)
optional int64 putOpenInterest = 7; //Put option open interest (T-1 delayed)
optional double iv = 8; //Implied volatility (percentage)
optional double ivRank = 9; //IV rank percentile (percentage)
optional double ivPercentile = 10; //IV percentile (percentage)
repeated HVItem hvList = 11; //Historical volatility list (multiple time ranges)
optional double preIV = 12; //Previous trading day IV (percentage)
}
message S2C
{
repeated UnderlyingData underlyingDataList = 1; //Underlying latest data 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
- Interface call result, structure refer to RetType
Protocol ID
3303
uint GetOptionUnderlyingOverview(Qot_GetOptionUnderlyingOverview.Request req); virtual void OnReply_GetOptionUnderlyingOverview(MMAPI_Conn client, uint nSerialNo, Qot_GetOptionUnderlyingOverview.Response rsp);
Description
Get option underlying overview data
Parameters
message C2S
{
repeated Qot_Common.Security ownerList = 1; //Option underlying stock list, max 500
optional int32 indexOptionType = 2; //Qot_Common.IndexOptionType, index option type, for HSI/HSCEI only
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
- Returns
message HVItem
{
required int32 timeRange = 1; //Qot_OptionCommon.OptionHVTimeRange, HV time range
required double hv = 2; //Historical volatility (percentage)
optional double hvPercentile = 3; //HV percentile (percentage)
}
message UnderlyingData
{
required Qot_Common.Security owner = 1; //Option underlying stock
optional string code = 2; //Stock code
optional string name = 3; //Underlying name
optional int64 callVolume = 4; //Call option volume
optional int64 putVolume = 5; //Put option volume
optional int64 callOpenInterest = 6; //Call option open interest (T-1 delayed)
optional int64 putOpenInterest = 7; //Put option open interest (T-1 delayed)
optional double iv = 8; //Implied volatility (percentage)
optional double ivRank = 9; //IV rank percentile (percentage)
optional double ivPercentile = 10; //IV percentile (percentage)
repeated HVItem hvList = 11; //Historical volatility list (multiple time ranges)
optional double preIV = 12; //Previous trading day IV (percentage)
}
message S2C
{
repeated UnderlyingData underlyingDataList = 1; //Underlying latest data 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
- Interface call result, structure refer to RetType
Protocol ID
3303
int getOptionUnderlyingOverview(Qot_GetOptionUnderlyingOverview.Request req) onReply_GetOptionUnderlyingOverview(MMAPI_Conn client, int nSerialNo, Qot_GetOptionUnderlyingOverview.Response rsp)
Description
Get option underlying overview data
Parameters
message C2S
{
repeated Qot_Common.Security ownerList = 1; //Option underlying stock list, max 500
optional int32 indexOptionType = 2; //Qot_Common.IndexOptionType, index option type, for HSI/HSCEI only
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
- Returns
message HVItem
{
required int32 timeRange = 1; //Qot_OptionCommon.OptionHVTimeRange, HV time range
required double hv = 2; //Historical volatility (percentage)
optional double hvPercentile = 3; //HV percentile (percentage)
}
message UnderlyingData
{
required Qot_Common.Security owner = 1; //Option underlying stock
optional string code = 2; //Stock code
optional string name = 3; //Underlying name
optional int64 callVolume = 4; //Call option volume
optional int64 putVolume = 5; //Put option volume
optional int64 callOpenInterest = 6; //Call option open interest (T-1 delayed)
optional int64 putOpenInterest = 7; //Put option open interest (T-1 delayed)
optional double iv = 8; //Implied volatility (percentage)
optional double ivRank = 9; //IV rank percentile (percentage)
optional double ivPercentile = 10; //IV percentile (percentage)
repeated HVItem hvList = 11; //Historical volatility list (multiple time ranges)
optional double preIV = 12; //Previous trading day IV (percentage)
}
message S2C
{
repeated UnderlyingData underlyingDataList = 1; //Underlying latest data 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
- Interface call result, structure refer to RetType
Protocol 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;
Description
Get option underlying overview data
Parameters
message C2S
{
repeated Qot_Common.Security ownerList = 1; //Option underlying stock list, max 500
optional int32 indexOptionType = 2; //Qot_Common.IndexOptionType, index option type, for HSI/HSCEI only
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
- Returns
message HVItem
{
required int32 timeRange = 1; //Qot_OptionCommon.OptionHVTimeRange, HV time range
required double hv = 2; //Historical volatility (percentage)
optional double hvPercentile = 3; //HV percentile (percentage)
}
message UnderlyingData
{
required Qot_Common.Security owner = 1; //Option underlying stock
optional string code = 2; //Stock code
optional string name = 3; //Underlying name
optional int64 callVolume = 4; //Call option volume
optional int64 putVolume = 5; //Put option volume
optional int64 callOpenInterest = 6; //Call option open interest (T-1 delayed)
optional int64 putOpenInterest = 7; //Put option open interest (T-1 delayed)
optional double iv = 8; //Implied volatility (percentage)
optional double ivRank = 9; //IV rank percentile (percentage)
optional double ivPercentile = 10; //IV percentile (percentage)
repeated HVItem hvList = 11; //Historical volatility list (multiple time ranges)
optional double preIV = 12; //Previous trading day IV (percentage)
}
message S2C
{
repeated UnderlyingData underlyingDataList = 1; //Underlying latest data 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
- Interface call result, structure refer to RetType
Protocol 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: populate c2s fields per proto
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)
Description
Get option underlying overview data
Parameters
message C2S
{
repeated Qot_Common.Security ownerList = 1; //Option underlying stock list, max 500
optional int32 indexOptionType = 2; //Qot_Common.IndexOptionType, index option type, for HSI/HSCEI only
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
- Returns
message HVItem
{
required int32 timeRange = 1; //Qot_OptionCommon.OptionHVTimeRange, HV time range
required double hv = 2; //Historical volatility (percentage)
optional double hvPercentile = 3; //HV percentile (percentage)
}
message UnderlyingData
{
required Qot_Common.Security owner = 1; //Option underlying stock
optional string code = 2; //Stock code
optional string name = 3; //Underlying name
optional int64 callVolume = 4; //Call option volume
optional int64 putVolume = 5; //Put option volume
optional int64 callOpenInterest = 6; //Call option open interest (T-1 delayed)
optional int64 putOpenInterest = 7; //Put option open interest (T-1 delayed)
optional double iv = 8; //Implied volatility (percentage)
optional double ivRank = 9; //IV rank percentile (percentage)
optional double ivPercentile = 10; //IV percentile (percentage)
repeated HVItem hvList = 11; //Historical volatility list (multiple time ranges)
optional double preIV = 12; //Previous trading day IV (percentage)
}
message S2C
{
repeated UnderlyingData underlyingDataList = 1; //Underlying latest data 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
- Interface call result, structure refer to RetType
Protocol 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
Rate Limit
- Maximum 60 requests per 30 seconds