# イベントコントラクト全登録解除
- Python
- Proto
- C#
- Java
- C++
- JavaScript
unsubscribe_all_event_contract()
説明
現在の接続におけるすべてのイベントコントラクトのリアルタイム行情購読を解除します。呼び出し後、板、K 線、ティックなどのプッシュ配信は受信されなくなります。
パラメータ
このインターフェースはパラメータなしで、現在の接続におけるすべてのイベントコントラクト購読を解除します。
戻り値
パラメータ タイプ 説明 ret RET_CODE インターフェース呼び出し結果 err_message None ret == RET_OK の場合は None を返します str ret != RET_OK の場合はエラー説明を返します Example
from futu import *
import time
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
# 複数のイベントコントラクトを登録
quote_ctx.subscribe_event_contract(
['EC.KXODIMATCH-26JUL140600INDENG-IND'], [SubType.TICKER]
)
quote_ctx.subscribe_event_contract(
['EC.KXNFLAFCCHAMP-27-CIN'], [SubType.K_DAY]
)
# 登録から 1 分経過後にのみ解除可能
time.sleep(62)
# すべての登録を一括解除
ret, err = quote_ctx.unsubscribe_all_event_contract()
if ret == RET_OK:
print('すべてのイベントコントラクト購読を解除しました')
else:
print('解除失敗:', err)
quote_ctx.close()
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
- Output
すべてのイベントコントラクト購読を解除しました
# Qot_SubEventContract.proto
説明
現在の接続におけるすべてのイベントコントラクトのリアルタイム行情購読を解除します。C2S の isUnsubAll を true に設定することに対応し、この時他のパラメータは無視されます。
パラメータ
// イベントコントラクト購読/購読解除
message C2S
{
repeated Qot_Common.Security securityList = 1; // 契約標的(market+code)、購読の意味は汎用購読と一致
repeated int32 subTypeList = 2; // Qot_Common.SubType、汎用購読タイプを再利用
required bool isSubOrUnSub = 3; // true で購読 / false で解除
optional bool isRegOrUnRegPush = 4; // プッシュを登録/解除するか
optional bool isFirstPush = 5; // 登録後に既存データを初回プッシュするか、デフォルト true
optional bool isUnsubAll = 6; // true の時は他のパラメータを無視し、該当接続の全 EC 購読を解除
repeated Qot_Common.EC_KlineSource klineSource = 7; // K 線出所リスト(None/OrderBookYes)、KL_* 購読時に有効、未指定時はデフォルト [None]
optional Qot_Common.QotHeader header = 100; // 行情共通パラメータヘッダー
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
- 戻り値
message S2C
{
}
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
- インターフェース呼び出し結果、構造は RetType を参照
プロトコル ID
3455
uint SubEventContract(SubEventContract.Request req); virtual void OnReply_SubEventContract(FTAPI_Conn client, uint nSerialNo, SubEventContract.Response rsp);
説明
現在の接続におけるすべてのイベントコントラクトのリアルタイム行情購読を解除します。C2S の isUnsubAll を true に設定することに対応し、この時他のパラメータは無視されます。
パラメータ
message C2S
{
repeated Qot_Common.Security securityList = 1;
repeated int32 subTypeList = 2;
required bool isSubOrUnSub = 3;
optional bool isRegOrUnRegPush = 4;
optional bool isFirstPush = 5;
optional bool isUnsubAll = 6;
repeated Qot_Common.EC_KlineSource klineSource = 7;
optional Qot_Common.QotHeader header = 100;
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
- 証券構造は Security を参照
- 戻り値
message S2C
{
}
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
- インターフェース呼び出し結果、構造は 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;
// 現在の接続のすべてのイベントコントラクト購読を解除、isUnsubAll を true に設定
var c2s = SubEventContract.C2S.CreateBuilder()
.SetIsUnsubAll(true).Build();
var req = SubEventContract.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.SubEventContract(req);
Console.Write("Send SubEventContract(UnsubAll): {0}\n", seqNo);
}
public void OnReply_SubEventContract(FTAPI_Conn client, uint nSerialNo, SubEventContract.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
int subEventContract(QotSubEventContract.Request req); void onReply_SubEventContract(FTAPI_Conn client, int nSerialNo, QotSubEventContract.Response rsp);
説明
現在の接続におけるすべてのイベントコントラクトのリアルタイム行情購読を解除します。C2S の isUnsubAll を true に設定することに対応し、この時他のパラメータは無視されます。
パラメータ
message C2S
{
repeated Qot_Common.Security securityList = 1;
repeated int32 subTypeList = 2;
required bool isSubOrUnSub = 3;
optional bool isRegOrUnRegPush = 4;
optional bool isFirstPush = 5;
optional bool isUnsubAll = 6;
repeated Qot_Common.EC_KlineSource klineSource = 7;
optional Qot_Common.QotHeader header = 100;
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
- 証券構造は Security を参照
- 戻り値
message S2C
{
}
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
- インターフェース呼び出し結果、構造は 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;
// 現在の接続のすべてのイベントコントラクト購読を解除、isUnsubAll を true に設定
QotSubEventContract.C2S c2s = QotSubEventContract.C2S.newBuilder()
.setIsUnsubAll(true).build();
QotSubEventContract.Request req = QotSubEventContract.Request.newBuilder()
.setC2S(c2s).build();
int seqNo = qot.subEventContract(req);
System.out.println("Send SubEventContract(UnsubAll): " + seqNo);
}
@Override
public void onReply_SubEventContract(FTAPI_Conn client, int nSerialNo, QotSubEventContract.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
Futu::u32_t SubEventContract(const Qot_SubEventContract::Request &stReq); virtual void OnReply_SubEventContract(Futu::u32_t nSerialNo, const Qot_SubEventContract::Response &stRsp) = 0;
説明
現在の接続におけるすべてのイベントコントラクトのリアルタイム行情購読を解除します。C2S の isUnsubAll を true に設定することに対応し、この時他のパラメータは無視されます。
パラメータ
// イベントコントラクト購読/購読解除
message C2S
{
repeated Qot_Common.Security securityList = 1; // 契約標的(market+code)、購読の意味は汎用購読と一致
repeated int32 subTypeList = 2; // Qot_Common.SubType、汎用購読タイプを再利用
required bool isSubOrUnSub = 3; // true で購読 / false で解除
optional bool isRegOrUnRegPush = 4; // プッシュを登録/解除するか
optional bool isFirstPush = 5; // 登録後に既存データを初回プッシュするか、デフォルト true
optional bool isUnsubAll = 6; // true の時は他のパラメータを無視し、該当接続の全 EC 購読を解除
repeated Qot_Common.EC_KlineSource klineSource = 7; // K 線出所リスト(None/OrderBookYes)、KL_* 購読時に有効、未指定時はデフォルト [None]
optional Qot_Common.QotHeader header = 100; // 行情共通パラメータヘッダー
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
- 証券構造は Security を参照
- 戻り値
message S2C
{
}
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
- インターフェース呼び出し結果、構造は 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;
// リクエストを構築:現在の接続のすべてのイベントコントラクト購読を解除、isUnsubAll を true に設定
Qot_SubEventContract::Request req;
Qot_SubEventContract::C2S *c2s = req.mutable_c2s();
c2s->set_isunsuball(true);
m_SubEventContractSerialNo = m_pQotApi->SubEventContract(req);
cout << "Request SubEventContract(UnsubAll) SerialNo: " << m_SubEventContractSerialNo << endl;
}
virtual void OnReply_SubEventContract(Futu::u32_t nSerialNo, const Qot_SubEventContract::Response &stRsp) {
if (nSerialNo == m_SubEventContractSerialNo)
{
cout << "OnReply_SubEventContract 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_SubEventContractSerialNo;
};
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
- Output
connect
Request SubEventContract(UnsubAll) SerialNo: 1
OnReply_SubEventContract SerialNo: 1
{
"retType": 0,
"retMsg": "",
"errCode": 0
}
2
3
4
5
6
7
8
SubEventContract(req);
説明
現在の接続におけるすべてのイベントコントラクトのリアルタイム行情購読を解除します。c2s の isUnsubAll を true に設定することに対応し、この時他のパラメータは無視されます。
パラメータ
message C2S
{
repeated Qot_Common.Security securityList = 1;
repeated int32 subTypeList = 2;
required bool isSubOrUnSub = 3;
optional bool isRegOrUnRegPush = 4;
optional bool isFirstPush = 5;
optional bool isUnsubAll = 6;
repeated Qot_Common.EC_KlineSource klineSource = 7;
optional Qot_Common.QotHeader header = 100;
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
- 証券構造は Security を参照
- 戻り値
message S2C
{
}
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
- インターフェース呼び出し結果、構造は RetType を参照
- Example
const ftWebsocket = require('futu-api');
let websocket = new ftWebsocket.WebsocketService();
websocket.onlogin = function() {
let req = {
proto: 'Qot_SubEventContract',
req: {
c2s: {
isUnsubAll: true
}
}
};
websocket.SubEventContract(req).then(res => {
console.log(JSON.stringify(res));
});
};
websocket.connect('127.0.0.1:11111');
setTimeout(() => websocket.stop(), 60000);
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
- Python
- Proto
- C#
- Java
- C++
- JavaScript
unsubscribe_all_event_contract()
説明
現在の接続におけるすべてのイベントコントラクトのリアルタイム行情購読を解除します。呼び出し後、板、K 線、ティックなどのプッシュ配信は受信されなくなります。
パラメータ
このインターフェースはパラメータなしで、現在の接続におけるすべてのイベントコントラクト購読を解除します。
戻り値
パラメータ タイプ 説明 ret RET_CODE インターフェース呼び出し結果 err_message None ret == RET_OK の場合は None を返します str ret != RET_OK の場合はエラー説明を返します Example
from moomoo import *
import time
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
# 複数のイベントコントラクトを登録
quote_ctx.subscribe_event_contract(
['EC.KXODIMATCH-26JUL140600INDENG-IND'], [SubType.TICKER]
)
quote_ctx.subscribe_event_contract(
['EC.KXNFLAFCCHAMP-27-CIN'], [SubType.K_DAY]
)
# 登録から 1 分経過後にのみ解除可能
time.sleep(62)
# すべての登録を一括解除
ret, err = quote_ctx.unsubscribe_all_event_contract()
if ret == RET_OK:
print('すべてのイベントコントラクト購読を解除しました')
else:
print('解除失敗:', err)
quote_ctx.close()
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
- Output
すべてのイベントコントラクト購読を解除しました
# Qot_SubEventContract.proto
説明
現在の接続におけるすべてのイベントコントラクトのリアルタイム行情購読を解除します。C2S の isUnsubAll を true に設定することに対応し、この時他のパラメータは無視されます。
パラメータ
// イベントコントラクト購読/購読解除
message C2S
{
repeated Qot_Common.Security securityList = 1; // 契約標的(market+code)、購読の意味は汎用購読と一致
repeated int32 subTypeList = 2; // Qot_Common.SubType、汎用購読タイプを再利用
required bool isSubOrUnSub = 3; // true で購読 / false で解除
optional bool isRegOrUnRegPush = 4; // プッシュを登録/解除するか
optional bool isFirstPush = 5; // 登録後に既存データを初回プッシュするか、デフォルト true
optional bool isUnsubAll = 6; // true の時は他のパラメータを無視し、該当接続の全 EC 購読を解除
repeated Qot_Common.EC_KlineSource klineSource = 7; // K 線出所リスト(None/OrderBookYes)、KL_* 購読時に有効、未指定時はデフォルト [None]
optional Qot_Common.QotHeader header = 100; // 行情共通パラメータヘッダー
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
- 戻り値
message S2C
{
}
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
- インターフェース呼び出し結果、構造は RetType を参照
プロトコル ID
3455
uint SubEventContract(SubEventContract.Request req); virtual void OnReply_SubEventContract(MMAPI_Conn client, uint nSerialNo, SubEventContract.Response rsp);
説明
現在の接続におけるすべてのイベントコントラクトのリアルタイム行情購読を解除します。C2S の isUnsubAll を true に設定することに対応し、この時他のパラメータは無視されます。
パラメータ
message C2S
{
repeated Qot_Common.Security securityList = 1;
repeated int32 subTypeList = 2;
required bool isSubOrUnSub = 3;
optional bool isRegOrUnRegPush = 4;
optional bool isFirstPush = 5;
optional bool isUnsubAll = 6;
repeated Qot_Common.EC_KlineSource klineSource = 7;
optional Qot_Common.QotHeader header = 100;
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
- 証券構造は Security を参照
- 戻り値
message S2C
{
}
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
- インターフェース呼び出し結果、構造は 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;
// 現在の接続のすべてのイベントコントラクト購読を解除、isUnsubAll を true に設定
var c2s = SubEventContract.C2S.CreateBuilder()
.SetIsUnsubAll(true).Build();
var req = SubEventContract.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.SubEventContract(req);
Console.Write("Send SubEventContract(UnsubAll): {0}\n", seqNo);
}
public void OnReply_SubEventContract(MMAPI_Conn client, uint nSerialNo, SubEventContract.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
int subEventContract(QotSubEventContract.Request req); void onReply_SubEventContract(MMAPI_Conn client, int nSerialNo, QotSubEventContract.Response rsp);
説明
現在の接続におけるすべてのイベントコントラクトのリアルタイム行情購読を解除します。C2S の isUnsubAll を true に設定することに対応し、この時他のパラメータは無視されます。
パラメータ
message C2S
{
repeated Qot_Common.Security securityList = 1;
repeated int32 subTypeList = 2;
required bool isSubOrUnSub = 3;
optional bool isRegOrUnRegPush = 4;
optional bool isFirstPush = 5;
optional bool isUnsubAll = 6;
repeated Qot_Common.EC_KlineSource klineSource = 7;
optional Qot_Common.QotHeader header = 100;
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
- 証券構造は Security を参照
- 戻り値
message S2C
{
}
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
- インターフェース呼び出し結果、構造は 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;
// 現在の接続のすべてのイベントコントラクト購読を解除、isUnsubAll を true に設定
QotSubEventContract.C2S c2s = QotSubEventContract.C2S.newBuilder()
.setIsUnsubAll(true).build();
QotSubEventContract.Request req = QotSubEventContract.Request.newBuilder()
.setC2S(c2s).build();
int seqNo = qot.subEventContract(req);
System.out.println("Send SubEventContract(UnsubAll): " + seqNo);
}
@Override
public void onReply_SubEventContract(MMAPI_Conn client, int nSerialNo, QotSubEventContract.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
moomoo::u32_t SubEventContract(const Qot_SubEventContract::Request &stReq); virtual void OnReply_SubEventContract(moomoo::u32_t nSerialNo, const Qot_SubEventContract::Response &stRsp) = 0;
説明
現在の接続におけるすべてのイベントコントラクトのリアルタイム行情購読を解除します。C2S の isUnsubAll を true に設定することに対応し、この時他のパラメータは無視されます。
パラメータ
// イベントコントラクト購読/購読解除
message C2S
{
repeated Qot_Common.Security securityList = 1; // 契約標的(market+code)、購読の意味は汎用購読と一致
repeated int32 subTypeList = 2; // Qot_Common.SubType、汎用購読タイプを再利用
required bool isSubOrUnSub = 3; // true で購読 / false で解除
optional bool isRegOrUnRegPush = 4; // プッシュを登録/解除するか
optional bool isFirstPush = 5; // 登録後に既存データを初回プッシュするか、デフォルト true
optional bool isUnsubAll = 6; // true の時は他のパラメータを無視し、該当接続の全 EC 購読を解除
repeated Qot_Common.EC_KlineSource klineSource = 7; // K 線出所リスト(None/OrderBookYes)、KL_* 購読時に有効、未指定時はデフォルト [None]
optional Qot_Common.QotHeader header = 100; // 行情共通パラメータヘッダー
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
- 証券構造は Security を参照
- 戻り値
message S2C
{
}
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
- インターフェース呼び出し結果、構造は 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;
// リクエストを構築:現在の接続のすべてのイベントコントラクト購読を解除、isUnsubAll を true に設定
Qot_SubEventContract::Request req;
Qot_SubEventContract::C2S *c2s = req.mutable_c2s();
c2s->set_isunsuball(true);
m_SubEventContractSerialNo = m_pQotApi->SubEventContract(req);
cout << "Request SubEventContract(UnsubAll) SerialNo: " << m_SubEventContractSerialNo << endl;
}
virtual void OnReply_SubEventContract(moomoo::u32_t nSerialNo, const Qot_SubEventContract::Response &stRsp) {
if (nSerialNo == m_SubEventContractSerialNo)
{
cout << "OnReply_SubEventContract 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_SubEventContractSerialNo;
};
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
- Output
connect
Request SubEventContract(UnsubAll) SerialNo: 1
OnReply_SubEventContract SerialNo: 1
{
"retType": 0,
"retMsg": "",
"errCode": 0
}
2
3
4
5
6
7
8
SubEventContract(req);
説明
現在の接続におけるすべてのイベントコントラクトのリアルタイム行情購読を解除します。c2s の isUnsubAll を true に設定することに対応し、この時他のパラメータは無視されます。
パラメータ
message C2S
{
repeated Qot_Common.Security securityList = 1;
repeated int32 subTypeList = 2;
required bool isSubOrUnSub = 3;
optional bool isRegOrUnRegPush = 4;
optional bool isFirstPush = 5;
optional bool isUnsubAll = 6;
repeated Qot_Common.EC_KlineSource klineSource = 7;
optional Qot_Common.QotHeader header = 100;
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
- 証券構造は Security を参照
- 戻り値
message S2C
{
}
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
- インターフェース呼び出し結果、構造は RetType を参照
- Example
const mmWebsocket = require('moomoo-api');
let websocket = new mmWebsocket.WebsocketService();
websocket.onlogin = function() {
let req = {
proto: 'Qot_SubEventContract',
req: {
c2s: {
isUnsubAll: true
}
}
};
websocket.SubEventContract(req).then(res => {
console.log(JSON.stringify(res));
});
};
websocket.connect('127.0.0.1:11111');
setTimeout(() => websocket.stop(), 60000);
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18