# 獲取事件合約
- 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 次獲取事件合約介面