# 获取事件合约快照
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_event_contract_snapshot(code_list)
介绍
获取事件合约的快照数据,包括最新价、累计成交量、YES/NO 买一卖一等实时行情字段。
参数
参数 类型 说明 code_list list 事件合约代码列表,例如 ['EC.KXODIMATCH-26JUL140600INDENG-IND'];传单个 str 会自动包装为列表返回
参数 类型 说明 ret RET_CODE 接口调用结果 data pd.DataFrame 当 ret == RET_OK,返回事件合约快照数据 str 当 ret != RET_OK,返回错误描述 返回的 DataFrame 字段如下:
字段 类型 说明 code str 合约代码 name str 合约名称(多语言) event_code str 所属 Event 代码 yes_sub_title str YES 子标题(多语言) no_sub_title str NO 子标题(多语言) status str 合约状态,参见 ECStatus price float 最新价格 cumulative_volume float 累计成交量 yes_bid float YES 买一 yes_bid_size float YES 买一量 yes_ask float YES 卖一 yes_ask_size float YES 卖一量 no_bid float NO 买一 no_bid_size float NO 买一量 no_ask float NO 卖一 no_ask_size float NO 卖一量 last_trade_time str 最新一笔成交时间(yyyy-MM-dd HH:mm:ss) volume_24h float 24h 成交量 open_interest float 持仓量 Example
from futu import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data = quote_ctx.get_event_contract_snapshot(
code_list=['EC.KXODIMATCH-26JUL140600INDENG-IND']
)
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 event_code yes_sub_title no_sub_title status price cumulative_volume yes_bid yes_bid_size yes_ask yes_ask_size no_bid no_bid_size no_ask no_ask_size last_trade_time volume_24h open_interest
0 EC.KXODIMATCH-26JUL140600INDENG-IND England vs India Winner? EC.KXODIMATCH-26JUL140600INDENG.EVENT India India ACTIVE 0.5 18746.7 0.5 1030.0 0.51 2650.6 0.49 2650.6 0.5 1030.0 2026-07-13 04:34:55 17744.76 16983.43
2
# Qot_GetEventContractSnapshot.proto
介绍
获取事件合约的快照数据。
参数
message C2S
{
repeated Qot_Common.Security securityList = 1; // 合约标的列表
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
- 股票结构参见 Security
- 返回
// 快照数据项
message SnapshotItem
{
required Qot_Common.Security code = 1; // 合约代码
optional string name = 2; // 合约名称(多语言)
optional Qot_Common.Security event_code = 3; // 所属 Event 标的
optional string yes_sub_title = 4; // YES 子标题(多语言)
optional string no_sub_title = 5; // NO 子标题(多语言)
optional Qot_Common.EC_Status status = 6; // 合约状态
optional double price = 7; // 最新价格
optional double cumulative_volume = 8; // 累计成交量
optional double yes_bid = 9; // YES 买一
optional double yes_bid_size = 10; // YES 买一量
optional double yes_ask = 11; // YES 卖一
optional double yes_ask_size = 12; // YES 卖一量
optional double no_bid = 13; // NO 买一
optional double no_bid_size = 14; // NO 买一量
optional double no_ask = 15; // NO 卖一
optional double no_ask_size = 16; // NO 卖一量
optional string last_trade_time = 17; // 最新一笔成交时间(yyyy-MM-dd HH:mm:ss)
optional double volume_24h = 18; // 24h 成交量
optional double open_interest = 19; // 持仓量
}
message S2C
{
repeated SnapshotItem snapshotList = 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
36
uint GetEventContractSnapshot(GetEventContractSnapshot.Request req);
virtual void OnReply_GetEventContractSnapshot(FTAPI_Conn client, uint nSerialNo, GetEventContractSnapshot.Response rsp);
介绍
获取事件合约的快照数据。
参数
message C2S
{
repeated Qot_Common.Security securityList = 1; // 合约标的列表
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
- 股票结构参见 Security
- 返回
message SnapshotItem
{
required Qot_Common.Security code = 1;
optional string name = 2;
optional Qot_Common.Security event_code = 3;
optional string yes_sub_title = 4;
optional string no_sub_title = 5;
optional Qot_Common.EC_Status status = 6;
optional double price = 7;
optional double cumulative_volume = 8;
optional double yes_bid = 9;
optional double yes_bid_size = 10;
optional double yes_ask = 11;
optional double yes_ask_size = 12;
optional double no_bid = 13;
optional double no_bid_size = 14;
optional double no_ask = 15;
optional double no_ask_size = 16;
optional string last_trade_time = 17;
optional double volume_24h = 18;
optional double open_interest = 19;
}
message S2C
{
repeated SnapshotItem snapshotList = 1;
}
message Response
{
required int32 retType = 1 [default = -400];
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
- 接口调用结果,结构参见 RetType
- Example
public class Program : FTSPI_Qot, FTSPI_Conn
{
FTAPI_Qot qot = new FTAPI_Qot();
public Program()
{
qot.SetClientInfo("csharp", 1);
qot.SetConnCallback(this);
qot.SetQotCallback(this);
}
public void Start()
{
qot.InitConnect("127.0.0.1", (ushort)11111, false);
}
public void OnInitConnect(FTAPI_Conn client, long errCode, String desc)
{
if (errCode != 0) return;
QotCommon.Security sec = QotCommon.Security.CreateBuilder()
.SetMarket((int)QotCommon.QotMarket.QotMarket_EventContract)
.SetCode("EC.KXODIMATCH-26JUL140600INDENG-IND").Build();
var c2s = GetEventContractSnapshot.C2S.CreateBuilder()
.AddSecurity(sec).Build();
var req = GetEventContractSnapshot.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetEventContractSnapshot(req);
Console.Write("Send GetEventContractSnapshot: {0}\n", seqNo);
}
public void OnReply_GetEventContractSnapshot(FTAPI_Conn client, uint nSerialNo, GetEventContractSnapshot.Response rsp)
{
Console.Write("Reply: {0} {1}\n", nSerialNo, rsp.ToString());
}
public static void Main(String[] args)
{
FTAPI.Init();
new Program().Start();
while (true) Thread.Sleep(1000 * 600);
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
- Output
connect
Request GetEventContractSnapshot SerialNo: 1
OnReply_GetEventContractSnapshot SerialNo: 1
{
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"snapshotList": [
{
"code": {"market": 101, "code": "EC.KXODIMATCH-26JUL140600INDENG-IND"},
"name": "England vs India Winner?",
"status": 2,
"price": 0.5,
"cumulative_volume": 18746.7,
"yes_bid": 0.5,
"yes_bid_size": 1030.0,
"yes_ask": 0.51,
"yes_ask_size": 2650.6,
"no_bid": 0.49,
"no_bid_size": 2650.6,
"no_ask": 0.5,
"no_ask_size": 1030.0,
"last_trade_time": "2026-07-13 04:34:55",
"volume_24h": 17744.76,
"open_interest": 16983.43
}
]
}
}
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
int getEventContractSnapshot(QotGetEventContractSnapshot.Request req);
void onReply_GetEventContractSnapshot(FTAPI_Conn client, int nSerialNo, QotGetEventContractSnapshot.Response rsp);
介绍
获取事件合约的快照数据。
参数
message C2S
{
repeated Qot_Common.Security securityList = 1;
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
- 股票结构参见 Security
- 返回
message SnapshotItem
{
required Qot_Common.Security code = 1;
optional string name = 2;
optional Qot_Common.Security event_code = 3;
optional string yes_sub_title = 4;
optional string no_sub_title = 5;
optional Qot_Common.EC_Status status = 6;
optional double price = 7;
optional double cumulative_volume = 8;
optional double yes_bid = 9;
optional double yes_bid_size = 10;
optional double yes_ask = 11;
optional double yes_ask_size = 12;
optional double no_bid = 13;
optional double no_bid_size = 14;
optional double no_ask = 15;
optional double no_ask_size = 16;
optional string last_trade_time = 17;
optional double volume_24h = 18;
optional double open_interest = 19;
}
message S2C
{
repeated SnapshotItem snapshotList = 1;
}
message Response
{
required int32 retType = 1 [default = -400];
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
- 接口调用结果,结构参见 RetType
- Example
public class Program implements FTSPI_Qot, FTSPI_Conn {
private FTAPI_Conn_Qot qot = new FTAPI_Conn_Qot();
public Program() {
qot.setClientInfo("java", 1);
qot.setConnCallback(this);
qot.setQotCallback(this);
}
public void start() {
qot.initConnect("127.0.0.1", (short) 11111, false);
}
@Override
public void onInitConnect(FTAPI_Conn client, long errCode, String desc) {
if (errCode != 0) return;
QotCommon.Security sec = QotCommon.Security.newBuilder()
.setMarket(QotCommon.QotMarket.QotMarket_EventContract_VALUE)
.setCode("EC.KXODIMATCH-26JUL140600INDENG-IND").build();
QotGetEventContractSnapshot.C2S c2s = QotGetEventContractSnapshot.C2S.newBuilder()
.addSecurity(sec).build();
QotGetEventContractSnapshot.Request req = QotGetEventContractSnapshot.Request.newBuilder()
.setC2S(c2s).build();
int seqNo = qot.getEventContractSnapshot(req);
System.out.println("Send GetEventContractSnapshot: " + seqNo);
}
@Override
public void onReply_GetEventContractSnapshot(FTAPI_Conn client, int nSerialNo, QotGetEventContractSnapshot.Response rsp) {
System.out.println("Reply: " + nSerialNo + " " + rsp.toString());
}
public static void main(String[] args) {
FTAPI.init();
new Program().start();
while (true) {
try { Thread.sleep(1000 * 600); } catch (InterruptedException e) {}
}
}
}
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
- Output
connect
Request GetEventContractSnapshot SerialNo: 1
OnReply_GetEventContractSnapshot SerialNo: 1
{
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"snapshotList": [
{
"code": {"market": 101, "code": "EC.KXODIMATCH-26JUL140600INDENG-IND"},
"name": "England vs India Winner?",
"status": 2,
"price": 0.5,
"cumulative_volume": 18746.7,
"yes_bid": 0.5,
"yes_bid_size": 1030.0,
"yes_ask": 0.51,
"yes_ask_size": 2650.6,
"no_bid": 0.49,
"no_bid_size": 2650.6,
"no_ask": 0.5,
"no_ask_size": 1030.0,
"last_trade_time": "2026-07-13 04:34:55",
"volume_24h": 17744.76,
"open_interest": 16983.43
}
]
}
}
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
Futu::u32_t GetEventContractSnapshot(const Qot_GetEventContractSnapshot::Request &stReq);
virtual void OnReply_GetEventContractSnapshot(Futu::u32_t nSerialNo, const Qot_GetEventContractSnapshot::Response &stRsp) = 0;
介绍
获取事件合约的快照数据。
参数
message C2S
{
repeated Qot_Common.Security securityList = 1; // 合约标的列表
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
- 股票结构参见 Security
- 返回
// 快照数据项
message SnapshotItem
{
required Qot_Common.Security code = 1; // 合约代码
optional string name = 2; // 合约名称(多语言)
optional Qot_Common.Security event_code = 3; // 所属 Event 标的
optional string yes_sub_title = 4; // YES 子标题(多语言)
optional string no_sub_title = 5; // NO 子标题(多语言)
optional Qot_Common.EC_Status status = 6; // 合约状态
optional double price = 7; // 最新价格
optional double cumulative_volume = 8; // 累计成交量
optional double yes_bid = 9; // YES 买一
optional double yes_bid_size = 10; // YES 买一量
optional double yes_ask = 11; // YES 卖一
optional double yes_ask_size = 12; // YES 卖一量
optional double no_bid = 13; // NO 买一
optional double no_bid_size = 14; // NO 买一量
optional double no_ask = 15; // NO 卖一
optional double no_ask_size = 16; // NO 卖一量
optional string last_trade_time = 17; // 最新一笔成交时间(yyyy-MM-dd HH:mm:ss)
optional double volume_24h = 18; // 24h 成交量
optional double open_interest = 19; // 持仓量
}
message S2C
{
repeated SnapshotItem snapshotList = 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
36
- Example
class Program : public FTSPI_Qot, public FTSPI_Trd, public FTSPI_Conn
{
public:
Program() {
m_pQotApi = FTAPI::CreateQotApi();
m_pQotApi->RegisterQotSpi(this);
m_pQotApi->RegisterConnSpi(this);
}
~Program() {
if (m_pQotApi != nullptr)
{
m_pQotApi->UnregisterQotSpi();
m_pQotApi->UnregisterConnSpi();
FTAPI::ReleaseQotApi(m_pQotApi);
m_pQotApi = nullptr;
}
}
void Start() {
m_pQotApi->InitConnect("127.0.0.1", 11111, false);
}
virtual void OnInitConnect(FTAPI_Conn* pConn, Futu::i64_t nErrCode, const char* strDesc) {
cout << "connect" << endl;
// 组包
Qot_GetEventContractSnapshot::Request req;
Qot_GetEventContractSnapshot::C2S *c2s = req.mutable_c2s();
Qot_Common::Security *sec = c2s->add_securitylist();
sec->set_code("EC.KXODIMATCH-26JUL140600INDENG-IND");
sec->set_market(Qot_Common::QotMarket::QotMarket_EventContract);
m_GetEventContractSnapshotSerialNo = m_pQotApi->GetEventContractSnapshot(req);
cout << "Request GetEventContractSnapshot SerialNo: " << m_GetEventContractSnapshotSerialNo << endl;
}
virtual void OnReply_GetEventContractSnapshot(Futu::u32_t nSerialNo, const Qot_GetEventContractSnapshot::Response &stRsp) {
if (nSerialNo == m_GetEventContractSnapshotSerialNo)
{
cout << "OnReply_GetEventContractSnapshot SerialNo: " << nSerialNo << endl;
// 解析内部结构打印出来
// ProtoBufToBodyData和UTF8ToLocal函数的定义参见Sample中的tool.h文件
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
}
protected:
FTAPI_Qot *m_pQotApi;
Futu::u32_t m_GetEventContractSnapshotSerialNo;
};
int32_t main(int32_t argc, char** argv)
{
FTAPI::Init();
{
Program program;
program.Start();
getchar();
}
protobuf::ShutdownProtobufLibrary();
FTAPI::UnInit();
return 0;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
- Output
connect
Request GetEventContractSnapshot SerialNo: 1
OnReply_GetEventContractSnapshot SerialNo: 1
{
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"snapshotList": [
{
"code": {"market": 101, "code": "EC.KXODIMATCH-26JUL140600INDENG-IND"},
"name": "England vs India Winner?",
"status": 2,
"price": 0.5,
"cumulative_volume": 18746.7,
"yes_bid": 0.5,
"yes_bid_size": 1030.0,
"yes_ask": 0.51,
"yes_ask_size": 2650.6,
"no_bid": 0.49,
"no_bid_size": 2650.6,
"no_ask": 0.5,
"no_ask_size": 1030.0,
"last_trade_time": "2026-07-13 04:34:55",
"volume_24h": 17744.76,
"open_interest": 16983.43
}
]
}
}
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
GetEventContractSnapshot(req);
介绍
获取事件合约的快照数据,包括最新价、累计成交量、YES/NO 买一卖一等实时行情字段。
参数
// 快照数据项
message SnapshotItem {
required Qot_Common.Security code = 1; // 合约代码
optional string name = 2; // 合约名称(多语言)
optional Qot_Common.Security event_code = 3; // 所属 Event 标的
optional string yes_sub_title = 4; // YES 子标题(多语言)
optional string no_sub_title = 5; // NO 子标题(多语言)
optional Qot_Common.EC_Status status = 6; // 合约状态
optional double price = 7; // 最新价格
optional double cumulative_volume = 8; // 累计成交量
optional double yes_bid = 9; // YES 买一
optional double yes_bid_size = 10; // YES 买一量
optional double yes_ask = 11; // YES 卖一
optional double yes_ask_size = 12; // YES 卖一量
optional double no_bid = 13; // NO 买一
optional double no_bid_size = 14; // NO 买一量
optional double no_ask = 15; // NO 卖一
optional double no_ask_size = 16; // NO 卖一量
optional string last_trade_time = 17; // 最新一笔成交时间
optional double volume_24h = 18; // 24h 成交量
optional double open_interest = 19; // 持仓量
}
message C2S {
repeated Qot_Common.Security securityList = 1; // 合约标的列表
}
message Request {
required C2S c2s = 1;
}
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
- 返回
message S2C {
repeated SnapshotItem snapshotList = 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
- 接口调用结果,结构参见 RetType
- Example
import ftWebsocket from "futu-api";
import { Common, Qot_Common } from "futu-api/proto";
import beautify from "js-beautify";
function GetEventContractSnapshot() {
const { RetType } = Common;
let [addr, port, enable_ssl, key] = ["127.0.0.1", 11111, false, ""];
let websocket = new ftWebsocket();
websocket.onlogin = async (ret, msg) => {
if (!ret) { console.log("start error", msg); return; }
try {
const req = { c2s: { securityList: [{ market: QotMarket.QotMarket_EventContract, code: "EC.KXODIMATCH-26JUL140600INDENG-IND" }] } };
let { errCode, retMsg, retType, s2c } = await websocket.GetEventContractSnapshot(req);
console.log("GetEventContractSnapshot: errCode %d, retMsg %s, retType %d", errCode, retMsg, retType);
if (retType == RetType.RetType_Succeed) {
console.log(beautify(JSON.stringify(s2c), { indent_size: 2, space_in_empty_paren: true }));
}
} catch (error) {
console.log("error:", error);
}
};
websocket.start(addr, port, enable_ssl, key);
setTimeout(() => { websocket.stop(); console.log("stop"); }, 5000);
}
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
- Output
GetEventContractSnapshot: errCode 0, retMsg , retType 0
{
"snapshotList": [{
"code": {
"market": 101,
"code": "EC.KXODIMATCH-26JUL140600INDENG-IND"
},
"name": "England vs India Winner?",
"status": 2,
"price": 0.5,
"cumulativeVolume": 18746.7,
"yesBid": 0.5,
"yesBidSize": 1030,
"yesAsk": 0.51,
"yesAskSize": 2650.6,
"noBid": 0.49,
"noBidSize": 2650.6,
"noAsk": 0.5,
"noAskSize": 1030,
"lastTradeTime": "2026-07-13 04:34:55",
"volume24h": 17744.76,
"openInterest": 16983.43
}]
}
stop
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
接口限制
- 每 30 秒内最多请求 10 次获取事件合约快照接口
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_event_contract_snapshot(code_list)
介绍
获取事件合约的快照数据,包括最新价、累计成交量、YES/NO 买一卖一等实时行情字段。
参数
参数 类型 说明 code_list list 事件合约代码列表,例如 ['EC.KXODIMATCH-26JUL140600INDENG-IND']返回
参数 类型 说明 ret RET_CODE 接口调用结果 data pd.DataFrame 当 ret == RET_OK,返回事件合约快照数据 str 当 ret != RET_OK,返回错误描述 Example
from moomoo import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data = quote_ctx.get_event_contract_snapshot(code_list=['EC.KXODIMATCH-26JUL140600INDENG-IND'])
if ret == RET_OK:
print(data)
else:
print('error:', data)
quote_ctx.close()
2
3
4
5
6
7
8
9
- Output
code name event_code yes_sub_title no_sub_title status price cumulative_volume yes_bid yes_bid_size yes_ask yes_ask_size no_bid no_bid_size no_ask no_ask_size last_trade_time volume_24h open_interest
0 EC.KXODIMATCH-26JUL140600INDENG-IND England vs India Winner? EC.KXODIMATCH-26JUL140600INDENG.EVENT India India ACTIVE 0.5 18746.7 0.5 1030.0 0.51 2650.6 0.49 2650.6 0.5 1030.0 2026-07-13 04:34:55 17744.76 16983.43
2
# Qot_GetEventContractSnapshot.proto
介绍
获取事件合约的快照数据。
参数
message C2S
{
repeated Qot_Common.Security securityList = 1; // 合约标的列表
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
- 股票结构参见 Security
- 返回
// 快照数据项
message SnapshotItem
{
required Qot_Common.Security code = 1; // 合约代码
optional string name = 2; // 合约名称(多语言)
optional Qot_Common.Security event_code = 3; // 所属 Event 标的
optional string yes_sub_title = 4; // YES 子标题(多语言)
optional string no_sub_title = 5; // NO 子标题(多语言)
optional Qot_Common.EC_Status status = 6; // 合约状态
optional double price = 7; // 最新价格
optional double cumulative_volume = 8; // 累计成交量
optional double yes_bid = 9; // YES 买一
optional double yes_bid_size = 10; // YES 买一量
optional double yes_ask = 11; // YES 卖一
optional double yes_ask_size = 12; // YES 卖一量
optional double no_bid = 13; // NO 买一
optional double no_bid_size = 14; // NO 买一量
optional double no_ask = 15; // NO 卖一
optional double no_ask_size = 16; // NO 卖一量
optional string last_trade_time = 17; // 最新一笔成交时间(yyyy-MM-dd HH:mm:ss)
optional double volume_24h = 18; // 24h 成交量
optional double open_interest = 19; // 持仓量
}
message S2C
{
repeated SnapshotItem snapshotList = 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
36
uint GetEventContractSnapshot(GetEventContractSnapshot.Request req);
virtual void OnReply_GetEventContractSnapshot(MMAPI_Conn client, uint nSerialNo, GetEventContractSnapshot.Response rsp);
介绍
获取事件合约的快照数据。
参数
message C2S
{
repeated Qot_Common.Security securityList = 1;
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
- 股票结构参见 Security
- 返回
message SnapshotItem
{
required Qot_Common.Security code = 1;
optional string name = 2;
optional Qot_Common.Security event_code = 3;
optional string yes_sub_title = 4;
optional string no_sub_title = 5;
optional Qot_Common.EC_Status status = 6;
optional double price = 7;
optional double cumulative_volume = 8;
optional double yes_bid = 9;
optional double yes_bid_size = 10;
optional double yes_ask = 11;
optional double yes_ask_size = 12;
optional double no_bid = 13;
optional double no_bid_size = 14;
optional double no_ask = 15;
optional double no_ask_size = 16;
optional string last_trade_time = 17;
optional double volume_24h = 18;
optional double open_interest = 19;
}
message S2C
{
repeated SnapshotItem snapshotList = 1;
}
message Response
{
required int32 retType = 1 [default = -400];
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
- 接口调用结果,结构参见 RetType
- Example
public class Program : MMSPI_Qot, MMSPI_Conn
{
MMAPI_Qot qot = new MMAPI_Qot();
public Program()
{
qot.SetClientInfo("csharp", 1);
qot.SetConnCallback(this);
qot.SetQotCallback(this);
}
public void Start()
{
qot.InitConnect("127.0.0.1", (ushort)11111, false);
}
public void OnInitConnect(MMAPI_Conn client, long errCode, String desc)
{
if (errCode != 0) return;
QotCommon.Security sec = QotCommon.Security.CreateBuilder()
.SetMarket((int)QotCommon.QotMarket.QotMarket_EventContract)
.SetCode("EC.KXODIMATCH-26JUL140600INDENG-IND").Build();
var c2s = GetEventContractSnapshot.C2S.CreateBuilder()
.AddSecurity(sec).Build();
var req = GetEventContractSnapshot.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetEventContractSnapshot(req);
Console.Write("Send GetEventContractSnapshot: {0}\n", seqNo);
}
public void OnReply_GetEventContractSnapshot(MMAPI_Conn client, uint nSerialNo, GetEventContractSnapshot.Response rsp)
{
Console.Write("Reply: {0} {1}\n", nSerialNo, rsp.ToString());
}
public static void Main(String[] args)
{
MMAPI.Init();
new Program().Start();
while (true) Thread.Sleep(1000 * 600);
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
- Output
connect
Request GetEventContractSnapshot SerialNo: 1
OnReply_GetEventContractSnapshot SerialNo: 1
{
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"snapshotList": [
{
"code": {"market": 101, "code": "EC.KXODIMATCH-26JUL140600INDENG-IND"},
"name": "England vs India Winner?",
"status": 2,
"price": 0.5,
"cumulative_volume": 18746.7,
"yes_bid": 0.5,
"yes_bid_size": 1030.0,
"yes_ask": 0.51,
"yes_ask_size": 2650.6,
"no_bid": 0.49,
"no_bid_size": 2650.6,
"no_ask": 0.5,
"no_ask_size": 1030.0,
"last_trade_time": "2026-07-13 04:34:55",
"volume_24h": 17744.76,
"open_interest": 16983.43
}
]
}
}
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
int getEventContractSnapshot(QotGetEventContractSnapshot.Request req);
void onReply_GetEventContractSnapshot(MMAPI_Conn client, int nSerialNo, QotGetEventContractSnapshot.Response rsp);
介绍
获取事件合约的快照数据。
参数
message C2S
{
repeated Qot_Common.Security securityList = 1;
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
- 股票结构参见 Security
- 返回
message SnapshotItem
{
required Qot_Common.Security code = 1;
optional string name = 2;
optional Qot_Common.Security event_code = 3;
optional string yes_sub_title = 4;
optional string no_sub_title = 5;
optional Qot_Common.EC_Status status = 6;
optional double price = 7;
optional double cumulative_volume = 8;
optional double yes_bid = 9;
optional double yes_bid_size = 10;
optional double yes_ask = 11;
optional double yes_ask_size = 12;
optional double no_bid = 13;
optional double no_bid_size = 14;
optional double no_ask = 15;
optional double no_ask_size = 16;
optional string last_trade_time = 17;
optional double volume_24h = 18;
optional double open_interest = 19;
}
message S2C
{
repeated SnapshotItem snapshotList = 1;
}
message Response
{
required int32 retType = 1 [default = -400];
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
- 接口调用结果,结构参见 RetType
- Example
public class Program implements MMSPI_Qot, MMSPI_Conn {
private MMAPI_Conn_Qot qot = new MMAPI_Conn_Qot();
public Program() {
qot.setClientInfo("java", 1);
qot.setConnCallback(this);
qot.setQotCallback(this);
}
public void start() {
qot.initConnect("127.0.0.1", (short) 11111, false);
}
@Override
public void onInitConnect(MMAPI_Conn client, long errCode, String desc) {
if (errCode != 0) return;
QotCommon.Security sec = QotCommon.Security.newBuilder()
.setMarket(QotCommon.QotMarket.QotMarket_EventContract_VALUE)
.setCode("EC.KXODIMATCH-26JUL140600INDENG-IND").build();
QotGetEventContractSnapshot.C2S c2s = QotGetEventContractSnapshot.C2S.newBuilder()
.addSecurity(sec).build();
QotGetEventContractSnapshot.Request req = QotGetEventContractSnapshot.Request.newBuilder()
.setC2S(c2s).build();
int seqNo = qot.getEventContractSnapshot(req);
System.out.println("Send GetEventContractSnapshot: " + seqNo);
}
@Override
public void onReply_GetEventContractSnapshot(MMAPI_Conn client, int nSerialNo, QotGetEventContractSnapshot.Response rsp) {
System.out.println("Reply: " + nSerialNo + " " + rsp.toString());
}
public static void main(String[] args) {
MMAPI.init();
new Program().start();
while (true) {
try { Thread.sleep(1000 * 600); } catch (InterruptedException e) {}
}
}
}
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
- Output
connect
Request GetEventContractSnapshot SerialNo: 1
OnReply_GetEventContractSnapshot SerialNo: 1
{
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"snapshotList": [
{
"code": {"market": 101, "code": "EC.KXODIMATCH-26JUL140600INDENG-IND"},
"name": "England vs India Winner?",
"status": 2,
"price": 0.5,
"cumulative_volume": 18746.7,
"yes_bid": 0.5,
"yes_bid_size": 1030.0,
"yes_ask": 0.51,
"yes_ask_size": 2650.6,
"no_bid": 0.49,
"no_bid_size": 2650.6,
"no_ask": 0.5,
"no_ask_size": 1030.0,
"last_trade_time": "2026-07-13 04:34:55",
"volume_24h": 17744.76,
"open_interest": 16983.43
}
]
}
}
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
moomoo::u32_t GetEventContractSnapshot(const Qot_GetEventContractSnapshot::Request &stReq);
virtual void OnReply_GetEventContractSnapshot(moomoo::u32_t nSerialNo, const Qot_GetEventContractSnapshot::Response &stRsp) = 0;
介绍
获取事件合约的快照数据。
参数
message C2S
{
repeated Qot_Common.Security securityList = 1; // 合约标的列表
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
- 股票结构参见 Security
- 返回
// 快照数据项
message SnapshotItem
{
required Qot_Common.Security code = 1; // 合约代码
optional string name = 2; // 合约名称(多语言)
optional Qot_Common.Security event_code = 3; // 所属 Event 标的
optional string yes_sub_title = 4; // YES 子标题(多语言)
optional string no_sub_title = 5; // NO 子标题(多语言)
optional Qot_Common.EC_Status status = 6; // 合约状态
optional double price = 7; // 最新价格
optional double cumulative_volume = 8; // 累计成交量
optional double yes_bid = 9; // YES 买一
optional double yes_bid_size = 10; // YES 买一量
optional double yes_ask = 11; // YES 卖一
optional double yes_ask_size = 12; // YES 卖一量
optional double no_bid = 13; // NO 买一
optional double no_bid_size = 14; // NO 买一量
optional double no_ask = 15; // NO 卖一
optional double no_ask_size = 16; // NO 卖一量
optional string last_trade_time = 17; // 最新一笔成交时间(yyyy-MM-dd HH:mm:ss)
optional double volume_24h = 18; // 24h 成交量
optional double open_interest = 19; // 持仓量
}
message S2C
{
repeated SnapshotItem snapshotList = 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
36
- Example
class Program : public MMSPI_Qot, public MMSPI_Trd, public MMSPI_Conn
{
public:
Program() {
m_pQotApi = MMAPI::CreateQotApi();
m_pQotApi->RegisterQotSpi(this);
m_pQotApi->RegisterConnSpi(this);
}
~Program() {
if (m_pQotApi != nullptr)
{
m_pQotApi->UnregisterQotSpi();
m_pQotApi->UnregisterConnSpi();
MMAPI::ReleaseQotApi(m_pQotApi);
m_pQotApi = nullptr;
}
}
void Start() {
m_pQotApi->InitConnect("127.0.0.1", 11111, false);
}
virtual void OnInitConnect(MMAPI_Conn* pConn, moomoo::i64_t nErrCode, const char* strDesc) {
cout << "connect" << endl;
// 组包
Qot_GetEventContractSnapshot::Request req;
Qot_GetEventContractSnapshot::C2S *c2s = req.mutable_c2s();
Qot_Common::Security *sec = c2s->add_securitylist();
sec->set_code("EC.KXODIMATCH-26JUL140600INDENG-IND");
sec->set_market(Qot_Common::QotMarket::QotMarket_EventContract);
m_GetEventContractSnapshotSerialNo = m_pQotApi->GetEventContractSnapshot(req);
cout << "Request GetEventContractSnapshot SerialNo: " << m_GetEventContractSnapshotSerialNo << endl;
}
virtual void OnReply_GetEventContractSnapshot(moomoo::u32_t nSerialNo, const Qot_GetEventContractSnapshot::Response &stRsp) {
if (nSerialNo == m_GetEventContractSnapshotSerialNo)
{
cout << "OnReply_GetEventContractSnapshot SerialNo: " << nSerialNo << endl;
// 解析内部结构打印出来
// ProtoBufToBodyData和UTF8ToLocal函数的定义参见Sample中的tool.h文件
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
}
protected:
MMAPI_Qot *m_pQotApi;
moomoo::u32_t m_GetEventContractSnapshotSerialNo;
};
int32_t main(int32_t argc, char** argv)
{
MMAPI::Init();
{
Program program;
program.Start();
getchar();
}
protobuf::ShutdownProtobufLibrary();
MMAPI::UnInit();
return 0;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
- Output
connect
Request GetEventContractSnapshot SerialNo: 1
OnReply_GetEventContractSnapshot SerialNo: 1
{
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"snapshotList": [
{
"code": {"market": 101, "code": "EC.KXODIMATCH-26JUL140600INDENG-IND"},
"name": "England vs India Winner?",
"status": 2,
"price": 0.5,
"cumulative_volume": 18746.7,
"yes_bid": 0.5,
"yes_bid_size": 1030.0,
"yes_ask": 0.51,
"yes_ask_size": 2650.6,
"no_bid": 0.49,
"no_bid_size": 2650.6,
"no_ask": 0.5,
"no_ask_size": 1030.0,
"last_trade_time": "2026-07-13 04:34:55",
"volume_24h": 17744.76,
"open_interest": 16983.43
}
]
}
}
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
GetEventContractSnapshot(req);
介绍
获取事件合约的快照数据,包括最新价、累计成交量、YES/NO 买一卖一等实时行情字段。
参数
// 快照数据项
message SnapshotItem {
required Qot_Common.Security code = 1; // 合约代码
optional string name = 2; // 合约名称(多语言)
optional Qot_Common.Security event_code = 3; // 所属 Event 标的
optional string yes_sub_title = 4; // YES 子标题(多语言)
optional string no_sub_title = 5; // NO 子标题(多语言)
optional Qot_Common.EC_Status status = 6; // 合约状态
optional double price = 7; // 最新价格
optional double cumulative_volume = 8; // 累计成交量
optional double yes_bid = 9; // YES 买一
optional double yes_bid_size = 10; // YES 买一量
optional double yes_ask = 11; // YES 卖一
optional double yes_ask_size = 12; // YES 卖一量
optional double no_bid = 13; // NO 买一
optional double no_bid_size = 14; // NO 买一量
optional double no_ask = 15; // NO 卖一
optional double no_ask_size = 16; // NO 卖一量
optional string last_trade_time = 17; // 最新一笔成交时间
optional double volume_24h = 18; // 24h 成交量
optional double open_interest = 19; // 持仓量
}
message C2S {
repeated Qot_Common.Security securityList = 1; // 合约标的列表
}
message Request {
required C2S c2s = 1;
}
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
- 返回
message S2C {
repeated SnapshotItem snapshotList = 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
- 接口调用结果,结构参见 RetType
- Example
import mmWebsocket from "moomoo-api";
import { Common, Qot_Common } from "moomoo-api/proto";
import beautify from "js-beautify";
function GetEventContractSnapshot() {
const { RetType } = Common;
let [addr, port, enable_ssl, key] = ["127.0.0.1", 11111, false, ""];
let websocket = new mmWebsocket();
websocket.onlogin = async (ret, msg) => {
if (!ret) { console.log("start error", msg); return; }
try {
const req = { c2s: { securityList: [{ market: QotMarket.QotMarket_EventContract, code: "EC.KXODIMATCH-26JUL140600INDENG-IND" }] } };
let { errCode, retMsg, retType, s2c } = await websocket.GetEventContractSnapshot(req);
console.log("GetEventContractSnapshot: errCode %d, retMsg %s, retType %d", errCode, retMsg, retType);
if (retType == RetType.RetType_Succeed) {
console.log(beautify(JSON.stringify(s2c), { indent_size: 2, space_in_empty_paren: true }));
}
} catch (error) {
console.log("error:", error);
}
};
websocket.start(addr, port, enable_ssl, key);
setTimeout(() => { websocket.stop(); console.log("stop"); }, 5000);
}
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
- Output
GetEventContractSnapshot: errCode 0, retMsg , retType 0
{
"snapshotList": [{
"code": {
"market": 101,
"code": "EC.KXODIMATCH-26JUL140600INDENG-IND"
},
"name": "England vs India Winner?",
"status": 2,
"price": 0.5,
"cumulativeVolume": 18746.7,
"yesBid": 0.5,
"yesBidSize": 1030,
"yesAsk": 0.51,
"yesAskSize": 2650.6,
"noBid": 0.49,
"noBidSize": 2650.6,
"noAsk": 0.5,
"noAskSize": 1030,
"lastTradeTime": "2026-07-13 04:34:55",
"volume24h": 17744.76,
"openInterest": 16983.43
}]
}
stop
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
接口限制
- 每 30 秒内最多请求 10 次获取事件合约快照接口
← 取消所有事件合约订阅 获取事件合约摆盘 →