# Unsubscribe All Event Contract
- Python
- Proto
- C#
- Java
- C++
- JavaScript
unsubscribe_all_event_contract()
Description
Unsubscribe from all event contract real-time market data on the current connection. After the call, order book, K-line, ticker and other pushes will no longer be received.
Parameters
This interface takes no parameters. It unsubscribes all event contract subscriptions on the current connection.
Return
Parameter Type Description ret RET_CODE Interface call result err_message None When ret == RET_OK, returns None str When ret != RET_OK, returns the error description Example
from futu import *
import time
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
# Subscribe to multiple event contracts
quote_ctx.subscribe_event_contract(
['EC.KXODIMATCH-26JUL140600INDENG-IND'], [SubType.TICKER]
)
quote_ctx.subscribe_event_contract(
['EC.KXNFLAFCCHAMP-27-CIN'], [SubType.K_DAY]
)
# You can only unsubscribe at least 1 minute after subscribing
time.sleep(62)
# Unsubscribe all subscriptions at once
ret, err = quote_ctx.unsubscribe_all_event_contract()
if ret == RET_OK:
print('All event contract subscriptions unsubscribed')
else:
print('Unsubscribe failed:', 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
All event contract subscriptions unsubscribed
# Qot_SubEventContract.proto
Description
Unsubscribe from all event contract real-time market data on the current connection. This corresponds to setting isUnsubAll to true in C2S, at which point other parameters are ignored.
Parameters
// Event contract subscribe/unsubscribe
message C2S
{
repeated Qot_Common.Security securityList = 1; // contract underlying (market+code), subscribe semantics match the common subscription
repeated int32 subTypeList = 2; // Qot_Common.SubType, reuses common subscription types
required bool isSubOrUnSub = 3; // true to subscribe / false to unsubscribe
optional bool isRegOrUnRegPush = 4; // whether to register/unregister push
optional bool isFirstPush = 5; // whether to push existing data first after registration, default true
optional bool isUnsubAll = 6; // when true, ignores other params and unsubscribes all EC subscriptions on the connection
repeated Qot_Common.EC_KlineSource klineSource = 7; // K-line source list (None/OrderBookYes), effective when subscribing KL_*; defaults to [None] if omitted
optional Qot_Common.QotHeader header = 100; // quote common header
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
- Return
message S2C
{
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType, return result
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
- Interface call result, see RetType
Protocol ID
3455
uint SubEventContract(SubEventContract.Request req); virtual void OnReply_SubEventContract(FTAPI_Conn client, uint nSerialNo, SubEventContract.Response rsp);
Description
Unsubscribe from all event contract real-time market data on the current connection. This corresponds to setting isUnsubAll to true in C2S, at which point other parameters are ignored.
Parameters
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 structure see Security
- Return
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
- Interface call result, see 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;
// Unsubscribe all event contract subscriptions on the current connection; set isUnsubAll to 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);
Description
Unsubscribe from all event contract real-time market data on the current connection. This corresponds to setting isUnsubAll to true in C2S, at which point other parameters are ignored.
Parameters
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 structure see Security
- Return
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
- Interface call result, see 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;
// Unsubscribe all event contract subscriptions on the current connection; set isUnsubAll to 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;
Description
Unsubscribe from all event contract real-time market data on the current connection. This corresponds to setting isUnsubAll to true in C2S, at which point other parameters are ignored.
Parameters
// Event contract subscribe/unsubscribe
message C2S
{
repeated Qot_Common.Security securityList = 1; // contract underlying (market+code), subscribe semantics match the common subscription
repeated int32 subTypeList = 2; // Qot_Common.SubType, reuses common subscription types
required bool isSubOrUnSub = 3; // true to subscribe / false to unsubscribe
optional bool isRegOrUnRegPush = 4; // whether to register/unregister push
optional bool isFirstPush = 5; // whether to push existing data first after registration, default true
optional bool isUnsubAll = 6; // when true, ignores other params and unsubscribes all EC subscriptions on the connection
repeated Qot_Common.EC_KlineSource klineSource = 7; // K-line source list (None/OrderBookYes), effective when subscribing KL_*; defaults to [None] if omitted
optional Qot_Common.QotHeader header = 100; // quote common header
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
- Security structure see Security
- Return
message S2C
{
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType, return result
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
- Interface call result, see 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;
// build request: unsubscribe all event contract subscriptions on the current connection; set isUnsubAll to 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;
// parse the inner structure and print it
// definitions of ProtoBufToBodyData and UTF8ToLocal see tool.h in Sample
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);
Description
Unsubscribe from all event contract real-time market data on the current connection. This corresponds to setting isUnsubAll to true in c2s, at which point other parameters are ignored.
Parameters
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 structure see Security
- Return
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
- Interface call result, see 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()
Description
Unsubscribe from all event contract real-time market data on the current connection. After the call, order book, K-line, ticker and other pushes will no longer be received.
Parameters
This interface takes no parameters. It unsubscribes all event contract subscriptions on the current connection.
Return
Parameter Type Description ret RET_CODE Interface call result err_message None When ret == RET_OK, returns None str When ret != RET_OK, returns the error description Example
from moomoo import *
import time
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
# Subscribe to multiple event contracts
quote_ctx.subscribe_event_contract(
['EC.KXODIMATCH-26JUL140600INDENG-IND'], [SubType.TICKER]
)
quote_ctx.subscribe_event_contract(
['EC.KXNFLAFCCHAMP-27-CIN'], [SubType.K_DAY]
)
# You can only unsubscribe at least 1 minute after subscribing
time.sleep(62)
# Unsubscribe all subscriptions at once
ret, err = quote_ctx.unsubscribe_all_event_contract()
if ret == RET_OK:
print('All event contract subscriptions unsubscribed')
else:
print('Unsubscribe failed:', 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
All event contract subscriptions unsubscribed
# Qot_SubEventContract.proto
Description
Unsubscribe from all event contract real-time market data on the current connection. This corresponds to setting isUnsubAll to true in C2S, at which point other parameters are ignored.
Parameters
// Event contract subscribe/unsubscribe
message C2S
{
repeated Qot_Common.Security securityList = 1; // contract underlying (market+code), subscribe semantics match the common subscription
repeated int32 subTypeList = 2; // Qot_Common.SubType, reuses common subscription types
required bool isSubOrUnSub = 3; // true to subscribe / false to unsubscribe
optional bool isRegOrUnRegPush = 4; // whether to register/unregister push
optional bool isFirstPush = 5; // whether to push existing data first after registration, default true
optional bool isUnsubAll = 6; // when true, ignores other params and unsubscribes all EC subscriptions on the connection
repeated Qot_Common.EC_KlineSource klineSource = 7; // K-line source list (None/OrderBookYes), effective when subscribing KL_*; defaults to [None] if omitted
optional Qot_Common.QotHeader header = 100; // quote common header
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
- Return
message S2C
{
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType, return result
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
- Interface call result, see RetType
Protocol ID
3455
uint SubEventContract(SubEventContract.Request req); virtual void OnReply_SubEventContract(MMAPI_Conn client, uint nSerialNo, SubEventContract.Response rsp);
Description
Unsubscribe from all event contract real-time market data on the current connection. This corresponds to setting isUnsubAll to true in C2S, at which point other parameters are ignored.
Parameters
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 structure see Security
- Return
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
- Interface call result, see 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;
// Unsubscribe all event contract subscriptions on the current connection; set isUnsubAll to 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);
Description
Unsubscribe from all event contract real-time market data on the current connection. This corresponds to setting isUnsubAll to true in C2S, at which point other parameters are ignored.
Parameters
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 structure see Security
- Return
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
- Interface call result, see 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;
// Unsubscribe all event contract subscriptions on the current connection; set isUnsubAll to 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;
Description
Unsubscribe from all event contract real-time market data on the current connection. This corresponds to setting isUnsubAll to true in C2S, at which point other parameters are ignored.
Parameters
// Event contract subscribe/unsubscribe
message C2S
{
repeated Qot_Common.Security securityList = 1; // contract underlying (market+code), subscribe semantics match the common subscription
repeated int32 subTypeList = 2; // Qot_Common.SubType, reuses common subscription types
required bool isSubOrUnSub = 3; // true to subscribe / false to unsubscribe
optional bool isRegOrUnRegPush = 4; // whether to register/unregister push
optional bool isFirstPush = 5; // whether to push existing data first after registration, default true
optional bool isUnsubAll = 6; // when true, ignores other params and unsubscribes all EC subscriptions on the connection
repeated Qot_Common.EC_KlineSource klineSource = 7; // K-line source list (None/OrderBookYes), effective when subscribing KL_*; defaults to [None] if omitted
optional Qot_Common.QotHeader header = 100; // quote common header
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
- Security structure see Security
- Return
message S2C
{
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType, return result
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
- Interface call result, see 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;
// build request: unsubscribe all event contract subscriptions on the current connection; set isUnsubAll to 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;
// parse the inner structure and print it
// definitions of ProtoBufToBodyData and UTF8ToLocal see tool.h in Sample
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);
Description
Unsubscribe from all event contract real-time market data on the current connection. This corresponds to setting isUnsubAll to true in c2s, at which point other parameters are ignored.
Parameters
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 structure see Security
- Return
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
- Interface call result, see 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