# イベントコントラクトティック取得
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_event_contract_ticker(code, count=30)
説明
単一のイベントコントラクトのリアルタイムティック(約定逐次)データを取得します。約定時間、YES/NO 約定価格、約定数量、ティック方向(YES/NO)を含みます。ティックを照会する前に
SubType.TICKERを登録しておく必要があります。そうでない場合、エラーが返されます。パラメータ
パラメータ 型 説明 code str イベントコントラクトコード、例: 'EC.KXODIMATCH-26JUL140600INDENG-IND'count int 返す件数、デフォルト 30、最大 1000 戻り値
パラメータ 型 説明 ret RET_CODE API呼出結果 data pd.DataFrame ret == RET_OK の場合、ティックリストを返します str ret != RET_OK の場合、エラーの説明を返します 返される DataFrame のフィールドは以下の通りです:
フィールド 型 説明 code str コントラクトコード time str 約定時間( yyyy-MM-dd HH:mm:ss、ミリ秒は保持しない)yes_price float YES 約定価格 no_price float NO 約定価格 volume float 約定数量 side str 約定方向、値は PredSide を参照( YES/NO)、取引の売買方向とは異なりますsequence str ティック通番(バックエンドの大きな整数) Example
from futu import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
# ティック照会前に TICKER タイプを登録する必要があります(そうでない場合エラーが返されます)
ret, err = quote_ctx.subscribe_event_contract(
['EC.KXODIMATCH-26JUL140600INDENG-IND'], [SubType.TICKER]
)
if ret != RET_OK:
print('登録失敗:', err)
else:
ret, data = quote_ctx.get_event_contract_ticker(
'EC.KXODIMATCH-26JUL140600INDENG-IND', count=5
)
if ret == RET_OK:
print(data)
else:
print('error:', data)
quote_ctx.close()
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
- Output
code time yes_price no_price volume side sequence
0 EC.KXODIMATCH-26JUL140600INDENG-IND 2026-07-14 14:00:22 0.0 0.01 7.57 NO 7662445088852672512
1 EC.KXODIMATCH-26JUL140600INDENG-IND 2026-07-14 14:00:33 0.0 0.01 14.18 NO 7662445136097312768
2 EC.KXODIMATCH-26JUL140600INDENG-IND 2026-07-14 14:00:50 0.0 0.01 106.14 NO 7662445209111756800
3 EC.KXODIMATCH-26JUL140600INDENG-IND 2026-07-14 14:00:59 0.0 0.01 5.82 NO 7662445247766462464
4 EC.KXODIMATCH-26JUL140600INDENG-IND 2026-07-14 14:01:01 0.0 0.01 111.50 NO 7662445256356397056
2
3
4
5
6
# Qot_GetEventContractTicker.proto
説明
単一のイベントコントラクトのティックデータを取得します。照会前に
SubType.TICKERを登録しておく必要があります。そうでない場合、エラーが返されます。パラメータ
// ティックデータポイント
message TickerPoint {
required string time = 1; // 約定時間(yyyy-MM-dd HH:mm:ss、ミリ秒は保持しない)
optional double yesPrice = 2; // YES 約定価格
optional double noPrice = 3; // NO 約定価格
optional double volume = 4; // 約定数量
optional Common.PredSide side = 5; // Ticker 方向
optional string sequence = 6; // ティック通番
}
// 単一コントラクトティック
message TickerItem {
required Qot_Common.Security code = 1; // コントラクトコード
repeated TickerPoint tickerList = 2; // ティックデータ
}
message C2S {
required Qot_Common.Security security = 1; // コントラクト標的(単一、必須)
optional int32 count = 2; // 返す件数(デフォルト30、最大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
- 戻り値
message S2C {
repeated TickerItem tickerList = 1; // ティックリスト
}
message Response {
required int32 retType = 1 [default = -400]; //RetType、戻り値
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
- API 呼び出し結果、構造は RetType を参照
uint GetEventContractTicker(GetEventContractTicker.Request req);
virtual void OnReply_GetEventContractTicker(FTAPI_Conn client, uint nSerialNo, GetEventContractTicker.Response rsp);
説明
単一のイベントコントラクトのティックデータを取得します。照会前に
SubType.TICKERを登録しておく必要があります。そうでない場合、エラーが返されます。パラメータ
message TickerPoint {
required string time = 1;
optional double yesPrice = 2;
optional double noPrice = 3;
optional double volume = 4;
optional Common.PredSide side = 5;
optional string sequence = 6;
}
message TickerItem {
required Qot_Common.Security code = 1;
repeated TickerPoint tickerList = 2;
}
message C2S {
required Qot_Common.Security security = 1;
optional int32 count = 2;
}
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 TickerItem tickerList = 1;
}
message Response {
required int32 retType = 1 [default = -400];
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
- API 呼び出し結果、構造は RetType を参照
- Example
public class Program : FTSPI_Qot, FTSPI_Conn
{
FTAPI_Qot qot = new FTAPI_Qot();
public Program()
{
qot.SetClientInfo("csharp", 1);
qot.SetConnCallback(this);
qot.SetQotCallback(this);
}
public void Start()
{
qot.InitConnect("127.0.0.1", (ushort)11111, false);
}
public void OnInitConnect(FTAPI_Conn client, long errCode, String desc)
{
if (errCode != 0) return;
QotCommon.Security sec = QotCommon.Security.CreateBuilder()
.SetMarket((int)QotCommon.QotMarket.QotMarket_EventContract)
.SetCode("EC.KXODIMATCH-26JUL140600INDENG-IND").Build();
var c2s = GetEventContractTicker.C2S.CreateBuilder()
.SetSecurity(sec).SetCount(30).Build();
var req = GetEventContractTicker.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetEventContractTicker(req);
Console.Write("Send GetEventContractTicker: {0}\n", seqNo);
}
public void OnReply_GetEventContractTicker(FTAPI_Conn client, uint nSerialNo, GetEventContractTicker.Response rsp)
{
Console.Write("Reply: {0} {1}\n", nSerialNo, rsp.ToString());
}
public static void Main(String[] args)
{
FTAPI.Init();
new Program().Start();
while (true) Thread.Sleep(1000 * 600);
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
- Output
connect
Request GetEventContractTicker SerialNo: 1
OnReply_GetEventContractTicker SerialNo: 1
{
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"tickerList": [
{
"code": {"market": 101, "code": "EC.KXODIMATCH-26JUL140600INDENG-IND"},
"tickerList": [
{
"time": "2026-07-14 14:00:22",
"yesPrice": 0.0,
"noPrice": 0.01,
"volume": 7.57,
"side": 2,
"sequence": "7662445088852672512"
},
{
"time": "2026-07-14 14:00:33",
"yesPrice": 0.0,
"noPrice": 0.01,
"volume": 14.18,
"side": 2,
"sequence": "7662445136097312768"
},
{
"time": "2026-07-14 14:00:50",
"yesPrice": 0.0,
"noPrice": 0.01,
"volume": 106.14,
"side": 2,
"sequence": "7662445209111756800"
},
{
"time": "2026-07-14 14:00:59",
"yesPrice": 0.0,
"noPrice": 0.01,
"volume": 5.82,
"side": 2,
"sequence": "7662445247766462464"
},
{
"time": "2026-07-14 14:01:01",
"yesPrice": 0.0,
"noPrice": 0.01,
"volume": 111.50,
"side": 2,
"sequence": "7662445256356397056"
}
]
}
]
}
}
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
int getEventContractTicker(QotGetEventContractTicker.Request req);
void onReply_GetEventContractTicker(FTAPI_Conn client, int nSerialNo, QotGetEventContractTicker.Response rsp);
説明
単一のイベントコントラクトのティックデータを取得します。照会前に
SubType.TICKERを登録しておく必要があります。そうでない場合、エラーが返されます。パラメータ
message C2S {
required Qot_Common.Security security = 1;
optional int32 count = 2;
}
message Request {
required C2S c2s = 1;
}
2
3
4
5
6
7
8
- 株式構造は Security を参照
- 戻り値
message S2C {
repeated TickerItem tickerList = 1;
}
message Response {
required int32 retType = 1 [default = -400];
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
- API 呼び出し結果、構造は RetType を参照
- Example
public class Program implements FTSPI_Qot, FTSPI_Conn {
private FTAPI_Conn_Qot qot = new FTAPI_Conn_Qot();
public Program() {
qot.setClientInfo("java", 1);
qot.setConnCallback(this);
qot.setQotCallback(this);
}
public void start() {
qot.initConnect("127.0.0.1", (short) 11111, false);
}
@Override
public void onInitConnect(FTAPI_Conn client, long errCode, String desc) {
if (errCode != 0) return;
QotCommon.Security sec = QotCommon.Security.newBuilder()
.setMarket(QotCommon.QotMarket.QotMarket_EventContract_VALUE)
.setCode("EC.KXODIMATCH-26JUL140600INDENG-IND").build();
QotGetEventContractTicker.C2S c2s = QotGetEventContractTicker.C2S.newBuilder()
.setSecurity(sec).setCount(30).build();
QotGetEventContractTicker.Request req = QotGetEventContractTicker.Request.newBuilder()
.setC2S(c2s).build();
int seqNo = qot.getEventContractTicker(req);
System.out.println("Send GetEventContractTicker: " + seqNo);
}
@Override
public void onReply_GetEventContractTicker(FTAPI_Conn client, int nSerialNo, QotGetEventContractTicker.Response rsp) {
System.out.println("Reply: " + nSerialNo + " " + rsp.toString());
}
public static void main(String[] args) {
FTAPI.init();
new Program().start();
while (true) {
try { Thread.sleep(1000 * 600); } catch (InterruptedException e) {}
}
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
- Output
connect
Request GetEventContractTicker SerialNo: 1
OnReply_GetEventContractTicker SerialNo: 1
{
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"tickerList": [
{
"code": {"market": 101, "code": "EC.KXODIMATCH-26JUL140600INDENG-IND"},
"tickerList": [
{
"time": "2026-07-14 14:00:22",
"yesPrice": 0.0,
"noPrice": 0.01,
"volume": 7.57,
"side": 2,
"sequence": "7662445088852672512"
},
{
"time": "2026-07-14 14:00:33",
"yesPrice": 0.0,
"noPrice": 0.01,
"volume": 14.18,
"side": 2,
"sequence": "7662445136097312768"
},
{
"time": "2026-07-14 14:00:50",
"yesPrice": 0.0,
"noPrice": 0.01,
"volume": 106.14,
"side": 2,
"sequence": "7662445209111756800"
},
{
"time": "2026-07-14 14:00:59",
"yesPrice": 0.0,
"noPrice": 0.01,
"volume": 5.82,
"side": 2,
"sequence": "7662445247766462464"
},
{
"time": "2026-07-14 14:01:01",
"yesPrice": 0.0,
"noPrice": 0.01,
"volume": 111.50,
"side": 2,
"sequence": "7662445256356397056"
}
]
}
]
}
}
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
Futu::u32_t GetEventContractTicker(const Qot_GetEventContractTicker::Request &stReq);
virtual void OnReply_GetEventContractTicker(Futu::u32_t nSerialNo, const Qot_GetEventContractTicker::Response &stRsp) = 0;
説明
単一のイベントコントラクトのティックデータを取得します。照会前に
SubType.TICKERを登録しておく必要があります。そうでない場合、エラーが返されます。パラメータ
// ティックデータポイント
message TickerPoint {
required string time = 1; // 約定時間(yyyy-MM-dd HH:mm:ss、ミリ秒は保持しない)
optional double yesPrice = 2; // YES 約定価格
optional double noPrice = 3; // NO 約定価格
optional double volume = 4; // 約定数量
optional Common.PredSide side = 5; // Ticker 方向
optional string sequence = 6; // ティック通番
}
// 単一コントラクトティック
message TickerItem {
required Qot_Common.Security code = 1; // コントラクトコード
repeated TickerPoint tickerList = 2; // ティックデータ
}
message C2S {
required Qot_Common.Security security = 1; // コントラクト標的(単一、必須)
optional int32 count = 2; // 返す件数(デフォルト30、最大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
- 戻り値
message S2C {
repeated TickerItem tickerList = 1; // ティックリスト
}
message Response {
required int32 retType = 1 [default = -400]; //RetType、戻り値
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
- API 呼び出し結果、構造は 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_GetEventContractTicker::Request req;
Qot_GetEventContractTicker::C2S *c2s = req.mutable_c2s();
Qot_Common::Security *sec = c2s->mutable_security();
sec->set_code("EC.KXODIMATCH-26JUL140600INDENG-IND");
sec->set_market(Qot_Common::QotMarket::QotMarket_EventContract);
c2s->set_count(30);
m_GetEventContractTickerSerialNo = m_pQotApi->GetEventContractTicker(req);
cout << "Request GetEventContractTicker SerialNo: " << m_GetEventContractTickerSerialNo << endl;
}
virtual void OnReply_GetEventContractTicker(Futu::u32_t nSerialNo, const Qot_GetEventContractTicker::Response &stRsp) {
if (nSerialNo == m_GetEventContractTickerSerialNo)
{
cout << "OnReply_GetEventContractTicker 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_GetEventContractTickerSerialNo;
};
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 GetEventContractTicker SerialNo: 1
OnReply_GetEventContractTicker SerialNo: 1
{
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"tickerList": [
{
"code": {"market": 101, "code": "EC.KXODIMATCH-26JUL140600INDENG-IND"},
"tickerList": [
{
"time": "2026-07-14 14:00:22",
"yesPrice": 0.0,
"noPrice": 0.01,
"volume": 7.57,
"side": 2,
"sequence": "7662445088852672512"
},
{
"time": "2026-07-14 14:00:33",
"yesPrice": 0.0,
"noPrice": 0.01,
"volume": 14.18,
"side": 2,
"sequence": "7662445136097312768"
},
{
"time": "2026-07-14 14:00:50",
"yesPrice": 0.0,
"noPrice": 0.01,
"volume": 106.14,
"side": 2,
"sequence": "7662445209111756800"
},
{
"time": "2026-07-14 14:00:59",
"yesPrice": 0.0,
"noPrice": 0.01,
"volume": 5.82,
"side": 2,
"sequence": "7662445247766462464"
},
{
"time": "2026-07-14 14:01:01",
"yesPrice": 0.0,
"noPrice": 0.01,
"volume": 111.50,
"side": 2,
"sequence": "7662445256356397056"
}
]
}
]
}
}
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
GetEventContractTicker(req);
説明
単一のイベントコントラクトのティック(約定逐次)データを取得します。照会前に
SubType.TICKERを登録しておく必要があります。そうでない場合、エラーが返されます。パラメータ
// ティックデータポイント
message TickerPoint {
required string time = 1; // 約定時間(yyyy-MM-dd HH:mm:ss)
optional double yesPrice = 2; // YES 約定価格
optional double noPrice = 3; // NO 約定価格
optional double volume = 4; // 約定数量
optional Common.PredSide side = 5; // Ticker 方向
optional string sequence = 6; // ティック通番
}
// 単一コントラクトティック
message TickerItem {
required Qot_Common.Security code = 1; // コントラクトコード
repeated TickerPoint tickerList = 2; // ティックデータ
}
message C2S {
required Qot_Common.Security security = 1; // コントラクト標的(単一、必須)
optional int32 count = 2; // 返す件数(デフォルト30、最大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
- 戻り値
message S2C {
repeated TickerItem tickerList = 1; // ティックリスト
}
message Response {
required int32 retType = 1 [default = -400]; //RetType、戻り値
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
- API 呼び出し結果、構造は RetType を参照
- Example
import ftWebsocket from "futu-api";
import { Common, Qot_Common } from "futu-api/proto";
import beautify from "js-beautify";
function GetEventContractTicker() {
const { RetType } = Common;
const { QotMarket } = Qot_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: { security: { market: QotMarket.QotMarket_EventContract, code: "EC.KXODIMATCH-26JUL140600INDENG-IND" }, count: 30 } };
let { errCode, retMsg, retType, s2c } = await websocket.GetEventContractTicker(req);
console.log("GetEventContractTicker: 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
27
- Output
GetEventContractTicker: errCode 0, retMsg , retType 0
{
"tickerList": [{
"code": {
"market": 101,
"code": "EC.KXODIMATCH-26JUL140600INDENG-IND"
},
"tickerList": [{
"time": "2026-07-14 14:00:22",
"yesPrice": 0.0,
"noPrice": 0.01,
"volume": 7.57,
"side": 2,
"sequence": "7662445088852672512"
}, {
"time": "2026-07-14 14:00:33",
"yesPrice": 0.0,
"noPrice": 0.01,
"volume": 14.18,
"side": 2,
"sequence": "7662445136097312768"
}, {
"time": "2026-07-14 14:00:50",
"yesPrice": 0.0,
"noPrice": 0.01,
"volume": 106.14,
"side": 2,
"sequence": "7662445209111756800"
}, {
"time": "2026-07-14 14:00:59",
"yesPrice": 0.0,
"noPrice": 0.01,
"volume": 5.82,
"side": 2,
"sequence": "7662445247766462464"
}, {
"time": "2026-07-14 14:01:01",
"yesPrice": 0.0,
"noPrice": 0.01,
"volume": 111.50,
"side": 2,
"sequence": "7662445256356397056"
}]
}]
}
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
45
46
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_event_contract_ticker(code, count=30)
説明
単一のイベントコントラクトのリアルタイムティック(約定逐次)データを取得します。約定時間、YES/NO 約定価格、約定数量、ティック方向(YES/NO)を含みます。ティックを照会する前に
SubType.TICKERを登録しておく必要があります。そうでない場合、エラーが返されます。パラメータ
パラメータ 型 説明 code str イベントコントラクトコード、例: 'EC.KXODIMATCH-26JUL140600INDENG-IND'count int 返す件数、デフォルト 30、最大 1000 戻り値
パラメータ 型 説明 ret RET_CODE API呼出結果 data pd.DataFrame ret == RET_OK の場合、ティックリストを返します str ret != RET_OK の場合、エラーの説明を返します 返される DataFrame のフィールドは以下の通りです:
フィールド 型 説明 code str コントラクトコード time str 約定時間( yyyy-MM-dd HH:mm:ss、ミリ秒は保持しない)yes_price float YES 約定価格 no_price float NO 約定価格 volume float 約定数量 side str 約定方向、値は PredSide を参照( YES/NO)、取引の売買方向とは異なりますsequence str ティック通番(バックエンドの大きな整数) Example
from moomoo import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
# ティック照会前に TICKER タイプを登録する必要があります(そうでない場合エラーが返されます)
ret, err = quote_ctx.subscribe_event_contract(
['EC.KXODIMATCH-26JUL140600INDENG-IND'], [SubType.TICKER]
)
if ret != RET_OK:
print('登録失敗:', err)
else:
ret, data = quote_ctx.get_event_contract_ticker(
'EC.KXODIMATCH-26JUL140600INDENG-IND', count=5
)
if ret == RET_OK:
print(data)
else:
print('error:', data)
quote_ctx.close()
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
- Output
code time yes_price no_price volume side sequence
0 EC.KXODIMATCH-26JUL140600INDENG-IND 2026-07-14 14:00:22 0.0 0.01 7.57 NO 7662445088852672512
1 EC.KXODIMATCH-26JUL140600INDENG-IND 2026-07-14 14:00:33 0.0 0.01 14.18 NO 7662445136097312768
2 EC.KXODIMATCH-26JUL140600INDENG-IND 2026-07-14 14:00:50 0.0 0.01 106.14 NO 7662445209111756800
3 EC.KXODIMATCH-26JUL140600INDENG-IND 2026-07-14 14:00:59 0.0 0.01 5.82 NO 7662445247766462464
4 EC.KXODIMATCH-26JUL140600INDENG-IND 2026-07-14 14:01:01 0.0 0.01 111.50 NO 7662445256356397056
2
3
4
5
6
# Qot_GetEventContractTicker.proto
説明
単一のイベントコントラクトのティックデータを取得します。照会前に
SubType.TICKERを登録しておく必要があります。そうでない場合、エラーが返されます。パラメータ
// ティックデータポイント
message TickerPoint {
required string time = 1; // 約定時間(yyyy-MM-dd HH:mm:ss、ミリ秒は保持しない)
optional double yesPrice = 2; // YES 約定価格
optional double noPrice = 3; // NO 約定価格
optional double volume = 4; // 約定数量
optional Common.PredSide side = 5; // Ticker 方向
optional string sequence = 6; // ティック通番
}
// 単一コントラクトティック
message TickerItem {
required Qot_Common.Security code = 1; // コントラクトコード
repeated TickerPoint tickerList = 2; // ティックデータ
}
message C2S {
required Qot_Common.Security security = 1; // コントラクト標的(単一、必須)
optional int32 count = 2; // 返す件数(デフォルト30、最大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
- 戻り値
message S2C {
repeated TickerItem tickerList = 1; // ティックリスト
}
message Response {
required int32 retType = 1 [default = -400]; //RetType、戻り値
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
- API 呼び出し結果、構造は RetType を参照
uint GetEventContractTicker(GetEventContractTicker.Request req);
virtual void OnReply_GetEventContractTicker(MMAPI_Conn client, uint nSerialNo, GetEventContractTicker.Response rsp);
説明
単一のイベントコントラクトのティックデータを取得します。照会前に
SubType.TICKERを登録しておく必要があります。そうでない場合、エラーが返されます。パラメータ
message TickerPoint {
required string time = 1;
optional double yesPrice = 2;
optional double noPrice = 3;
optional double volume = 4;
optional Common.PredSide side = 5;
optional string sequence = 6;
}
message TickerItem {
required Qot_Common.Security code = 1;
repeated TickerPoint tickerList = 2;
}
message C2S {
required Qot_Common.Security security = 1;
optional int32 count = 2;
}
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 TickerItem tickerList = 1;
}
message Response {
required int32 retType = 1 [default = -400];
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
- API 呼び出し結果、構造は RetType を参照
- Example
public class Program : MMSPI_Qot, MMSPI_Conn
{
MMAPI_Qot qot = new MMAPI_Qot();
public Program()
{
qot.SetClientInfo("csharp", 1);
qot.SetConnCallback(this);
qot.SetQotCallback(this);
}
public void Start()
{
qot.InitConnect("127.0.0.1", (ushort)11111, false);
}
public void OnInitConnect(MMAPI_Conn client, long errCode, String desc)
{
if (errCode != 0) return;
QotCommon.Security sec = QotCommon.Security.CreateBuilder()
.SetMarket((int)QotCommon.QotMarket.QotMarket_EventContract)
.SetCode("EC.KXODIMATCH-26JUL140600INDENG-IND").Build();
var c2s = GetEventContractTicker.C2S.CreateBuilder()
.SetSecurity(sec).SetCount(30).Build();
var req = GetEventContractTicker.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetEventContractTicker(req);
Console.Write("Send GetEventContractTicker: {0}\n", seqNo);
}
public void OnReply_GetEventContractTicker(MMAPI_Conn client, uint nSerialNo, GetEventContractTicker.Response rsp)
{
Console.Write("Reply: {0} {1}\n", nSerialNo, rsp.ToString());
}
public static void Main(String[] args)
{
MMAPI.Init();
new Program().Start();
while (true) Thread.Sleep(1000 * 600);
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
- Output
connect
Request GetEventContractTicker SerialNo: 1
OnReply_GetEventContractTicker SerialNo: 1
{
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"tickerList": [
{
"code": {"market": 101, "code": "EC.KXODIMATCH-26JUL140600INDENG-IND"},
"tickerList": [
{
"time": "2026-07-14 14:00:22",
"yesPrice": 0.0,
"noPrice": 0.01,
"volume": 7.57,
"side": 2,
"sequence": "7662445088852672512"
},
{
"time": "2026-07-14 14:00:33",
"yesPrice": 0.0,
"noPrice": 0.01,
"volume": 14.18,
"side": 2,
"sequence": "7662445136097312768"
},
{
"time": "2026-07-14 14:00:50",
"yesPrice": 0.0,
"noPrice": 0.01,
"volume": 106.14,
"side": 2,
"sequence": "7662445209111756800"
},
{
"time": "2026-07-14 14:00:59",
"yesPrice": 0.0,
"noPrice": 0.01,
"volume": 5.82,
"side": 2,
"sequence": "7662445247766462464"
},
{
"time": "2026-07-14 14:01:01",
"yesPrice": 0.0,
"noPrice": 0.01,
"volume": 111.50,
"side": 2,
"sequence": "7662445256356397056"
}
]
}
]
}
}
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
int getEventContractTicker(QotGetEventContractTicker.Request req);
void onReply_GetEventContractTicker(MMAPI_Conn client, int nSerialNo, QotGetEventContractTicker.Response rsp);
説明
単一のイベントコントラクトのティックデータを取得します。照会前に
SubType.TICKERを登録しておく必要があります。そうでない場合、エラーが返されます。パラメータ
message C2S {
required Qot_Common.Security security = 1;
optional int32 count = 2;
}
message Request {
required C2S c2s = 1;
}
2
3
4
5
6
7
8
- 株式構造は Security を参照
- 戻り値
message S2C {
repeated TickerItem tickerList = 1;
}
message Response {
required int32 retType = 1 [default = -400];
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
- API 呼び出し結果、構造は RetType を参照
- Example
public class Program implements MMSPI_Qot, MMSPI_Conn {
private MMAPI_Conn_Qot qot = new MMAPI_Conn_Qot();
public Program() {
qot.setClientInfo("java", 1);
qot.setConnCallback(this);
qot.setQotCallback(this);
}
public void start() {
qot.initConnect("127.0.0.1", (short) 11111, false);
}
@Override
public void onInitConnect(MMAPI_Conn client, long errCode, String desc) {
if (errCode != 0) return;
QotCommon.Security sec = QotCommon.Security.newBuilder()
.setMarket(QotCommon.QotMarket.QotMarket_EventContract_VALUE)
.setCode("EC.KXODIMATCH-26JUL140600INDENG-IND").build();
QotGetEventContractTicker.C2S c2s = QotGetEventContractTicker.C2S.newBuilder()
.setSecurity(sec).setCount(30).build();
QotGetEventContractTicker.Request req = QotGetEventContractTicker.Request.newBuilder()
.setC2S(c2s).build();
int seqNo = qot.getEventContractTicker(req);
System.out.println("Send GetEventContractTicker: " + seqNo);
}
@Override
public void onReply_GetEventContractTicker(MMAPI_Conn client, int nSerialNo, QotGetEventContractTicker.Response rsp) {
System.out.println("Reply: " + nSerialNo + " " + rsp.toString());
}
public static void main(String[] args) {
MMAPI.init();
new Program().start();
while (true) {
try { Thread.sleep(1000 * 600); } catch (InterruptedException e) {}
}
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
- Output
connect
Request GetEventContractTicker SerialNo: 1
OnReply_GetEventContractTicker SerialNo: 1
{
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"tickerList": [
{
"code": {"market": 101, "code": "EC.KXODIMATCH-26JUL140600INDENG-IND"},
"tickerList": [
{
"time": "2026-07-14 14:00:22",
"yesPrice": 0.0,
"noPrice": 0.01,
"volume": 7.57,
"side": 2,
"sequence": "7662445088852672512"
},
{
"time": "2026-07-14 14:00:33",
"yesPrice": 0.0,
"noPrice": 0.01,
"volume": 14.18,
"side": 2,
"sequence": "7662445136097312768"
},
{
"time": "2026-07-14 14:00:50",
"yesPrice": 0.0,
"noPrice": 0.01,
"volume": 106.14,
"side": 2,
"sequence": "7662445209111756800"
},
{
"time": "2026-07-14 14:00:59",
"yesPrice": 0.0,
"noPrice": 0.01,
"volume": 5.82,
"side": 2,
"sequence": "7662445247766462464"
},
{
"time": "2026-07-14 14:01:01",
"yesPrice": 0.0,
"noPrice": 0.01,
"volume": 111.50,
"side": 2,
"sequence": "7662445256356397056"
}
]
}
]
}
}
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
moomoo::u32_t GetEventContractTicker(const Qot_GetEventContractTicker::Request &stReq);
virtual void OnReply_GetEventContractTicker(moomoo::u32_t nSerialNo, const Qot_GetEventContractTicker::Response &stRsp) = 0;
説明
単一のイベントコントラクトのティックデータを取得します。照会前に
SubType.TICKERを登録しておく必要があります。そうでない場合、エラーが返されます。パラメータ
// ティックデータポイント
message TickerPoint {
required string time = 1; // 約定時間(yyyy-MM-dd HH:mm:ss、ミリ秒は保持しない)
optional double yesPrice = 2; // YES 約定価格
optional double noPrice = 3; // NO 約定価格
optional double volume = 4; // 約定数量
optional Common.PredSide side = 5; // Ticker 方向
optional string sequence = 6; // ティック通番
}
// 単一コントラクトティック
message TickerItem {
required Qot_Common.Security code = 1; // コントラクトコード
repeated TickerPoint tickerList = 2; // ティックデータ
}
message C2S {
required Qot_Common.Security security = 1; // コントラクト標的(単一、必須)
optional int32 count = 2; // 返す件数(デフォルト30、最大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
- 戻り値
message S2C {
repeated TickerItem tickerList = 1; // ティックリスト
}
message Response {
required int32 retType = 1 [default = -400]; //RetType、戻り値
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
- API 呼び出し結果、構造は 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_GetEventContractTicker::Request req;
Qot_GetEventContractTicker::C2S *c2s = req.mutable_c2s();
Qot_Common::Security *sec = c2s->mutable_security();
sec->set_code("EC.KXODIMATCH-26JUL140600INDENG-IND");
sec->set_market(Qot_Common::QotMarket::QotMarket_EventContract);
c2s->set_count(30);
m_GetEventContractTickerSerialNo = m_pQotApi->GetEventContractTicker(req);
cout << "Request GetEventContractTicker SerialNo: " << m_GetEventContractTickerSerialNo << endl;
}
virtual void OnReply_GetEventContractTicker(moomoo::u32_t nSerialNo, const Qot_GetEventContractTicker::Response &stRsp) {
if (nSerialNo == m_GetEventContractTickerSerialNo)
{
cout << "OnReply_GetEventContractTicker 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_GetEventContractTickerSerialNo;
};
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 GetEventContractTicker SerialNo: 1
OnReply_GetEventContractTicker SerialNo: 1
{
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"tickerList": [
{
"code": {"market": 101, "code": "EC.KXODIMATCH-26JUL140600INDENG-IND"},
"tickerList": [
{
"time": "2026-07-14 14:00:22",
"yesPrice": 0.0,
"noPrice": 0.01,
"volume": 7.57,
"side": 2,
"sequence": "7662445088852672512"
},
{
"time": "2026-07-14 14:00:33",
"yesPrice": 0.0,
"noPrice": 0.01,
"volume": 14.18,
"side": 2,
"sequence": "7662445136097312768"
},
{
"time": "2026-07-14 14:00:50",
"yesPrice": 0.0,
"noPrice": 0.01,
"volume": 106.14,
"side": 2,
"sequence": "7662445209111756800"
},
{
"time": "2026-07-14 14:00:59",
"yesPrice": 0.0,
"noPrice": 0.01,
"volume": 5.82,
"side": 2,
"sequence": "7662445247766462464"
},
{
"time": "2026-07-14 14:01:01",
"yesPrice": 0.0,
"noPrice": 0.01,
"volume": 111.50,
"side": 2,
"sequence": "7662445256356397056"
}
]
}
]
}
}
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
GetEventContractTicker(req);
説明
単一のイベントコントラクトのティック(約定逐次)データを取得します。照会前に
SubType.TICKERを登録しておく必要があります。そうでない場合、エラーが返されます。パラメータ
// ティックデータポイント
message TickerPoint {
required string time = 1; // 約定時間(yyyy-MM-dd HH:mm:ss)
optional double yesPrice = 2; // YES 約定価格
optional double noPrice = 3; // NO 約定価格
optional double volume = 4; // 約定数量
optional Common.PredSide side = 5; // Ticker 方向
optional string sequence = 6; // ティック通番
}
// 単一コントラクトティック
message TickerItem {
required Qot_Common.Security code = 1; // コントラクトコード
repeated TickerPoint tickerList = 2; // ティックデータ
}
message C2S {
required Qot_Common.Security security = 1; // コントラクト標的(単一、必須)
optional int32 count = 2; // 返す件数(デフォルト30、最大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
- 戻り値
message S2C {
repeated TickerItem tickerList = 1; // ティックリスト
}
message Response {
required int32 retType = 1 [default = -400]; //RetType、戻り値
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
- API 呼び出し結果、構造は RetType を参照
- Example
import mmWebsocket from "moomoo-api";
import { Common, Qot_Common } from "moomoo-api/proto";
import beautify from "js-beautify";
function GetEventContractTicker() {
const { RetType } = Common;
const { QotMarket } = Qot_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: { security: { market: QotMarket.QotMarket_EventContract, code: "EC.KXODIMATCH-26JUL140600INDENG-IND" }, count: 30 } };
let { errCode, retMsg, retType, s2c } = await websocket.GetEventContractTicker(req);
console.log("GetEventContractTicker: 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
27
- Output
GetEventContractTicker: errCode 0, retMsg , retType 0
{
"tickerList": [{
"code": {
"market": 101,
"code": "EC.KXODIMATCH-26JUL140600INDENG-IND"
},
"tickerList": [{
"time": "2026-07-14 14:00:22",
"yesPrice": 0.0,
"noPrice": 0.01,
"volume": 7.57,
"side": 2,
"sequence": "7662445088852672512"
}, {
"time": "2026-07-14 14:00:33",
"yesPrice": 0.0,
"noPrice": 0.01,
"volume": 14.18,
"side": 2,
"sequence": "7662445136097312768"
}, {
"time": "2026-07-14 14:00:50",
"yesPrice": 0.0,
"noPrice": 0.01,
"volume": 106.14,
"side": 2,
"sequence": "7662445209111756800"
}, {
"time": "2026-07-14 14:00:59",
"yesPrice": 0.0,
"noPrice": 0.01,
"volume": 5.82,
"side": 2,
"sequence": "7662445247766462464"
}, {
"time": "2026-07-14 14:01:01",
"yesPrice": 0.0,
"noPrice": 0.01,
"volume": 111.50,
"side": 2,
"sequence": "7662445256356397056"
}]
}]
}
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
45
46