# Get Macro Indicator List
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_macro_indicator_list(region)
Description
Get macro indicator list. Returns the macro economic indicator categories and indicator information for the specified country/region, including indicator ID and name, for subsequent historical data queries.
Parameters
Parameter Type Description region MacroRegion Country/region (required) Return
Parameter Type Description ret RET_CODE API call result data pd.DataFrame When ret == RET_OK, returns data str When ret != RET_OK, returns error description - Data format:
Field Type Description category_name str Category name (e.g. "All"/"Employment"/"Inflation"/"Interest Rate") indicator_id int Macro indicator ID (for querying historical data) name str Indicator name
- Data format:
Example
from futu import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data = quote_ctx.get_macro_indicator_list(region=MacroRegion.US)
if ret == RET_OK:
print(data.head(2))
else:
print('error:', data)
quote_ctx.close()
2
3
4
5
6
7
8
9
10
11
- Output
category_name indicator_id name
0 物价 1003000003 美国生产者物价指数(PPI)同比
1 物价 1003000001 美国核心CPI同比
2
3
# Qot_GetMacroIndicatorList.proto
Description
Get macro indicator list. Returns the macro economic indicator categories and indicator information for the specified country/region, including indicator ID and name, for subsequent historical data queries.
Parameters
// Macro data country/region
enum MacroRegion {
MacroRegion_Unknown = 0; //Unknown
MacroRegion_HK = 1; //Hong Kong
MacroRegion_US = 2; //United States
MacroRegion_JP = 3; //Japan
MacroRegion_SG = 4; //Singapore
MacroRegion_AU = 5; //Australia
MacroRegion_CA = 6; //Canada
MacroRegion_MY = 7; //Malaysia
MacroRegion_CN = 8; //China (SH/SZ)
}
// Macro indicator info
message MacroIndicatorInfo {
required uint64 indicatorId = 1; //Macro indicator ID
optional string name = 2; //Indicator name
}
// Macro indicator category
message MacroIndicatorCategory {
required string categoryName = 1; //Category name (e.g. "All"/"Employment"/"Inflation"/"Interest Rate")
repeated MacroIndicatorInfo indicatorList = 2; //Macro indicator list under this category
}
message C2S {
required int32 region = 1; //MacroRegion, country/region
optional Qot_Common.QotHeader header = 100; //Quote common parameter header
}
message S2C {
repeated MacroIndicatorCategory indicatorList = 1; //Category indicator list
}
message Request {
required C2S c2s = 1;
}
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
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
Protocol ID
3402
uint GetMacroIndicatorList(Qot_GetMacroIndicatorList.Request req);
virtual void OnReply_GetMacroIndicatorList(FTAPI_Conn client, uint nSerialNo, Qot_GetMacroIndicatorList.Response rsp);
Description
Get macro indicator list. Returns the macro economic indicator categories and indicator information for the specified country/region, including indicator ID and name, for subsequent historical data queries.
Parameters
// Macro data country/region
enum MacroRegion {
MacroRegion_Unknown = 0; //Unknown
MacroRegion_HK = 1; //Hong Kong
MacroRegion_US = 2; //United States
MacroRegion_JP = 3; //Japan
MacroRegion_SG = 4; //Singapore
MacroRegion_AU = 5; //Australia
MacroRegion_CA = 6; //Canada
MacroRegion_MY = 7; //Malaysia
MacroRegion_CN = 8; //China (SH/SZ)
}
// Macro indicator info
message MacroIndicatorInfo {
required uint64 indicatorId = 1; //Macro indicator ID
optional string name = 2; //Indicator name
}
// Macro indicator category
message MacroIndicatorCategory {
required string categoryName = 1; //Category name (e.g. "All"/"Employment"/"Inflation"/"Interest Rate")
repeated MacroIndicatorInfo indicatorList = 2; //Macro indicator list under this category
}
message C2S {
required int32 region = 1; //MacroRegion, country/region
optional Qot_Common.QotHeader header = 100; //Quote common parameter header
}
message S2C {
repeated MacroIndicatorCategory indicatorList = 1; //Category indicator list
}
message Request {
required C2S c2s = 1;
}
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
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
- For interface result, refer to RetType
Protocol ID
3402
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)
{
Console.Write("Qot onInitConnect: ret={0} desc={1} connID={2}
", errCode, desc, client.GetConnectID());
if (errCode != 0)
return;
QotGetMacroIndicatorList.C2S c2s = QotGetMacroIndicatorList.C2S.CreateBuilder()
.SetRegion(1)
.Build();
QotGetMacroIndicatorList.Request req = QotGetMacroIndicatorList.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetMacroIndicatorList(req);
Console.Write("Send QotGetMacroIndicatorList: {0}
", seqNo);
}
public void OnDisconnect(FTAPI_Conn client, long errCode) {
Console.Write("Qot onDisConnect: {0}
", errCode);
}
public void OnReply_GetMacroIndicatorList(FTAPI_Conn client, uint nSerialNo, QotGetMacroIndicatorList.Response rsp)
{
Console.Write("Reply: QotGetMacroIndicatorList: {0}
", nSerialNo);
if (rsp.RetType == 0 && rsp.HasS2C)
Console.Write("{0}
", rsp.ToString());
}
public static void Main(String[] args) {
FTAPI.Init();
Program program = new Program();
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
- Output
Send QotGetMacroIndicatorList: 3
Reply: QotGetMacroIndicatorList: 3
GetMacroIndicatorList: errCode 0, retMsg , retType 0
{
"indicatorList": [
{
"categoryName": "物价",
"indicatorList": [
{ "indicatorId": "1003000003", "name": "美国生产者物价指数(PPI)同比" },
{ "indicatorId": "1003000001", "name": "美国核心CPI同比" },
{ "indicatorId": "1003000002", "name": "美国CPI同比" }
]
}
]
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
int getMacroIndicatorList(Qot_GetMacroIndicatorList.Request req);
onReply_GetMacroIndicatorList(FTAPI_Conn client, int nSerialNo, Qot_GetMacroIndicatorList.Response rsp)
Description
Get macro indicator list. Returns the macro economic indicator categories and indicator information for the specified country/region, including indicator ID and name, for subsequent historical data queries.
Parameters
// Macro data country/region
enum MacroRegion {
MacroRegion_Unknown = 0; //Unknown
MacroRegion_HK = 1; //Hong Kong
MacroRegion_US = 2; //United States
MacroRegion_JP = 3; //Japan
MacroRegion_SG = 4; //Singapore
MacroRegion_AU = 5; //Australia
MacroRegion_CA = 6; //Canada
MacroRegion_MY = 7; //Malaysia
MacroRegion_CN = 8; //China (SH/SZ)
}
// Macro indicator info
message MacroIndicatorInfo {
required uint64 indicatorId = 1; //Macro indicator ID
optional string name = 2; //Indicator name
}
// Macro indicator category
message MacroIndicatorCategory {
required string categoryName = 1; //Category name (e.g. "All"/"Employment"/"Inflation"/"Interest Rate")
repeated MacroIndicatorInfo indicatorList = 2; //Macro indicator list under this category
}
message C2S {
required int32 region = 1; //MacroRegion, country/region
optional Qot_Common.QotHeader header = 100; //Quote common parameter header
}
message S2C {
repeated MacroIndicatorCategory indicatorList = 1; //Category indicator list
}
message Request {
required C2S c2s = 1;
}
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
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
- For interface result, refer to RetType
Protocol ID
3402
Example
public class QotDemo implements FTSPI_Qot, FTSPI_Conn {
FTAPI_Conn_Qot qot = new FTAPI_Conn_Qot();
public QotDemo() {
qot.setClientInfo("javaclient", 1); //设置客户端信息
qot.setConnSpi(this); //设置连接回调
qot.setQotSpi(this); //设置行情回调
}
public void start() {
qot.initConnect("127.0.0.1", (short)11111, false);
}
@Override
public void onInitConnect(FTAPI_Conn client, long errCode, String desc)
{
System.out.printf("Qot onInitConnect: ret=%d desc=%s connID=%d
", errCode, desc, client.getConnectID());
if (errCode != 0)
return;
QotGetMacroIndicatorList.C2S c2s = QotGetMacroIndicatorList.C2S.newBuilder()
.setRegion(1)
.build();
QotGetMacroIndicatorList.Request req = QotGetMacroIndicatorList.Request.newBuilder().setC2S(c2s).build();
int seqNo = qot.getMacroIndicatorList(req);
System.out.printf("Send QotGetMacroIndicatorList: %d
", seqNo);
}
@Override
public void onDisconnect(FTAPI_Conn client, long errCode) {
System.out.printf("Qot onDisConnect: %d
", errCode);
}
@Override
public void onReply_GetMacroIndicatorList(FTAPI_Conn client, int nSerialNo, QotGetMacroIndicatorList.Response rsp) {
if (rsp.getRetType() != 0) {
System.out.printf("QotGetMacroIndicatorList failed: %s
", rsp.getRetMsg());
} else {
try {
String json = JsonFormat.printer().print(rsp);
System.out.printf("Receive QotGetMacroIndicatorList: %s
", json);
} catch (InvalidProtocolBufferException e) {
e.printStackTrace();
}
}
}
public static void main(String[] args) {
FTAPI.init();
QotDemo qot = new QotDemo();
qot.start();
while (true) {
try {
Thread.sleep(1000 * 600);
} catch (InterruptedException exc) {
}
}
}
}
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
- Output
Send QotGetMacroIndicatorList: 3
Receive QotGetMacroIndicatorList: {
"indicatorList": [
{
"categoryName": "物价",
"indicatorList": [
{ "indicatorId": "1003000003", "name": "美国生产者物价指数(PPI)同比" },
{ "indicatorId": "1003000001", "name": "美国核心CPI同比" },
{ "indicatorId": "1003000002", "name": "美国CPI同比" }
]
}
]
}
2
3
4
5
6
7
8
9
10
11
12
13
Futu::u32_t GetMacroIndicatorList(const Qot_GetMacroIndicatorList::Request &stReq);
virtual void OnReply_GetMacroIndicatorList(Futu::u32_t nSerialNo, const Qot_GetMacroIndicatorList::Response &stRsp) = 0;
Description
Protocol request and response definition
Parameters
// Macro data country/region
enum MacroRegion {
MacroRegion_Unknown = 0; //Unknown
MacroRegion_HK = 1; //Hong Kong
MacroRegion_US = 2; //United States
MacroRegion_JP = 3; //Japan
MacroRegion_SG = 4; //Singapore
MacroRegion_AU = 5; //Australia
MacroRegion_CA = 6; //Canada
MacroRegion_MY = 7; //Malaysia
MacroRegion_CN = 8; //China (SH/SZ)
}
// Macro indicator info
message MacroIndicatorInfo {
required uint64 indicatorId = 1; //Macro indicator ID
optional string name = 2; //Indicator name
}
// Macro indicator category
message MacroIndicatorCategory {
required string categoryName = 1; //Category name (e.g. "All"/"Employment"/"Inflation"/"Interest Rate")
repeated MacroIndicatorInfo indicatorList = 2; //Macro indicator list under this category
}
message C2S {
required int32 region = 1; //MacroRegion, country/region
optional Qot_Common.QotHeader header = 100; //Quote common parameter header
}
message S2C {
repeated MacroIndicatorCategory indicatorList = 1; //Category indicator list
}
message Request {
required C2S c2s = 1;
}
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
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
- For interface result, refer to RetType
Protocol ID
3402
Example
class Program : public FTSPI_Qot, 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) {
Qot_GetMacroIndicatorList::Request req;
Qot_GetMacroIndicatorList::C2S *c2s = req.mutable_c2s();
c2s->set_region(2); // MacroRegion_US
m_GetMacroIndicatorListSerialNo = m_pQotApi->GetMacroIndicatorList(req);
}
virtual void OnReply_GetMacroIndicatorList(Futu::u32_t nSerialNo, const Qot_GetMacroIndicatorList::Response &stRsp) {
if (nSerialNo != m_GetMacroIndicatorListSerialNo) return;
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
FTAPI_Qot *m_pQotApi;
Futu::u32_t m_GetMacroIndicatorListSerialNo = 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
- Output
{
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"indicatorList": [
{
"categoryName": "Inflation",
"indicatorCount": 5
}
]
}
}
2
3
4
5
6
7
8
9
10
11
12
13
getMacroIndicatorList(qotGetMacroIndicatorList)
Description
Get macro indicator list. Returns the macro economic indicator categories and indicator information for the specified country/region, including indicator ID and name, for subsequent historical data queries.
Parameters
// Macro data country/region
enum MacroRegion {
MacroRegion_Unknown = 0; //Unknown
MacroRegion_HK = 1; //Hong Kong
MacroRegion_US = 2; //United States
MacroRegion_JP = 3; //Japan
MacroRegion_SG = 4; //Singapore
MacroRegion_AU = 5; //Australia
MacroRegion_CA = 6; //Canada
MacroRegion_MY = 7; //Malaysia
MacroRegion_CN = 8; //China (SH/SZ)
}
// Macro indicator info
message MacroIndicatorInfo {
required uint64 indicatorId = 1; //Macro indicator ID
optional string name = 2; //Indicator name
}
// Macro indicator category
message MacroIndicatorCategory {
required string categoryName = 1; //Category name (e.g. "All"/"Employment"/"Inflation"/"Interest Rate")
repeated MacroIndicatorInfo indicatorList = 2; //Macro indicator list under this category
}
message C2S {
required int32 region = 1; //MacroRegion, country/region
optional Qot_Common.QotHeader header = 100; //Quote common parameter header
}
message S2C {
repeated MacroIndicatorCategory indicatorList = 1; //Category indicator list
}
message Request {
required C2S c2s = 1;
}
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
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
- For interface result, refer to RetType
Protocol ID
3402
Example
import ftWebsocket from "futu-api";
import { Common, Qot_Common } from "futu-api/proto";
import beautify from "js-beautify";
function QotGetMacroIndicatorList(){
const { RetType } = Common
let [addr, port, enable_ssl, key] = ["127.0.0.1", 11111, false, "xxxxxx"];
let websocket = new ftWebsocket();
websocket.onlogin = (ret, msg)=>{
if (ret) {
const req = {
c2s: { region: 1 },
};
websocket.GetMacroIndicatorList(req)
.then((res)=>{
let { errCode, retMsg, retType, s2c } = res
console.log("GetMacroIndicatorList: errCode %d, retMsg %s, retType %d", errCode, retMsg, retType);
if(retType == RetType.RetType_Succeed){
let data = beautify(JSON.stringify(s2c), { indent_size: 2, space_in_empty_paren: true });
console.log(data);
}
})
.catch((error)=>{ console.log("error:", error); });
} else {
console.log("start error", msg);
}
};
websocket.start(addr, port, enable_ssl, key);
setTimeout(()=>{ websocket.stop(); process.exit(); }, 5000);
}
QotGetMacroIndicatorList()
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
- Output
GetMacroIndicatorList: errCode 0, retMsg , retType 0
{
"indicatorList": [
{
"categoryName": "物价",
"indicatorList": [
{ "indicatorId": "1003000003", "name": "美国生产者物价指数(PPI)同比" },
{ "indicatorId": "1003000001", "name": "美国核心CPI同比" },
{ "indicatorId": "1003000002", "name": "美国CPI同比" }
]
}
]
}
2
3
4
5
6
7
8
9
10
11
12
13
API Limits
- Maximum 60 requests within 30 seconds
- Only the first page of paginated requests counts towards rate limiting
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_macro_indicator_list(region)
Description
Get macro indicator list. Returns the macro economic indicator categories and indicator information for the specified country/region, including indicator ID and name, for subsequent historical data queries.
Parameters
Parameter Type Description region MacroRegion Country/region (required) Return
Parameter Type Description ret RET_CODE API call result data pd.DataFrame When ret == RET_OK, returns data str When ret != RET_OK, returns error description - Data format:
Field Type Description category_name str Category name (e.g. "All"/"Employment"/"Inflation"/"Interest Rate") indicator_id int Macro indicator ID (for querying historical data) name str Indicator name
- Data format:
Example
from futu import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data = quote_ctx.get_macro_indicator_list(region=MacroRegion.US)
if ret == RET_OK:
print(data.head(2))
else:
print('error:', data)
quote_ctx.close()
2
3
4
5
6
7
8
9
10
11
- Output
category_name indicator_id name
0 物价 1003000003 美国生产者物价指数(PPI)同比
1 物价 1003000001 美国核心CPI同比
2
3
# Qot_GetMacroIndicatorList.proto
Description
Get macro indicator list. Returns the macro economic indicator categories and indicator information for the specified country/region, including indicator ID and name, for subsequent historical data queries.
Parameters
// Macro data country/region
enum MacroRegion {
MacroRegion_Unknown = 0; //Unknown
MacroRegion_HK = 1; //Hong Kong
MacroRegion_US = 2; //United States
MacroRegion_JP = 3; //Japan
MacroRegion_SG = 4; //Singapore
MacroRegion_AU = 5; //Australia
MacroRegion_CA = 6; //Canada
MacroRegion_MY = 7; //Malaysia
MacroRegion_CN = 8; //China (SH/SZ)
}
// Macro indicator info
message MacroIndicatorInfo {
required uint64 indicatorId = 1; //Macro indicator ID
optional string name = 2; //Indicator name
}
// Macro indicator category
message MacroIndicatorCategory {
required string categoryName = 1; //Category name (e.g. "All"/"Employment"/"Inflation"/"Interest Rate")
repeated MacroIndicatorInfo indicatorList = 2; //Macro indicator list under this category
}
message C2S {
required int32 region = 1; //MacroRegion, country/region
optional Qot_Common.QotHeader header = 100; //Quote common parameter header
}
message S2C {
repeated MacroIndicatorCategory indicatorList = 1; //Category indicator list
}
message Request {
required C2S c2s = 1;
}
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
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
Protocol ID
3402
uint GetMacroIndicatorList(Qot_GetMacroIndicatorList.Request req);
virtual void OnReply_GetMacroIndicatorList(FTAPI_Conn client, uint nSerialNo, Qot_GetMacroIndicatorList.Response rsp);
Description
Get macro indicator list. Returns the macro economic indicator categories and indicator information for the specified country/region, including indicator ID and name, for subsequent historical data queries.
Parameters
// Macro data country/region
enum MacroRegion {
MacroRegion_Unknown = 0; //Unknown
MacroRegion_HK = 1; //Hong Kong
MacroRegion_US = 2; //United States
MacroRegion_JP = 3; //Japan
MacroRegion_SG = 4; //Singapore
MacroRegion_AU = 5; //Australia
MacroRegion_CA = 6; //Canada
MacroRegion_MY = 7; //Malaysia
MacroRegion_CN = 8; //China (SH/SZ)
}
// Macro indicator info
message MacroIndicatorInfo {
required uint64 indicatorId = 1; //Macro indicator ID
optional string name = 2; //Indicator name
}
// Macro indicator category
message MacroIndicatorCategory {
required string categoryName = 1; //Category name (e.g. "All"/"Employment"/"Inflation"/"Interest Rate")
repeated MacroIndicatorInfo indicatorList = 2; //Macro indicator list under this category
}
message C2S {
required int32 region = 1; //MacroRegion, country/region
optional Qot_Common.QotHeader header = 100; //Quote common parameter header
}
message S2C {
repeated MacroIndicatorCategory indicatorList = 1; //Category indicator list
}
message Request {
required C2S c2s = 1;
}
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
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
- For interface result, refer to RetType
Protocol ID
3402
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)
{
Console.Write("Qot onInitConnect: ret={0} desc={1} connID={2}
", errCode, desc, client.GetConnectID());
if (errCode != 0)
return;
QotGetMacroIndicatorList.C2S c2s = QotGetMacroIndicatorList.C2S.CreateBuilder()
.SetRegion(1)
.Build();
QotGetMacroIndicatorList.Request req = QotGetMacroIndicatorList.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetMacroIndicatorList(req);
Console.Write("Send QotGetMacroIndicatorList: {0}
", seqNo);
}
public void OnDisconnect(MMAPI_Conn client, long errCode) {
Console.Write("Qot onDisConnect: {0}
", errCode);
}
public void OnReply_GetMacroIndicatorList(MMAPI_Conn client, uint nSerialNo, QotGetMacroIndicatorList.Response rsp)
{
Console.Write("Reply: QotGetMacroIndicatorList: {0}
", nSerialNo);
if (rsp.RetType == 0 && rsp.HasS2C)
Console.Write("{0}
", rsp.ToString());
}
public static void Main(String[] args) {
MMAPI.Init();
Program program = new Program();
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
- Output
Send QotGetMacroIndicatorList: 3
Reply: QotGetMacroIndicatorList: 3
GetMacroIndicatorList: errCode 0, retMsg , retType 0
{
"indicatorList": [
{
"categoryName": "物价",
"indicatorList": [
{ "indicatorId": "1003000003", "name": "美国生产者物价指数(PPI)同比" },
{ "indicatorId": "1003000001", "name": "美国核心CPI同比" },
{ "indicatorId": "1003000002", "name": "美国CPI同比" }
]
}
]
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
int getMacroIndicatorList(Qot_GetMacroIndicatorList.Request req);
onReply_GetMacroIndicatorList(FTAPI_Conn client, int nSerialNo, Qot_GetMacroIndicatorList.Response rsp)
Description
Get macro indicator list. Returns the macro economic indicator categories and indicator information for the specified country/region, including indicator ID and name, for subsequent historical data queries.
Parameters
// Macro data country/region
enum MacroRegion {
MacroRegion_Unknown = 0; //Unknown
MacroRegion_HK = 1; //Hong Kong
MacroRegion_US = 2; //United States
MacroRegion_JP = 3; //Japan
MacroRegion_SG = 4; //Singapore
MacroRegion_AU = 5; //Australia
MacroRegion_CA = 6; //Canada
MacroRegion_MY = 7; //Malaysia
MacroRegion_CN = 8; //China (SH/SZ)
}
// Macro indicator info
message MacroIndicatorInfo {
required uint64 indicatorId = 1; //Macro indicator ID
optional string name = 2; //Indicator name
}
// Macro indicator category
message MacroIndicatorCategory {
required string categoryName = 1; //Category name (e.g. "All"/"Employment"/"Inflation"/"Interest Rate")
repeated MacroIndicatorInfo indicatorList = 2; //Macro indicator list under this category
}
message C2S {
required int32 region = 1; //MacroRegion, country/region
optional Qot_Common.QotHeader header = 100; //Quote common parameter header
}
message S2C {
repeated MacroIndicatorCategory indicatorList = 1; //Category indicator list
}
message Request {
required C2S c2s = 1;
}
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
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
- For interface result, refer to RetType
Protocol ID
3402
Example
public class QotDemo implements MMSPI_Qot, MMSPI_Conn {
MMAPI_Conn_Qot qot = new MMAPI_Conn_Qot();
public QotDemo() {
qot.setClientInfo("javaclient", 1); //设置客户端信息
qot.setConnSpi(this); //设置连接回调
qot.setQotSpi(this); //设置行情回调
}
public void start() {
qot.initConnect("127.0.0.1", (short)11111, false);
}
@Override
public void onInitConnect(MMAPI_Conn client, long errCode, String desc)
{
System.out.printf("Qot onInitConnect: ret=%d desc=%s connID=%d
", errCode, desc, client.getConnectID());
if (errCode != 0)
return;
QotGetMacroIndicatorList.C2S c2s = QotGetMacroIndicatorList.C2S.newBuilder()
.setRegion(1)
.build();
QotGetMacroIndicatorList.Request req = QotGetMacroIndicatorList.Request.newBuilder().setC2S(c2s).build();
int seqNo = qot.getMacroIndicatorList(req);
System.out.printf("Send QotGetMacroIndicatorList: %d
", seqNo);
}
@Override
public void onDisconnect(MMAPI_Conn client, long errCode) {
System.out.printf("Qot onDisConnect: %d
", errCode);
}
@Override
public void onReply_GetMacroIndicatorList(MMAPI_Conn client, int nSerialNo, QotGetMacroIndicatorList.Response rsp) {
if (rsp.getRetType() != 0) {
System.out.printf("QotGetMacroIndicatorList failed: %s
", rsp.getRetMsg());
} else {
try {
String json = JsonFormat.printer().print(rsp);
System.out.printf("Receive QotGetMacroIndicatorList: %s
", json);
} catch (InvalidProtocolBufferException e) {
e.printStackTrace();
}
}
}
public static void main(String[] args) {
MMAPI.init();
QotDemo qot = new QotDemo();
qot.start();
while (true) {
try {
Thread.sleep(1000 * 600);
} catch (InterruptedException exc) {
}
}
}
}
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
- Output
Send QotGetMacroIndicatorList: 3
Receive QotGetMacroIndicatorList: {
"indicatorList": [
{
"categoryName": "物价",
"indicatorList": [
{ "indicatorId": "1003000003", "name": "美国生产者物价指数(PPI)同比" },
{ "indicatorId": "1003000001", "name": "美国核心CPI同比" },
{ "indicatorId": "1003000002", "name": "美国CPI同比" }
]
}
]
}
2
3
4
5
6
7
8
9
10
11
12
13
moomoo::u32_t GetMacroIndicatorList(const Qot_GetMacroIndicatorList::Request &stReq);
virtual void OnReply_GetMacroIndicatorList(moomoo::u32_t nSerialNo, const Qot_GetMacroIndicatorList::Response &stRsp) = 0;
Description
Protocol request and response definition
Parameters
// Macro data country/region
enum MacroRegion {
MacroRegion_Unknown = 0; //Unknown
MacroRegion_HK = 1; //Hong Kong
MacroRegion_US = 2; //United States
MacroRegion_JP = 3; //Japan
MacroRegion_SG = 4; //Singapore
MacroRegion_AU = 5; //Australia
MacroRegion_CA = 6; //Canada
MacroRegion_MY = 7; //Malaysia
MacroRegion_CN = 8; //China (SH/SZ)
}
// Macro indicator info
message MacroIndicatorInfo {
required uint64 indicatorId = 1; //Macro indicator ID
optional string name = 2; //Indicator name
}
// Macro indicator category
message MacroIndicatorCategory {
required string categoryName = 1; //Category name (e.g. "All"/"Employment"/"Inflation"/"Interest Rate")
repeated MacroIndicatorInfo indicatorList = 2; //Macro indicator list under this category
}
message C2S {
required int32 region = 1; //MacroRegion, country/region
optional Qot_Common.QotHeader header = 100; //Quote common parameter header
}
message S2C {
repeated MacroIndicatorCategory indicatorList = 1; //Category indicator list
}
message Request {
required C2S c2s = 1;
}
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
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
- For interface result, refer to RetType
Protocol ID
3402
Example
class Program : public MMSPI_Qot, 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) {
Qot_GetMacroIndicatorList::Request req;
Qot_GetMacroIndicatorList::C2S *c2s = req.mutable_c2s();
c2s->set_region(2); // MacroRegion_US
m_GetMacroIndicatorListSerialNo = m_pQotApi->GetMacroIndicatorList(req);
}
virtual void OnReply_GetMacroIndicatorList(moomoo::u32_t nSerialNo, const Qot_GetMacroIndicatorList::Response &stRsp) {
if (nSerialNo != m_GetMacroIndicatorListSerialNo) return;
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
MMAPI_Qot *m_pQotApi;
moomoo::u32_t m_GetMacroIndicatorListSerialNo = 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
- Output
{
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"indicatorList": [
{
"categoryName": "Inflation",
"indicatorCount": 5
}
]
}
}
2
3
4
5
6
7
8
9
10
11
12
13
getMacroIndicatorList(qotGetMacroIndicatorList)
Description
Get macro indicator list. Returns the macro economic indicator categories and indicator information for the specified country/region, including indicator ID and name, for subsequent historical data queries.
Parameters
// Macro data country/region
enum MacroRegion {
MacroRegion_Unknown = 0; //Unknown
MacroRegion_HK = 1; //Hong Kong
MacroRegion_US = 2; //United States
MacroRegion_JP = 3; //Japan
MacroRegion_SG = 4; //Singapore
MacroRegion_AU = 5; //Australia
MacroRegion_CA = 6; //Canada
MacroRegion_MY = 7; //Malaysia
MacroRegion_CN = 8; //China (SH/SZ)
}
// Macro indicator info
message MacroIndicatorInfo {
required uint64 indicatorId = 1; //Macro indicator ID
optional string name = 2; //Indicator name
}
// Macro indicator category
message MacroIndicatorCategory {
required string categoryName = 1; //Category name (e.g. "All"/"Employment"/"Inflation"/"Interest Rate")
repeated MacroIndicatorInfo indicatorList = 2; //Macro indicator list under this category
}
message C2S {
required int32 region = 1; //MacroRegion, country/region
optional Qot_Common.QotHeader header = 100; //Quote common parameter header
}
message S2C {
repeated MacroIndicatorCategory indicatorList = 1; //Category indicator list
}
message Request {
required C2S c2s = 1;
}
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
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
- For interface result, refer to RetType
Protocol ID
3402
Example
import mmWebsocket from "moomoo-api";
import { Common, Qot_Common } from "moomoo-api/proto";
import beautify from "js-beautify";
function QotGetMacroIndicatorList(){
const { RetType } = Common
let [addr, port, enable_ssl, key] = ["127.0.0.1", 11111, false, "xxxxxx"];
let websocket = new mmWebsocket();
websocket.onlogin = (ret, msg)=>{
if (ret) {
const req = {
c2s: { region: 1 },
};
websocket.GetMacroIndicatorList(req)
.then((res)=>{
let { errCode, retMsg, retType, s2c } = res
console.log("GetMacroIndicatorList: errCode %d, retMsg %s, retType %d", errCode, retMsg, retType);
if(retType == RetType.RetType_Succeed){
let data = beautify(JSON.stringify(s2c), { indent_size: 2, space_in_empty_paren: true });
console.log(data);
}
})
.catch((error)=>{ console.log("error:", error); });
} else {
console.log("start error", msg);
}
};
websocket.start(addr, port, enable_ssl, key);
setTimeout(()=>{ websocket.stop(); process.exit(); }, 5000);
}
QotGetMacroIndicatorList()
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
- Output
GetMacroIndicatorList: errCode 0, retMsg , retType 0
{
"indicatorList": [
{
"categoryName": "物价",
"indicatorList": [
{ "indicatorId": "1003000003", "name": "美国生产者物价指数(PPI)同比" },
{ "indicatorId": "1003000001", "name": "美国核心CPI同比" },
{ "indicatorId": "1003000002", "name": "美国CPI同比" }
]
}
]
}
2
3
4
5
6
7
8
9
10
11
12
13
API Limits
- Maximum 60 requests within 30 seconds
- Only the first page of paginated requests counts towards rate limiting