# 獲取事件合約可Combo列表
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_valid_combo_list(category=None, competition=None, series=None, next_page=None, count=None)
介紹
獲取可以參與 Combo(組合)的事件合約列表,返回每個可組合事件下的可組合合約列表,以及 MVC 標的(詢價介面需透傳)。支援按分類、賽事、Series 過濾與分頁。
參數
參數 類型 說明 category str 一級分類過濾,例如 'Sports'competition str 賽事過濾 series str Series 標的過濾,例如 'EC.xxx'next_page str 翻頁標記,首頁不傳 count int 單頁最大返回條數,選填,預設不限制 返回
參數 類型 說明 ret RET_CODE 介面調用結果 data pd.DataFrame 當 ret == RET_OK,返回可 Combo 事件列表 str 當 ret != RET_OK,返回錯誤描述 mvc str MVC 標的字串,透傳給 request_combo_quotes 詢價介面 next_page str 翻頁標記,空字串表示沒有下一頁 返回的 DataFrame 欄位如下:
欄位 類型 說明 event_code str 事件代碼 event_name str 事件名稱(多語言) combo_contracts list 可組合的合約代碼列表 series_code str 所屬 Series 代碼 category str 一級分類標識 competition str 賽事名稱(多語言) competition_scope str 賽事類型/玩法(多語言) Example
from futu import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data, mvc, next_page = quote_ctx.get_valid_combo_list(category='Sports', count=5)
if ret == RET_OK:
print(data)
print('mvc:', mvc) # 透傳給 request_combo_quotes
if not data.empty:
contracts = data.iloc[0]['combo_contracts']
print('可組合合約:', contracts)
else:
print('error:', data)
quote_ctx.close()
2
3
4
5
6
7
8
9
10
11
12
13
14
15
- Output
event_code event_name combo_contracts series_code category competition competition_scope
0 EC.KXWCADVANCE-26JUL14FRAESP.EVENT France vs Spain [EC.KXWCADVANCE-26JUL14FRAESP-FRA, EC.KXWCADVANCE-26JUL14FRAESP-ESP] EC.KXWCADVANCE.SERIES Hot FIFA World Cup Game
1 EC.KXPGATOUR-THOC26.EVENT The Open Championship Winner [EC.KXPGATOUR-THOC26-SSCH, EC.KXPGATOUR-THOC26-RMCI, EC.KXPGATOUR-THOC26-MFIT] EC.KXPGATOUR.SERIES Hot The Open Championship Game
2 EC.KXWCADVANCE-26JUL15ENGARG.EVENT England vs Argentina [EC.KXWCADVANCE-26JUL15ENGARG-ENG, EC.KXWCADVANCE-26JUL15ENGARG-ARG] EC.KXWCADVANCE.SERIES Hot FIFA World Cup Game
3 EC.KXWTAMATCH-26JUL13PRIGAR.EVENT Pridankina vs Garcia Perez [EC.KXWTAMATCH-26JUL13PRIGAR-PRI, EC.KXWTAMATCH-26JUL13PRIGAR-GAR] EC.KXWTAMATCH.SERIES Hot WTA Iasi Game
4 EC.KXATPMATCH-26JUL12SONSCH.EVENT Sonego vs Schwaerzler [EC.KXATPMATCH-26JUL12SONSCH-SON, EC.KXATPMATCH-26JUL12SONSCH-SCH] EC.KXATPMATCH.SERIES Hot ATP Gstaad Game
mvc: KALSHI.KXMVECROSSCATEGORY-R
可組合合約: ['EC.KXWCADVANCE-26JUL14FRAESP-FRA', 'EC.KXWCADVANCE-26JUL14FRAESP-ESP']
2
3
4
5
6
7
8
# Qot_GetEventContractComboList.proto
介紹
獲取可以參與 Combo(組合)的事件合約列表。
參數
// 可 Combo 事件項
message ComboEvent {
required Qot_Common.Security eventSecurity = 1; // 事件標的 {market=101, code="EC.xxx"}
optional string eventName = 2; // 事件名稱(多語言)
repeated Qot_Common.Security comboContracts = 3; // 可組合的合約列表(contract 級預覽,全量走 Qot_GetEventContract)
optional Qot_Common.Security seriesSecurity = 4; // 所屬 Series
optional string category = 5; // 一級分類標識
optional string competition = 6; // 賽事名稱(多語言)
optional string competitionScope = 7; // 賽事類型/玩法(多語言)
}
message C2S {
optional string category = 1; // 一級分類過濾(如 "SPORTS")
optional string competition = 2; // 賽事過濾
optional Qot_Common.Security series = 3; // Series 標的過濾 {market=101, code="EC.xxx"}
optional string nextPage = 4; // 翻頁標記(首頁不填)
optional int32 count = 5; // 單頁最大返回數(預設 200)
}
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
- 股票結構參見 Security
- 返回
message S2C {
repeated ComboEvent comboEventList = 1; // 可 Combo 事件列表
optional string mvc = 2; // MVC 標的,格式 exchange.origin_symbol(詢價介面需透傳)
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
協議 ID
3453
數據類型
- 股票結構參見 Security
uint GetEventContractComboList(GetEventContractComboList.Request req);
virtual void OnReply_GetEventContractComboList(FTAPI_Conn client, uint nSerialNo, GetEventContractComboList.Response rsp);
介紹
獲取可以參與 Combo(組合)的事件合約列表。
參數
message ComboEvent {
required Qot_Common.Security eventSecurity = 1;
optional string eventName = 2;
repeated Qot_Common.Security comboContracts = 3;
optional Qot_Common.Security seriesSecurity = 4;
optional string category = 5;
optional string competition = 6;
optional string competitionScope = 7;
}
message C2S {
optional string category = 1;
optional string competition = 2;
optional Qot_Common.Security series = 3;
optional string nextPage = 4;
optional int32 count = 5;
}
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
- 股票結構參見 Security
- 返回
message S2C {
repeated ComboEvent comboEventList = 1;
optional string mvc = 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;
var c2s = GetEventContractComboList.C2S.CreateBuilder()
.SetCategory("Sports").SetCount(5).Build();
var req = GetEventContractComboList.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetEventContractComboList(req);
Console.Write("Send GetEventContractComboList: {0}\n", seqNo);
}
public void OnReply_GetEventContractComboList(FTAPI_Conn client, uint nSerialNo, GetEventContractComboList.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
- Output
connect
Request GetEventContractComboList SerialNo: 1
OnReply_GetEventContractComboList SerialNo: 1
{
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"comboEventList": [
{
"eventSecurity": {"market": 101, "code": "EC.xxx"},
"eventName": "事件示例",
"category": "SPORTS",
"competition": "Pro Football"
}
],
"mvc": "EC.xxx"
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
int getEventContractComboList(QotGetEventContractComboList.Request req);
void onReply_GetEventContractComboList(FTAPI_Conn client, int nSerialNo, QotGetEventContractComboList.Response rsp);
介紹
獲取可以參與 Combo(組合)的事件合約列表。
參數
message C2S {
optional string category = 1;
optional string competition = 2;
optional Qot_Common.Security series = 3;
optional string nextPage = 4;
optional int32 count = 5;
}
message Request {
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 股票結構參見 Security
- 返回
message S2C {
repeated ComboEvent comboEventList = 1;
optional string mvc = 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 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;
QotGetEventContractComboList.C2S c2s = QotGetEventContractComboList.C2S.newBuilder()
.setCategory("Sports").setCount(5).build();
QotGetEventContractComboList.Request req = QotGetEventContractComboList.Request.newBuilder()
.setC2S(c2s).build();
int seqNo = qot.getEventContractComboList(req);
System.out.println("Send GetEventContractComboList: " + seqNo);
}
@Override
public void onReply_GetEventContractComboList(FTAPI_Conn client, int nSerialNo, QotGetEventContractComboList.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
- Output
connect
Request GetEventContractComboList SerialNo: 1
OnReply_GetEventContractComboList SerialNo: 1
{
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"comboEventList": [
{
"eventSecurity": {"market": 101, "code": "EC.xxx"},
"eventName": "事件示例",
"category": "SPORTS",
"competition": "Pro Football"
}
],
"mvc": "EC.xxx"
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Futu::u32_t GetEventContractComboList(const Qot_GetEventContractComboList::Request &stReq);
virtual void OnReply_GetEventContractComboList(Futu::u32_t nSerialNo, const Qot_GetEventContractComboList::Response &stRsp) = 0;
介紹
獲取可以參與 Combo(組合)的事件合約列表。
參數
// 可 Combo 事件項
message ComboEvent {
required Qot_Common.Security eventSecurity = 1; // 事件標的 {market=101, code="EC.xxx"}
optional string eventName = 2; // 事件名稱(多語言)
repeated Qot_Common.Security comboContracts = 3; // 可組合的合約列表(contract 級預覽,全量走 Qot_GetEventContract)
optional Qot_Common.Security seriesSecurity = 4; // 所屬 Series
optional string category = 5; // 一級分類標識
optional string competition = 6; // 賽事名稱(多語言)
optional string competitionScope = 7; // 賽事類型/玩法(多語言)
}
message C2S {
optional string category = 1; // 一級分類過濾(如 "SPORTS")
optional string competition = 2; // 賽事過濾
optional Qot_Common.Security series = 3; // Series 標的過濾 {market=101, code="EC.xxx"}
optional string nextPage = 4; // 翻頁標記(首頁不填)
optional int32 count = 5; // 單頁最大返回數(預設 200)
}
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
- 股票結構參見 Security
- 返回
message S2C {
repeated ComboEvent comboEventList = 1; // 可 Combo 事件列表
optional string mvc = 2; // MVC 標的,格式 exchange.origin_symbol(詢價介面需透傳)
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
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_GetEventContractComboList::Request req;
Qot_GetEventContractComboList::C2S *c2s = req.mutable_c2s();
c2s->set_category("Sports");
c2s->set_count(5);
m_GetEventContractComboListSerialNo = m_pQotApi->GetEventContractComboList(req);
cout << "Request GetEventContractComboList SerialNo: " << m_GetEventContractComboListSerialNo << endl;
}
virtual void OnReply_GetEventContractComboList(Futu::u32_t nSerialNo, const Qot_GetEventContractComboList::Response &stRsp) {
if (nSerialNo == m_GetEventContractComboListSerialNo)
{
cout << "OnReply_GetEventContractComboList 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_GetEventContractComboListSerialNo;
};
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
- Output
connect
Request GetEventContractComboList SerialNo: 1
OnReply_GetEventContractComboList SerialNo: 1
{
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"comboEventList": [
{
"eventSecurity": {"market": 101, "code": "EC.KXWCADVANCE-26JUL14FRAESP.EVENT"},
"eventName": "France vs Spain",
"comboContracts": [
{"market": 101, "code": "EC.KXWCADVANCE-26JUL14FRAESP-FRA"},
{"market": 101, "code": "EC.KXWCADVANCE-26JUL14FRAESP-ESP"}
],
"seriesSecurity": {"market": 101, "code": "EC.KXWCADVANCE.SERIES"},
"category": "Hot",
"competition": "FIFA World Cup",
"competitionScope": "Game"
}
],
"mvc": "KALSHI.KXMVECROSSCATEGORY-R"
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
GetEventContractComboList(req);
介紹
獲取可以參與 Combo(組合)的事件合約列表,支援按分類、賽事、Series 過濾。
參數
// 可 Combo 事件項
message ComboEvent {
required Qot_Common.Security eventSecurity = 1; // 事件標的 {market=101, code="EC.xxx"}
optional string eventName = 2; // 事件名稱(多語言)
repeated Qot_Common.Security comboContracts = 3; // 可組合的合約列表
optional Qot_Common.Security seriesSecurity = 4; // 所屬 Series
optional string category = 5; // 一級分類標識
optional string competition = 6; // 賽事名稱(多語言)
optional string competitionScope = 7; // 賽事類型/玩法(多語言)
}
message C2S {
optional string category = 1; // 一級分類過濾(如 "SPORTS")
optional string competition = 2; // 賽事過濾
optional Qot_Common.Security series = 3; // Series 標的過濾 {market=101, code="EC.xxx"}
optional string nextPage = 4; // 翻頁標記(首頁不填)
optional int32 count = 5; // 單頁最大返回數(預設 200)
}
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
- 返回
message S2C {
repeated ComboEvent comboEventList = 1; // 可 Combo 事件列表
optional string mvc = 2; // MVC 標的,格式 exchange.origin_symbol(詢價介面需透傳)
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 GetEventContractComboList() {
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: { category: "Sports", count: 5 } };
let { errCode, retMsg, retType, s2c } = await websocket.GetEventContractComboList(req);
console.log("GetEventContractComboList: 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
GetEventContractComboList: errCode 0, retMsg , retType 0
{
"comboEventList": [{
"eventSecurity": {
"market": 101,
"code": "EC.KXWCADVANCE-26JUL14FRAESP.EVENT"
},
"eventName": "France vs Spain",
"comboContracts": [
{"market": 101, "code": "EC.KXWCADVANCE-26JUL14FRAESP-FRA"},
{"market": 101, "code": "EC.KXWCADVANCE-26JUL14FRAESP-ESP"}
],
"seriesSecurity": {
"market": 101,
"code": "EC.KXWCADVANCE.SERIES"
},
"category": "Hot",
"competition": "FIFA World Cup",
"competitionScope": "Game"
}],
"mvc": "KALSHI.KXMVECROSSCATEGORY-R"
}
stop
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
介面限制
- 每 30 秒內最多請求 15 次獲取事件合約 Combo 列表介面
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_valid_combo_list(category=None, competition=None, series=None, next_page=None, count=None)
介紹
獲取可以參與 Combo(組合)的事件合約列表,返回每個可組合事件下的可組合合約列表,以及 MVC 標的(詢價介面需透傳)。支援按分類、賽事、Series 過濾與分頁。
參數
參數 類型 說明 category str 一級分類過濾,例如 'Sports'competition str 賽事過濾 series str Series 標的過濾,例如 'EC.xxx'next_page str 翻頁標記,首頁不傳 count int 單頁最大返回條數,選填,預設不限制 返回
參數 類型 說明 ret RET_CODE 介面調用結果 data pd.DataFrame 當 ret == RET_OK,返回可 Combo 事件列表 str 當 ret != RET_OK,返回錯誤描述 mvc str MVC 標的字串,透傳給 request_combo_quotes 詢價介面 next_page str 翻頁標記,空字串表示沒有下一頁 返回的 DataFrame 欄位如下:
欄位 類型 說明 event_code str 事件代碼 event_name str 事件名稱(多語言) combo_contracts list 可組合的合約代碼列表 series_code str 所屬 Series 代碼 category str 一級分類標識 competition str 賽事名稱(多語言) competition_scope str 賽事類型/玩法(多語言) Example
from moomoo import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data, mvc, next_page = quote_ctx.get_valid_combo_list(category='Sports', count=5)
if ret == RET_OK:
print(data)
print('mvc:', mvc) # 透傳給 request_combo_quotes
if not data.empty:
contracts = data.iloc[0]['combo_contracts']
print('可組合合約:', contracts)
else:
print('error:', data)
quote_ctx.close()
2
3
4
5
6
7
8
9
10
11
12
13
14
15
- Output
event_code event_name combo_contracts series_code category competition competition_scope
0 EC.KXWCADVANCE-26JUL14FRAESP.EVENT France vs Spain [EC.KXWCADVANCE-26JUL14FRAESP-FRA, EC.KXWCADVANCE-26JUL14FRAESP-ESP] EC.KXWCADVANCE.SERIES Hot FIFA World Cup Game
1 EC.KXPGATOUR-THOC26.EVENT The Open Championship Winner [EC.KXPGATOUR-THOC26-SSCH, EC.KXPGATOUR-THOC26-RMCI, EC.KXPGATOUR-THOC26-MFIT] EC.KXPGATOUR.SERIES Hot The Open Championship Game
2 EC.KXWCADVANCE-26JUL15ENGARG.EVENT England vs Argentina [EC.KXWCADVANCE-26JUL15ENGARG-ENG, EC.KXWCADVANCE-26JUL15ENGARG-ARG] EC.KXWCADVANCE.SERIES Hot FIFA World Cup Game
3 EC.KXWTAMATCH-26JUL13PRIGAR.EVENT Pridankina vs Garcia Perez [EC.KXWTAMATCH-26JUL13PRIGAR-PRI, EC.KXWTAMATCH-26JUL13PRIGAR-GAR] EC.KXWTAMATCH.SERIES Hot WTA Iasi Game
4 EC.KXATPMATCH-26JUL12SONSCH.EVENT Sonego vs Schwaerzler [EC.KXATPMATCH-26JUL12SONSCH-SON, EC.KXATPMATCH-26JUL12SONSCH-SCH] EC.KXATPMATCH.SERIES Hot ATP Gstaad Game
mvc: KALSHI.KXMVECROSSCATEGORY-R
可組合合約: ['EC.KXWCADVANCE-26JUL14FRAESP-FRA', 'EC.KXWCADVANCE-26JUL14FRAESP-ESP']
2
3
4
5
6
7
8
# Qot_GetEventContractComboList.proto
介紹
獲取可以參與 Combo(組合)的事件合約列表。
參數
// 可 Combo 事件項
message ComboEvent {
required Qot_Common.Security eventSecurity = 1; // 事件標的 {market=101, code="EC.xxx"}
optional string eventName = 2; // 事件名稱(多語言)
repeated Qot_Common.Security comboContracts = 3; // 可組合的合約列表(contract 級預覽,全量走 Qot_GetEventContract)
optional Qot_Common.Security seriesSecurity = 4; // 所屬 Series
optional string category = 5; // 一級分類標識
optional string competition = 6; // 賽事名稱(多語言)
optional string competitionScope = 7; // 賽事類型/玩法(多語言)
}
message C2S {
optional string category = 1; // 一級分類過濾(如 "SPORTS")
optional string competition = 2; // 賽事過濾
optional Qot_Common.Security series = 3; // Series 標的過濾 {market=101, code="EC.xxx"}
optional string nextPage = 4; // 翻頁標記(首頁不填)
optional int32 count = 5; // 單頁最大返回數(預設 200)
}
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
- 股票結構參見 Security
- 返回
message S2C {
repeated ComboEvent comboEventList = 1; // 可 Combo 事件列表
optional string mvc = 2; // MVC 標的,格式 exchange.origin_symbol(詢價介面需透傳)
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
協議 ID
3453
數據類型
- 股票結構參見 Security
uint GetEventContractComboList(GetEventContractComboList.Request req);
virtual void OnReply_GetEventContractComboList(MMAPI_Conn client, uint nSerialNo, GetEventContractComboList.Response rsp);
介紹
獲取可以參與 Combo(組合)的事件合約列表。
參數
message ComboEvent {
required Qot_Common.Security eventSecurity = 1;
optional string eventName = 2;
repeated Qot_Common.Security comboContracts = 3;
optional Qot_Common.Security seriesSecurity = 4;
optional string category = 5;
optional string competition = 6;
optional string competitionScope = 7;
}
message C2S {
optional string category = 1;
optional string competition = 2;
optional Qot_Common.Security series = 3;
optional string nextPage = 4;
optional int32 count = 5;
}
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
- 股票結構參見 Security
- 返回
message S2C {
repeated ComboEvent comboEventList = 1;
optional string mvc = 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;
var c2s = GetEventContractComboList.C2S.CreateBuilder()
.SetCategory("Sports").SetCount(5).Build();
var req = GetEventContractComboList.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetEventContractComboList(req);
Console.Write("Send GetEventContractComboList: {0}\n", seqNo);
}
public void OnReply_GetEventContractComboList(MMAPI_Conn client, uint nSerialNo, GetEventContractComboList.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
- Output
connect
Request GetEventContractComboList SerialNo: 1
OnReply_GetEventContractComboList SerialNo: 1
{
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"comboEventList": [
{
"eventSecurity": {"market": 101, "code": "EC.xxx"},
"eventName": "事件示例",
"category": "SPORTS",
"competition": "Pro Football"
}
],
"mvc": "EC.xxx"
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
int getEventContractComboList(QotGetEventContractComboList.Request req);
void onReply_GetEventContractComboList(MMAPI_Conn client, int nSerialNo, QotGetEventContractComboList.Response rsp);
介紹
獲取可以參與 Combo(組合)的事件合約列表。
參數
message C2S {
optional string category = 1;
optional string competition = 2;
optional Qot_Common.Security series = 3;
optional string nextPage = 4;
optional int32 count = 5;
}
message Request {
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 股票結構參見 Security
- 返回
message S2C {
repeated ComboEvent comboEventList = 1;
optional string mvc = 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 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;
QotGetEventContractComboList.C2S c2s = QotGetEventContractComboList.C2S.newBuilder()
.setCategory("Sports").setCount(5).build();
QotGetEventContractComboList.Request req = QotGetEventContractComboList.Request.newBuilder()
.setC2S(c2s).build();
int seqNo = qot.getEventContractComboList(req);
System.out.println("Send GetEventContractComboList: " + seqNo);
}
@Override
public void onReply_GetEventContractComboList(MMAPI_Conn client, int nSerialNo, QotGetEventContractComboList.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
- Output
connect
Request GetEventContractComboList SerialNo: 1
OnReply_GetEventContractComboList SerialNo: 1
{
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"comboEventList": [
{
"eventSecurity": {"market": 101, "code": "EC.xxx"},
"eventName": "事件示例",
"category": "SPORTS",
"competition": "Pro Football"
}
],
"mvc": "EC.xxx"
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
moomoo::u32_t GetEventContractComboList(const Qot_GetEventContractComboList::Request &stReq);
virtual void OnReply_GetEventContractComboList(moomoo::u32_t nSerialNo, const Qot_GetEventContractComboList::Response &stRsp) = 0;
介紹
獲取可以參與 Combo(組合)的事件合約列表。
參數
// 可 Combo 事件項
message ComboEvent {
required Qot_Common.Security eventSecurity = 1; // 事件標的 {market=101, code="EC.xxx"}
optional string eventName = 2; // 事件名稱(多語言)
repeated Qot_Common.Security comboContracts = 3; // 可組合的合約列表(contract 級預覽,全量走 Qot_GetEventContract)
optional Qot_Common.Security seriesSecurity = 4; // 所屬 Series
optional string category = 5; // 一級分類標識
optional string competition = 6; // 賽事名稱(多語言)
optional string competitionScope = 7; // 賽事類型/玩法(多語言)
}
message C2S {
optional string category = 1; // 一級分類過濾(如 "SPORTS")
optional string competition = 2; // 賽事過濾
optional Qot_Common.Security series = 3; // Series 標的過濾 {market=101, code="EC.xxx"}
optional string nextPage = 4; // 翻頁標記(首頁不填)
optional int32 count = 5; // 單頁最大返回數(預設 200)
}
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
- 股票結構參見 Security
- 返回
message S2C {
repeated ComboEvent comboEventList = 1; // 可 Combo 事件列表
optional string mvc = 2; // MVC 標的,格式 exchange.origin_symbol(詢價介面需透傳)
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
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_GetEventContractComboList::Request req;
Qot_GetEventContractComboList::C2S *c2s = req.mutable_c2s();
c2s->set_category("Sports");
c2s->set_count(5);
m_GetEventContractComboListSerialNo = m_pQotApi->GetEventContractComboList(req);
cout << "Request GetEventContractComboList SerialNo: " << m_GetEventContractComboListSerialNo << endl;
}
virtual void OnReply_GetEventContractComboList(moomoo::u32_t nSerialNo, const Qot_GetEventContractComboList::Response &stRsp) {
if (nSerialNo == m_GetEventContractComboListSerialNo)
{
cout << "OnReply_GetEventContractComboList 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_GetEventContractComboListSerialNo;
};
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
- Output
connect
Request GetEventContractComboList SerialNo: 1
OnReply_GetEventContractComboList SerialNo: 1
{
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"comboEventList": [
{
"eventSecurity": {"market": 101, "code": "EC.KXWCADVANCE-26JUL14FRAESP.EVENT"},
"eventName": "France vs Spain",
"comboContracts": [
{"market": 101, "code": "EC.KXWCADVANCE-26JUL14FRAESP-FRA"},
{"market": 101, "code": "EC.KXWCADVANCE-26JUL14FRAESP-ESP"}
],
"seriesSecurity": {"market": 101, "code": "EC.KXWCADVANCE.SERIES"},
"category": "Hot",
"competition": "FIFA World Cup",
"competitionScope": "Game"
}
],
"mvc": "KALSHI.KXMVECROSSCATEGORY-R"
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
GetEventContractComboList(req);
介紹
獲取可以參與 Combo(組合)的事件合約列表,支援按分類、賽事、Series 過濾。
參數
// 可 Combo 事件項
message ComboEvent {
required Qot_Common.Security eventSecurity = 1; // 事件標的 {market=101, code="EC.xxx"}
optional string eventName = 2; // 事件名稱(多語言)
repeated Qot_Common.Security comboContracts = 3; // 可組合的合約列表
optional Qot_Common.Security seriesSecurity = 4; // 所屬 Series
optional string category = 5; // 一級分類標識
optional string competition = 6; // 賽事名稱(多語言)
optional string competitionScope = 7; // 賽事類型/玩法(多語言)
}
message C2S {
optional string category = 1; // 一級分類過濾(如 "SPORTS")
optional string competition = 2; // 賽事過濾
optional Qot_Common.Security series = 3; // Series 標的過濾 {market=101, code="EC.xxx"}
optional string nextPage = 4; // 翻頁標記(首頁不填)
optional int32 count = 5; // 單頁最大返回數(預設 200)
}
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
- 返回
message S2C {
repeated ComboEvent comboEventList = 1; // 可 Combo 事件列表
optional string mvc = 2; // MVC 標的,格式 exchange.origin_symbol(詢價介面需透傳)
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 GetEventContractComboList() {
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: { category: "Sports", count: 5 } };
let { errCode, retMsg, retType, s2c } = await websocket.GetEventContractComboList(req);
console.log("GetEventContractComboList: 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
GetEventContractComboList: errCode 0, retMsg , retType 0
{
"comboEventList": [{
"eventSecurity": {
"market": 101,
"code": "EC.KXWCADVANCE-26JUL14FRAESP.EVENT"
},
"eventName": "France vs Spain",
"comboContracts": [
{"market": 101, "code": "EC.KXWCADVANCE-26JUL14FRAESP-FRA"},
{"market": 101, "code": "EC.KXWCADVANCE-26JUL14FRAESP-ESP"}
],
"seriesSecurity": {
"market": 101,
"code": "EC.KXWCADVANCE.SERIES"
},
"category": "Hot",
"competition": "FIFA World Cup",
"competitionScope": "Game"
}],
"mvc": "KALSHI.KXMVECROSSCATEGORY-R"
}
stop
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
介面限制
- 每 30 秒內最多請求 15 次獲取事件合約 Combo 列表介面