# 获取事件合约
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_event_contract(event_code, next_page=None, count=None)
介绍
根据 Event 代码获取其下挂的事件合约(Contract)列表,含合约类型、时间、状态、结果、交易属性等完整信息,并返回推荐合约。支持分页。
参数
参数 类型 说明 event_code str Event 代码,例如 'EC.KXUFCVICROUND-26JUL11SAIPIM.EVENT'next_page str 翻页标记,首页不传 count int 单页最大返回条数,默认 100,最大 1000 返回
参数 类型 说明 ret RET_CODE 接口调用结果 data dict 当 ret == RET_OK,返回事件合约数据,含 contract_list 与 recommend_contracts str 当 ret != RET_OK,返回错误描述 next_page str 翻页标记,为空表示没有下一页 data 的 dict 结构如下:
键 类型 说明 contract_list pd.DataFrame 事件合约列表(字段见下) recommend_contracts list[dict] 推荐合约列表,每项含 contract_code contract_list 的 DataFrame 字段如下:
字段 类型 说明 contract_code str 合约代码 event_code str 所属 Event 代码 series_code str 所属 Series 代码 contract_type str 合约类型,参见 ECContractType title str 合约标题(多语言) yes_sub_title str YES 子标题(多语言) open_time str 合约开始时间(UTC ISO8601) close_time str 合约结束时间(UTC ISO8601) determination_time str 结果确定时间 settled_time str 结算完成时间 latest_expiration_time str 最新到期时间 status str 合约状态,参见 ECStatus result str 合约结果 settlement_value str 合约结算价值 expiration_value str 合约到期结果 volume str 合约成交量 can_close_early bool 是否可提早结束交易 tick_size str 价位 category str 一级分类标识 tag str 二级分类标识 Example
from futu import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data, next_page = quote_ctx.get_event_contract(
'EC.KXUFCVICROUND-26JUL11SAIPIM.EVENT', count=5
)
if ret == RET_OK:
print(data['contract_list'])
print('推荐合约:', data['recommend_contracts'])
print('next_page:', next_page)
else:
print('error:', data)
quote_ctx.close()
2
3
4
5
6
7
8
9
10
11
12
13
- Output
contract_code event_code series_code contract_type title yes_sub_title open_time close_time determination_time settled_time latest_expiration_time status result settlement_value expiration_value volume can_close_early tick_size category tag
0 EC.KXUFCVICROUND-26JUL11SAIPIM-SAI1 EC.KXUFCVICROUND-26JUL11SAIPIM.EVENT EC.KXUFCVICROUND.SERIES BINARY Will Benoit Saint-Denis win the Benoit Saint-Denis vs. Paddy Pimblett 329 fight in Round 1 N/A 2026-07-08 12:29:00 2026-07-11 23:19:55 2026-07-11 23:20:54 2026-07-11 23:27:06 2026-07-25 22:00:00 FINALIZED No N/A Paddy Pimblett to win in Round 1 N/A True 0.010000000 Hot N/A
1 EC.KXUFCVICROUND-26JUL11SAIPIM-PIM2 EC.KXUFCVICROUND-26JUL11SAIPIM.EVENT EC.KXUFCVICROUND.SERIES BINARY Will Paddy Pimblett win the Benoit Saint-Denis vs. Paddy Pimblett 329 fight in Round 2 N/A 2026-07-08 12:29:00 2026-07-11 23:19:55 2026-07-11 23:20:54 2026-07-11 23:27:06 2026-07-25 22:00:00 FINALIZED No N/A Paddy Pimblett to win in Round 1 N/A True 0.010000000 Hot N/A
2 EC.KXUFCVICROUND-26JUL11SAIPIM-PIM3 EC.KXUFCVICROUND-26JUL11SAIPIM.EVENT EC.KXUFCVICROUND.SERIES BINARY Will Paddy Pimblett win the Benoit Saint-Denis vs. Paddy Pimblett 329 fight in Round 3 N/A 2026-07-08 12:29:00 2026-07-11 23:19:55 2026-07-11 23:20:54 2026-07-11 23:27:06 2026-07-25 22:00:00 FINALIZED No N/A Paddy Pimblett to win in Round 1 N/A True 0.010000000 Hot N/A
3 EC.KXUFCVICROUND-26JUL11SAIPIM-SAI3 EC.KXUFCVICROUND-26JUL11SAIPIM.EVENT EC.KXUFCVICROUND.SERIES BINARY Will Benoit Saint-Denis win the Benoit Saint-Denis vs. Paddy Pimblett 329 fight in Round 3 N/A 2026-07-08 12:29:00 2026-07-11 23:19:55 2026-07-11 23:20:54 2026-07-11 23:27:06 2026-07-25 22:00:00 FINALIZED No N/A Paddy Pimblett to win in Round 1 N/A True 0.010000000 Hot N/A
4 EC.KXUFCVICROUND-26JUL11SAIPIM-PIM1 EC.KXUFCVICROUND-26JUL11SAIPIM.EVENT EC.KXUFCVICROUND.SERIES BINARY Will Paddy Pimblett win the Benoit Saint-Denis vs. Paddy Pimblett 329 fight in Round 1 N/A 2026-07-08 12:29:00 2026-07-11 23:19:55 2026-07-11 23:20:54 2026-07-11 23:27:06 2026-07-25 22:00:00 FINALIZED Yes 1.000000000 Paddy Pimblett to win in Round 1 N/A True 0.010000000 Hot N/A
推荐合约: [{'contract_code': 'EC.KXUFCVICROUND-26JUL11SAIPIM-SAI1'}, {'contract_code': 'EC.KXUFCVICROUND-26JUL11SAIPIM-PIM2'}, {'contract_code': 'EC.KXUFCVICROUND-26JUL11SAIPIM-PIM3'}]
next_page: 5
2
3
4
5
6
7
8
# Qot_GetEventContract.proto
介绍
根据 Event 代码获取其下挂的事件合约列表。
参数
// 合约项
message ContractItem {
// ===== 标识 =====
required Qot_Common.Security contractSecurity = 1; // 合约标的
optional Qot_Common.Security eventSecurity = 2; // 所属 Event
optional Qot_Common.Security seriesSecurity = 3; // 所属 Series
optional Qot_Common.EC_ContractType contractType = 4; // 合约类型 (Binary/Scalar)
// ===== 名称 =====
optional string title = 5; // 合约标题(多语言)
optional string yesSubTitle = 6; // YES 的子标题(多语言)
// ===== 时间(UTC ISO8601 字符串,形如 2025-09-26T18:30:00Z)=====
optional string openTime = 7; // 合约开始时间
optional string closeTime = 8; // 合约结束时间
optional string determinationTime = 9; // 结果确定时间
optional string settledTime = 10; // 结算完成时间
optional string latestExpirationTime = 11; // 最新到期时间
// ===== 状态与结果 =====
optional Qot_Common.EC_Status status = 12; // 合约状态
optional string result = 13; // 合约结果
optional string settlementValue = 14; // 合约结算价值
optional string expirationValue = 15; // 合约到期结果
// ===== 交易属性 =====
optional string notionalValue = 16; // 合约名义价值
optional string liquidity = 17; // 合约流动性
optional string volume = 18; // 合约成交量
optional bool canCloseEarly = 19; // 是否可提早结束交易
optional string tickSize = 20; // 价位
// ===== 分类 =====
optional string category = 21; // 一级分类标识
optional string tag = 22; // 二级分类标识
}
// 推荐合约
message RecommendContract {
required Qot_Common.Security contractSecurity = 1;
}
message C2S {
required Qot_Common.Security event = 1; // Event 标的
optional string nextPage = 2; // 翻页标记(首页不填)
optional int32 count = 3; // 单页最大返回数(默认100,最大1000)
}
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
- 股票结构参见 Security
- 事件合约类型参见 EC_ContractType
- 返回
message S2C {
repeated ContractItem contractList = 1; // 合约列表
repeated RecommendContract recommendContracts = 2; // 推荐合约
optional string nextPage = 3; // 为空表示没有下一页
}
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
协议 ID
3438
数据类型
- 股票结构参见 Security
- 事件合约类型参见 EC_ContractType
- 事件合约状态参见 EC_Status
uint GetEventContract(GetEventContract.Request req);
virtual void OnReply_GetEventContract(FTAPI_Conn client, uint nSerialNo, GetEventContract.Response rsp);
介绍
根据 Event 代码获取其下挂的事件合约列表。
参数
message ContractItem {
required Qot_Common.Security contractSecurity = 1;
optional Qot_Common.Security eventSecurity = 2;
optional Qot_Common.Security seriesSecurity = 3;
optional Qot_Common.EC_ContractType contractType = 4;
optional string title = 5;
optional string yesSubTitle = 6;
optional string openTime = 7;
optional string closeTime = 8;
optional string determinationTime = 9;
optional string settledTime = 10;
optional string latestExpirationTime = 11;
optional Qot_Common.EC_Status status = 12;
optional string result = 13;
optional string settlementValue = 14;
optional string expirationValue = 15;
optional string notionalValue = 16;
optional string liquidity = 17;
optional string volume = 18;
optional bool canCloseEarly = 19;
optional string tickSize = 20;
optional string category = 21;
optional string tag = 22;
}
message RecommendContract {
required Qot_Common.Security contractSecurity = 1;
}
message C2S {
required Qot_Common.Security event = 1;
optional string nextPage = 2;
optional int32 count = 3;
}
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
31
32
33
34
35
36
37
38
- 股票结构参见 Security
- 返回
message S2C {
repeated ContractItem contractList = 1;
repeated RecommendContract recommendContracts = 2;
optional string nextPage = 3;
}
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
- 接口调用结果,结构参见 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 evt = QotCommon.Security.CreateBuilder()
.SetMarket((int)QotCommon.QotMarket.QotMarket_EventContract)
.SetCode("EC.KXUFCVICROUND-26JUL11SAIPIM.EVENT").Build();
var c2s = GetEventContract.C2S.CreateBuilder()
.SetEvent(evt).SetCount(5).Build();
var req = GetEventContract.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetEventContract(req);
Console.Write("Send GetEventContract: {0}\n", seqNo);
}
public void OnReply_GetEventContract(FTAPI_Conn client, uint nSerialNo, GetEventContract.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
int getEventContract(QotGetEventContract.Request req);
void onReply_GetEventContract(FTAPI_Conn client, int nSerialNo, QotGetEventContract.Response rsp);
介绍
根据 Event 代码获取其下挂的事件合约列表。
参数
message C2S {
required Qot_Common.Security event = 1;
optional string nextPage = 2;
optional int32 count = 3;
}
message Request {
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
- 股票结构参见 Security
- 返回
message ContractItem {
required Qot_Common.Security contractSecurity = 1;
optional Qot_Common.Security eventSecurity = 2;
optional Qot_Common.Security seriesSecurity = 3;
optional Qot_Common.EC_ContractType contractType = 4;
optional string title = 5;
optional string yesSubTitle = 6;
optional string openTime = 7;
optional string closeTime = 8;
optional string determinationTime = 9;
optional string settledTime = 10;
optional string latestExpirationTime = 11;
optional Qot_Common.EC_Status status = 12;
optional string result = 13;
optional string settlementValue = 14;
optional string expirationValue = 15;
optional string notionalValue = 16;
optional string liquidity = 17;
optional string volume = 18;
optional bool canCloseEarly = 19;
optional string tickSize = 20;
optional string category = 21;
optional string tag = 22;
}
message RecommendContract {
required Qot_Common.Security contractSecurity = 1;
}
message S2C {
repeated ContractItem contractList = 1;
repeated RecommendContract recommendContracts = 2;
optional string nextPage = 3;
}
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
36
37
38
39
40
41
- 接口调用结果,结构参见 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 evt = QotCommon.Security.newBuilder()
.setMarket(QotCommon.QotMarket.QotMarket_EventContract_VALUE)
.setCode("EC.KXUFCVICROUND-26JUL11SAIPIM.EVENT").build();
QotGetEventContract.C2S c2s = QotGetEventContract.C2S.newBuilder()
.setEvent(evt).setCount(5).build();
QotGetEventContract.Request req = QotGetEventContract.Request.newBuilder()
.setC2S(c2s).build();
int seqNo = qot.getEventContract(req);
System.out.println("Send GetEventContract: " + seqNo);
}
@Override
public void onReply_GetEventContract(FTAPI_Conn client, int nSerialNo, QotGetEventContract.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
Futu::u32_t GetEventContract(const Qot_GetEventContract::Request &stReq);
virtual void OnReply_GetEventContract(Futu::u32_t nSerialNo, const Qot_GetEventContract::Response &stRsp) = 0;
介绍
根据 Event 代码获取其下挂的事件合约列表。
参数
// 合约项
message ContractItem {
// ===== 标识 =====
required Qot_Common.Security contractSecurity = 1; // 合约标的
optional Qot_Common.Security eventSecurity = 2; // 所属 Event
optional Qot_Common.Security seriesSecurity = 3; // 所属 Series
optional Qot_Common.EC_ContractType contractType = 4; // 合约类型 (Binary/Scalar)
// ===== 名称 =====
optional string title = 5; // 合约标题(多语言)
optional string yesSubTitle = 6; // YES 的子标题(多语言)
// ===== 时间(UTC ISO8601 字符串,形如 2025-09-26T18:30:00Z)=====
optional string openTime = 7; // 合约开始时间
optional string closeTime = 8; // 合约结束时间
optional string determinationTime = 9; // 结果确定时间
optional string settledTime = 10; // 结算完成时间
optional string latestExpirationTime = 11; // 最新到期时间
// ===== 状态与结果 =====
optional Qot_Common.EC_Status status = 12; // 合约状态
optional string result = 13; // 合约结果
optional string settlementValue = 14; // 合约结算价值
optional string expirationValue = 15; // 合约到期结果
// ===== 交易属性 =====
optional string notionalValue = 16; // 合约名义价值
optional string liquidity = 17; // 合约流动性
optional string volume = 18; // 合约成交量
optional bool canCloseEarly = 19; // 是否可提早结束交易
optional string tickSize = 20; // 价位
// ===== 分类 =====
optional string category = 21; // 一级分类标识
optional string tag = 22; // 二级分类标识
}
// 推荐合约
message RecommendContract {
required Qot_Common.Security contractSecurity = 1;
}
message C2S {
required Qot_Common.Security event = 1; // Event 标的
optional string nextPage = 2; // 翻页标记(首页不填)
optional int32 count = 3; // 单页最大返回数(默认100,最大1000)
}
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
- 股票结构参见 Security
- 事件合约类型参见 EC_ContractType
- 返回
message S2C {
repeated ContractItem contractList = 1; // 合约列表
repeated RecommendContract recommendContracts = 2; // 推荐合约
optional string nextPage = 3; // 为空表示没有下一页
}
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
- 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_GetEventContract::Request req;
Qot_GetEventContract::C2S *c2s = req.mutable_c2s();
Qot_Common::Security *evt = c2s->mutable_event();
evt->set_code("EC.KXUFCVICROUND-26JUL11SAIPIM.EVENT");
evt->set_market(Qot_Common::QotMarket::QotMarket_EventContract);
c2s->set_count(5);
m_GetEventContractSerialNo = m_pQotApi->GetEventContract(req);
cout << "Request GetEventContract SerialNo: " << m_GetEventContractSerialNo << endl;
}
virtual void OnReply_GetEventContract(Futu::u32_t nSerialNo, const Qot_GetEventContract::Response &stRsp) {
if (nSerialNo == m_GetEventContractSerialNo)
{
cout << "OnReply_GetEventContract 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_GetEventContractSerialNo;
};
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
71
- Output
connect
Request GetEventContract SerialNo: 1
OnReply_GetEventContract SerialNo: 1
{
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"contractList": [
{
"contractSecurity": {"market": 101, "code": "EC.KXUFCVICROUND-26JUL11SAIPIM-SAI1"},
"eventSecurity": {"market": 101, "code": "EC.KXUFCVICROUND-26JUL11SAIPIM.EVENT"},
"seriesSecurity": {"market": 101, "code": "EC.KXUFCVICROUND.SERIES"},
"contractType": 1,
"title": "Will Benoit Saint-Denis win the Benoit Saint-Denis vs. Paddy Pimblett 329 fight in Round 1",
"yesSubTitle": "N/A",
"openTime": "2026-07-08T12:29:00Z",
"closeTime": "2026-07-11T23:19:55Z",
"determinationTime": "2026-07-11T23:20:54Z",
"settledTime": "2026-07-11T23:27:06Z",
"latestExpirationTime": "2026-07-25T22:00:00Z",
"status": 9,
"result": "No",
"settlementValue": "N/A",
"expirationValue": "Paddy Pimblett to win in Round 1",
"notionalValue": "N/A",
"liquidity": "N/A",
"volume": "N/A",
"canCloseEarly": true,
"tickSize": "0.010000000",
"category": "Hot",
"tag": "N/A"
}
],
"recommendContracts": [
{"contractSecurity": {"market": 101, "code": "EC.KXUFCVICROUND-26JUL11SAIPIM-SAI1"}},
{"contractSecurity": {"market": 101, "code": "EC.KXUFCVICROUND-26JUL11SAIPIM-PIM2"}},
{"contractSecurity": {"market": 101, "code": "EC.KXUFCVICROUND-26JUL11SAIPIM-PIM3"}}
],
"nextPage": "5"
}
}
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
GetEventContract(req);
介绍
根据 Event 代码获取其下挂的事件合约列表,支持分页。
参数
// 合约项
message ContractItem {
// ===== 标识 =====
required Qot_Common.Security contractSecurity = 1; // 合约标的
optional Qot_Common.Security eventSecurity = 2; // 所属 Event
optional Qot_Common.Security seriesSecurity = 3; // 所属 Series
optional Qot_Common.EC_ContractType contractType = 4; // 合约类型 (Binary/Scalar)
// ===== 名称 =====
optional string title = 5; // 合约标题(多语言)
optional string yesSubTitle = 6; // YES 的子标题(多语言)
// ===== 时间(UTC ISO8601 字符串,形如 2025-09-26T18:30:00Z)=====
optional string openTime = 7; // 合约开始时间
optional string closeTime = 8; // 合约结束时间
optional string determinationTime = 9; // 结果确定时间
optional string settledTime = 10; // 结算完成时间
optional string latestExpirationTime = 11; // 最新到期时间
// ===== 状态与结果 =====
optional Qot_Common.EC_Status status = 12; // 合约状态
optional string result = 13; // 合约结果
optional string settlementValue = 14; // 合约结算价值
optional string expirationValue = 15; // 合约到期结果
// ===== 交易属性 =====
optional string notionalValue = 16; // 合约名义价值
optional string liquidity = 17; // 合约流动性
optional string volume = 18; // 合约成交量
optional bool canCloseEarly = 19; // 是否可提早结束交易
optional string tickSize = 20; // 价位
// ===== 分类 =====
optional string category = 21; // 一级分类标识
optional string tag = 22; // 二级分类标识
}
// 推荐合约
message RecommendContract {
required Qot_Common.Security contractSecurity = 1;
}
message C2S {
required Qot_Common.Security event = 1; // Event 标的
optional string nextPage = 2; // 翻页标记(首页不填)
optional int32 count = 3; // 单页最大返回数(默认100,最大1000)
}
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
- 返回
message S2C {
repeated ContractItem contractList = 1; // 合约列表
repeated RecommendContract recommendContracts = 2; // 推荐合约
optional string nextPage = 3; // 为空表示没有下一页
}
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
- 接口调用结果,结构参见 RetType
- Example
import ftWebsocket from "futu-api";
import { Common, Qot_Common } from "futu-api/proto";
import beautify from "js-beautify";
function GetEventContract() {
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: { event: { market: QotMarket.QotMarket_EventContract, code: "EC.KXUFCVICROUND-26JUL11SAIPIM.EVENT" }, count: 5 } };
let { errCode, retMsg, retType, s2c } = await websocket.GetEventContract(req);
console.log("GetEventContract: 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
GetEventContract: errCode 0, retMsg , retType 0
{
"contractList": [{
"contractSecurity": {
"market": 101,
"code": "EC.KXUFCVICROUND-26JUL11SAIPIM-SAI1"
},
"eventSecurity": {
"market": 101,
"code": "EC.KXUFCVICROUND-26JUL11SAIPIM.EVENT"
},
"seriesSecurity": {
"market": 101,
"code": "EC.KXUFCVICROUND.SERIES"
},
"contractType": 1,
"title": "Will Benoit Saint-Denis win the Benoit Saint-Denis vs. Paddy Pimblett 329 fight in Round 1",
"status": 9,
"result": "No",
"volume": "N/A",
"canCloseEarly": true,
"tickSize": "0.010000000",
"category": "Hot",
"tag": "N/A"
}],
"recommendContracts": [{
"contractSecurity": {
"market": 101,
"code": "EC.KXUFCVICROUND-26JUL11SAIPIM-SAI1"
}
}, {
"contractSecurity": {
"market": 101,
"code": "EC.KXUFCVICROUND-26JUL11SAIPIM-PIM2"
}
}, {
"contractSecurity": {
"market": 101,
"code": "EC.KXUFCVICROUND-26JUL11SAIPIM-PIM3"
}
}],
"nextPage": "5"
}
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
接口限制
- 每 30 秒内最多请求 10 次获取事件合约接口
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_event_contract(event_code, next_page=None, count=None)
介绍
根据 Event 代码获取其下挂的事件合约(Contract)列表,含合约类型、时间、状态、结果、交易属性等完整信息,并返回推荐合约。支持分页。
参数
参数 类型 说明 event_code str Event 代码,例如 'EC.KXUFCVICROUND-26JUL11SAIPIM.EVENT'next_page str 翻页标记,首页不传 count int 单页最大返回条数,默认 100,最大 1000 返回
参数 类型 说明 ret RET_CODE 接口调用结果 data dict 当 ret == RET_OK,返回事件合约数据,含 contract_list 与 recommend_contracts str 当 ret != RET_OK,返回错误描述 next_page str 翻页标记,为空表示没有下一页 data 的 dict 结构如下:
键 类型 说明 contract_list pd.DataFrame 事件合约列表(字段见下) recommend_contracts list[dict] 推荐合约列表,每项含 contract_code contract_list 的 DataFrame 字段如下:
字段 类型 说明 contract_code str 合约代码 event_code str 所属 Event 代码 series_code str 所属 Series 代码 contract_type str 合约类型,参见 ECContractType title str 合约标题(多语言) yes_sub_title str YES 子标题(多语言) open_time str 合约开始时间(UTC ISO8601) close_time str 合约结束时间(UTC ISO8601) determination_time str 结果确定时间 settled_time str 结算完成时间 latest_expiration_time str 最新到期时间 status str 合约状态,参见 ECStatus result str 合约结果 settlement_value str 合约结算价值 expiration_value str 合约到期结果 volume str 合约成交量 can_close_early bool 是否可提早结束交易 tick_size str 价位 category str 一级分类标识 tag str 二级分类标识 Example
from moomoo import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data, next_page = quote_ctx.get_event_contract(
'EC.KXUFCVICROUND-26JUL11SAIPIM.EVENT', count=5
)
if ret == RET_OK:
print(data['contract_list'])
print('推荐合约:', data['recommend_contracts'])
print('next_page:', next_page)
else:
print('error:', data)
quote_ctx.close()
2
3
4
5
6
7
8
9
10
11
12
13
- Output
contract_code event_code series_code contract_type title yes_sub_title open_time close_time determination_time settled_time latest_expiration_time status result settlement_value expiration_value volume can_close_early tick_size category tag
0 EC.KXUFCVICROUND-26JUL11SAIPIM-SAI1 EC.KXUFCVICROUND-26JUL11SAIPIM.EVENT EC.KXUFCVICROUND.SERIES BINARY Will Benoit Saint-Denis win the Benoit Saint-Denis vs. Paddy Pimblett 329 fight in Round 1 N/A 2026-07-08 12:29:00 2026-07-11 23:19:55 2026-07-11 23:20:54 2026-07-11 23:27:06 2026-07-25 22:00:00 FINALIZED No N/A Paddy Pimblett to win in Round 1 N/A True 0.010000000 Hot N/A
1 EC.KXUFCVICROUND-26JUL11SAIPIM-PIM2 EC.KXUFCVICROUND-26JUL11SAIPIM.EVENT EC.KXUFCVICROUND.SERIES BINARY Will Paddy Pimblett win the Benoit Saint-Denis vs. Paddy Pimblett 329 fight in Round 2 N/A 2026-07-08 12:29:00 2026-07-11 23:19:55 2026-07-11 23:20:54 2026-07-11 23:27:06 2026-07-25 22:00:00 FINALIZED No N/A Paddy Pimblett to win in Round 1 N/A True 0.010000000 Hot N/A
2 EC.KXUFCVICROUND-26JUL11SAIPIM-PIM3 EC.KXUFCVICROUND-26JUL11SAIPIM.EVENT EC.KXUFCVICROUND.SERIES BINARY Will Paddy Pimblett win the Benoit Saint-Denis vs. Paddy Pimblett 329 fight in Round 3 N/A 2026-07-08 12:29:00 2026-07-11 23:19:55 2026-07-11 23:20:54 2026-07-11 23:27:06 2026-07-25 22:00:00 FINALIZED No N/A Paddy Pimblett to win in Round 1 N/A True 0.010000000 Hot N/A
3 EC.KXUFCVICROUND-26JUL11SAIPIM-SAI3 EC.KXUFCVICROUND-26JUL11SAIPIM.EVENT EC.KXUFCVICROUND.SERIES BINARY Will Benoit Saint-Denis win the Benoit Saint-Denis vs. Paddy Pimblett 329 fight in Round 3 N/A 2026-07-08 12:29:00 2026-07-11 23:19:55 2026-07-11 23:20:54 2026-07-11 23:27:06 2026-07-25 22:00:00 FINALIZED No N/A Paddy Pimblett to win in Round 1 N/A True 0.010000000 Hot N/A
4 EC.KXUFCVICROUND-26JUL11SAIPIM-PIM1 EC.KXUFCVICROUND-26JUL11SAIPIM.EVENT EC.KXUFCVICROUND.SERIES BINARY Will Paddy Pimblett win the Benoit Saint-Denis vs. Paddy Pimblett 329 fight in Round 1 N/A 2026-07-08 12:29:00 2026-07-11 23:19:55 2026-07-11 23:20:54 2026-07-11 23:27:06 2026-07-25 22:00:00 FINALIZED Yes 1.000000000 Paddy Pimblett to win in Round 1 N/A True 0.010000000 Hot N/A
推荐合约: [{'contract_code': 'EC.KXUFCVICROUND-26JUL11SAIPIM-SAI1'}, {'contract_code': 'EC.KXUFCVICROUND-26JUL11SAIPIM-PIM2'}, {'contract_code': 'EC.KXUFCVICROUND-26JUL11SAIPIM-PIM3'}]
next_page: 5
2
3
4
5
6
7
8
# Qot_GetEventContract.proto
介绍
根据 Event 代码获取其下挂的事件合约列表。
参数
// 合约项
message ContractItem {
// ===== 标识 =====
required Qot_Common.Security contractSecurity = 1; // 合约标的
optional Qot_Common.Security eventSecurity = 2; // 所属 Event
optional Qot_Common.Security seriesSecurity = 3; // 所属 Series
optional Qot_Common.EC_ContractType contractType = 4; // 合约类型 (Binary/Scalar)
// ===== 名称 =====
optional string title = 5; // 合约标题(多语言)
optional string yesSubTitle = 6; // YES 的子标题(多语言)
// ===== 时间(UTC ISO8601 字符串,形如 2025-09-26T18:30:00Z)=====
optional string openTime = 7; // 合约开始时间
optional string closeTime = 8; // 合约结束时间
optional string determinationTime = 9; // 结果确定时间
optional string settledTime = 10; // 结算完成时间
optional string latestExpirationTime = 11; // 最新到期时间
// ===== 状态与结果 =====
optional Qot_Common.EC_Status status = 12; // 合约状态
optional string result = 13; // 合约结果
optional string settlementValue = 14; // 合约结算价值
optional string expirationValue = 15; // 合约到期结果
// ===== 交易属性 =====
optional string notionalValue = 16; // 合约名义价值
optional string liquidity = 17; // 合约流动性
optional string volume = 18; // 合约成交量
optional bool canCloseEarly = 19; // 是否可提早结束交易
optional string tickSize = 20; // 价位
// ===== 分类 =====
optional string category = 21; // 一级分类标识
optional string tag = 22; // 二级分类标识
}
// 推荐合约
message RecommendContract {
required Qot_Common.Security contractSecurity = 1;
}
message C2S {
required Qot_Common.Security event = 1; // Event 标的
optional string nextPage = 2; // 翻页标记(首页不填)
optional int32 count = 3; // 单页最大返回数(默认100,最大1000)
}
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
- 股票结构参见 Security
- 事件合约类型参见 EC_ContractType
- 返回
message S2C {
repeated ContractItem contractList = 1; // 合约列表
repeated RecommendContract recommendContracts = 2; // 推荐合约
optional string nextPage = 3; // 为空表示没有下一页
}
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
协议 ID
3438
数据类型
- 股票结构参见 Security
- 事件合约类型参见 EC_ContractType
- 事件合约状态参见 EC_Status
uint GetEventContract(GetEventContract.Request req);
virtual void OnReply_GetEventContract(MMAPI_Conn client, uint nSerialNo, GetEventContract.Response rsp);
介绍
根据 Event 代码获取其下挂的事件合约列表。
参数
message ContractItem {
required Qot_Common.Security contractSecurity = 1;
optional Qot_Common.Security eventSecurity = 2;
optional Qot_Common.Security seriesSecurity = 3;
optional Qot_Common.EC_ContractType contractType = 4;
optional string title = 5;
optional string yesSubTitle = 6;
optional string openTime = 7;
optional string closeTime = 8;
optional string determinationTime = 9;
optional string settledTime = 10;
optional string latestExpirationTime = 11;
optional Qot_Common.EC_Status status = 12;
optional string result = 13;
optional string settlementValue = 14;
optional string expirationValue = 15;
optional string notionalValue = 16;
optional string liquidity = 17;
optional string volume = 18;
optional bool canCloseEarly = 19;
optional string tickSize = 20;
optional string category = 21;
optional string tag = 22;
}
message RecommendContract {
required Qot_Common.Security contractSecurity = 1;
}
message C2S {
required Qot_Common.Security event = 1;
optional string nextPage = 2;
optional int32 count = 3;
}
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
31
32
33
34
35
36
37
38
- 股票结构参见 Security
- 返回
message S2C {
repeated ContractItem contractList = 1;
repeated RecommendContract recommendContracts = 2;
optional string nextPage = 3;
}
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
- 接口调用结果,结构参见 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 evt = QotCommon.Security.CreateBuilder()
.SetMarket((int)QotCommon.QotMarket.QotMarket_EventContract)
.SetCode("EC.KXUFCVICROUND-26JUL11SAIPIM.EVENT").Build();
var c2s = GetEventContract.C2S.CreateBuilder()
.SetEvent(evt).SetCount(5).Build();
var req = GetEventContract.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetEventContract(req);
Console.Write("Send GetEventContract: {0}\n", seqNo);
}
public void OnReply_GetEventContract(MMAPI_Conn client, uint nSerialNo, GetEventContract.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
int getEventContract(QotGetEventContract.Request req);
void onReply_GetEventContract(MMAPI_Conn client, int nSerialNo, QotGetEventContract.Response rsp);
介绍
根据 Event 代码获取其下挂的事件合约列表。
参数
message C2S {
required Qot_Common.Security event = 1;
optional string nextPage = 2;
optional int32 count = 3;
}
message Request {
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
- 股票结构参见 Security
- 返回
message ContractItem {
required Qot_Common.Security contractSecurity = 1;
optional Qot_Common.Security eventSecurity = 2;
optional Qot_Common.Security seriesSecurity = 3;
optional Qot_Common.EC_ContractType contractType = 4;
optional string title = 5;
optional string yesSubTitle = 6;
optional string openTime = 7;
optional string closeTime = 8;
optional string determinationTime = 9;
optional string settledTime = 10;
optional string latestExpirationTime = 11;
optional Qot_Common.EC_Status status = 12;
optional string result = 13;
optional string settlementValue = 14;
optional string expirationValue = 15;
optional string notionalValue = 16;
optional string liquidity = 17;
optional string volume = 18;
optional bool canCloseEarly = 19;
optional string tickSize = 20;
optional string category = 21;
optional string tag = 22;
}
message RecommendContract {
required Qot_Common.Security contractSecurity = 1;
}
message S2C {
repeated ContractItem contractList = 1;
repeated RecommendContract recommendContracts = 2;
optional string nextPage = 3;
}
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
36
37
38
39
40
41
- 接口调用结果,结构参见 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 evt = QotCommon.Security.newBuilder()
.setMarket(QotCommon.QotMarket.QotMarket_EventContract_VALUE)
.setCode("EC.KXUFCVICROUND-26JUL11SAIPIM.EVENT").build();
QotGetEventContract.C2S c2s = QotGetEventContract.C2S.newBuilder()
.setEvent(evt).setCount(5).build();
QotGetEventContract.Request req = QotGetEventContract.Request.newBuilder()
.setC2S(c2s).build();
int seqNo = qot.getEventContract(req);
System.out.println("Send GetEventContract: " + seqNo);
}
@Override
public void onReply_GetEventContract(MMAPI_Conn client, int nSerialNo, QotGetEventContract.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
moomoo::u32_t GetEventContract(const Qot_GetEventContract::Request &stReq);
virtual void OnReply_GetEventContract(moomoo::u32_t nSerialNo, const Qot_GetEventContract::Response &stRsp) = 0;
介绍
根据 Event 代码获取其下挂的事件合约列表。
参数
// 合约项
message ContractItem {
// ===== 标识 =====
required Qot_Common.Security contractSecurity = 1; // 合约标的
optional Qot_Common.Security eventSecurity = 2; // 所属 Event
optional Qot_Common.Security seriesSecurity = 3; // 所属 Series
optional Qot_Common.EC_ContractType contractType = 4; // 合约类型 (Binary/Scalar)
// ===== 名称 =====
optional string title = 5; // 合约标题(多语言)
optional string yesSubTitle = 6; // YES 的子标题(多语言)
// ===== 时间(UTC ISO8601 字符串,形如 2025-09-26T18:30:00Z)=====
optional string openTime = 7; // 合约开始时间
optional string closeTime = 8; // 合约结束时间
optional string determinationTime = 9; // 结果确定时间
optional string settledTime = 10; // 结算完成时间
optional string latestExpirationTime = 11; // 最新到期时间
// ===== 状态与结果 =====
optional Qot_Common.EC_Status status = 12; // 合约状态
optional string result = 13; // 合约结果
optional string settlementValue = 14; // 合约结算价值
optional string expirationValue = 15; // 合约到期结果
// ===== 交易属性 =====
optional string notionalValue = 16; // 合约名义价值
optional string liquidity = 17; // 合约流动性
optional string volume = 18; // 合约成交量
optional bool canCloseEarly = 19; // 是否可提早结束交易
optional string tickSize = 20; // 价位
// ===== 分类 =====
optional string category = 21; // 一级分类标识
optional string tag = 22; // 二级分类标识
}
// 推荐合约
message RecommendContract {
required Qot_Common.Security contractSecurity = 1;
}
message C2S {
required Qot_Common.Security event = 1; // Event 标的
optional string nextPage = 2; // 翻页标记(首页不填)
optional int32 count = 3; // 单页最大返回数(默认100,最大1000)
}
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
- 股票结构参见 Security
- 事件合约类型参见 EC_ContractType
- 返回
message S2C {
repeated ContractItem contractList = 1; // 合约列表
repeated RecommendContract recommendContracts = 2; // 推荐合约
optional string nextPage = 3; // 为空表示没有下一页
}
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
- 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_GetEventContract::Request req;
Qot_GetEventContract::C2S *c2s = req.mutable_c2s();
Qot_Common::Security *evt = c2s->mutable_event();
evt->set_code("EC.KXUFCVICROUND-26JUL11SAIPIM.EVENT");
evt->set_market(Qot_Common::QotMarket::QotMarket_EventContract);
c2s->set_count(5);
m_GetEventContractSerialNo = m_pQotApi->GetEventContract(req);
cout << "Request GetEventContract SerialNo: " << m_GetEventContractSerialNo << endl;
}
virtual void OnReply_GetEventContract(moomoo::u32_t nSerialNo, const Qot_GetEventContract::Response &stRsp) {
if (nSerialNo == m_GetEventContractSerialNo)
{
cout << "OnReply_GetEventContract 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_GetEventContractSerialNo;
};
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
71
- Output
connect
Request GetEventContract SerialNo: 1
OnReply_GetEventContract SerialNo: 1
{
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"contractList": [
{
"contractSecurity": {"market": 101, "code": "EC.KXUFCVICROUND-26JUL11SAIPIM-SAI1"},
"eventSecurity": {"market": 101, "code": "EC.KXUFCVICROUND-26JUL11SAIPIM.EVENT"},
"seriesSecurity": {"market": 101, "code": "EC.KXUFCVICROUND.SERIES"},
"contractType": 1,
"title": "Will Benoit Saint-Denis win the Benoit Saint-Denis vs. Paddy Pimblett 329 fight in Round 1",
"yesSubTitle": "N/A",
"openTime": "2026-07-08T12:29:00Z",
"closeTime": "2026-07-11T23:19:55Z",
"determinationTime": "2026-07-11T23:20:54Z",
"settledTime": "2026-07-11T23:27:06Z",
"latestExpirationTime": "2026-07-25T22:00:00Z",
"status": 9,
"result": "No",
"settlementValue": "N/A",
"expirationValue": "Paddy Pimblett to win in Round 1",
"notionalValue": "N/A",
"liquidity": "N/A",
"volume": "N/A",
"canCloseEarly": true,
"tickSize": "0.010000000",
"category": "Hot",
"tag": "N/A"
}
],
"recommendContracts": [
{"contractSecurity": {"market": 101, "code": "EC.KXUFCVICROUND-26JUL11SAIPIM-SAI1"}},
{"contractSecurity": {"market": 101, "code": "EC.KXUFCVICROUND-26JUL11SAIPIM-PIM2"}},
{"contractSecurity": {"market": 101, "code": "EC.KXUFCVICROUND-26JUL11SAIPIM-PIM3"}}
],
"nextPage": "5"
}
}
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
GetEventContract(req);
介绍
根据 Event 代码获取其下挂的事件合约列表,支持分页。
参数
// 合约项
message ContractItem {
// ===== 标识 =====
required Qot_Common.Security contractSecurity = 1; // 合约标的
optional Qot_Common.Security eventSecurity = 2; // 所属 Event
optional Qot_Common.Security seriesSecurity = 3; // 所属 Series
optional Qot_Common.EC_ContractType contractType = 4; // 合约类型 (Binary/Scalar)
// ===== 名称 =====
optional string title = 5; // 合约标题(多语言)
optional string yesSubTitle = 6; // YES 的子标题(多语言)
// ===== 时间(UTC ISO8601 字符串,形如 2025-09-26T18:30:00Z)=====
optional string openTime = 7; // 合约开始时间
optional string closeTime = 8; // 合约结束时间
optional string determinationTime = 9; // 结果确定时间
optional string settledTime = 10; // 结算完成时间
optional string latestExpirationTime = 11; // 最新到期时间
// ===== 状态与结果 =====
optional Qot_Common.EC_Status status = 12; // 合约状态
optional string result = 13; // 合约结果
optional string settlementValue = 14; // 合约结算价值
optional string expirationValue = 15; // 合约到期结果
// ===== 交易属性 =====
optional string notionalValue = 16; // 合约名义价值
optional string liquidity = 17; // 合约流动性
optional string volume = 18; // 合约成交量
optional bool canCloseEarly = 19; // 是否可提早结束交易
optional string tickSize = 20; // 价位
// ===== 分类 =====
optional string category = 21; // 一级分类标识
optional string tag = 22; // 二级分类标识
}
// 推荐合约
message RecommendContract {
required Qot_Common.Security contractSecurity = 1;
}
message C2S {
required Qot_Common.Security event = 1; // Event 标的
optional string nextPage = 2; // 翻页标记(首页不填)
optional int32 count = 3; // 单页最大返回数(默认100,最大1000)
}
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
- 返回
message S2C {
repeated ContractItem contractList = 1; // 合约列表
repeated RecommendContract recommendContracts = 2; // 推荐合约
optional string nextPage = 3; // 为空表示没有下一页
}
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
- 接口调用结果,结构参见 RetType
- Example
import mmWebsocket from "moomoo-api";
import { Common, Qot_Common } from "moomoo-api/proto";
import beautify from "js-beautify";
function GetEventContract() {
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: { event: { market: QotMarket.QotMarket_EventContract, code: "EC.KXUFCVICROUND-26JUL11SAIPIM.EVENT" }, count: 5 } };
let { errCode, retMsg, retType, s2c } = await websocket.GetEventContract(req);
console.log("GetEventContract: 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
GetEventContract: errCode 0, retMsg , retType 0
{
"contractList": [{
"contractSecurity": {
"market": 101,
"code": "EC.KXUFCVICROUND-26JUL11SAIPIM-SAI1"
},
"eventSecurity": {
"market": 101,
"code": "EC.KXUFCVICROUND-26JUL11SAIPIM.EVENT"
},
"seriesSecurity": {
"market": 101,
"code": "EC.KXUFCVICROUND.SERIES"
},
"contractType": 1,
"title": "Will Benoit Saint-Denis win the Benoit Saint-Denis vs. Paddy Pimblett 329 fight in Round 1",
"status": 9,
"result": "No",
"volume": "N/A",
"canCloseEarly": true,
"tickSize": "0.010000000",
"category": "Hot",
"tag": "N/A"
}],
"recommendContracts": [{
"contractSecurity": {
"market": 101,
"code": "EC.KXUFCVICROUND-26JUL11SAIPIM-SAI1"
}
}, {
"contractSecurity": {
"market": 101,
"code": "EC.KXUFCVICROUND-26JUL11SAIPIM-PIM2"
}
}, {
"contractSecurity": {
"market": 101,
"code": "EC.KXUFCVICROUND-26JUL11SAIPIM-PIM3"
}
}],
"nextPage": "5"
}
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
接口限制
- 每 30 秒内最多请求 10 次获取事件合约接口