# 獲取產業鏈列表
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_industrial_chain_list(market, keyword=None, count=None, page=None)
介紹
獲取產業鏈列表,返回指定市場的產業鏈信息(含產業鏈類型、市值、成分股數量等),支持關鍵字搜索和遊標翻頁。
參數
參數 類型 說明 market Market 市場類型(必填) keyword str 搜索關鍵字 count int 返回數量 [1, 50],默認 20 page str 翻頁遊標 返回
參數 類型 說明 ret RET_CODE 接口調用結果 data pd.DataFrame 當 ret == RET_OK,返回數據 str 當 ret != RET_OK,返回錯誤描述 - 數據格式如下:
字段 類型 說明 chain_id int 產業鏈 ID chain_type str 產業鏈類型("CHAIN"/"PARALLEL"/"UP_MID_DOWN") name str 產業鏈名稱 detail str 詳情描述 market_cap float 市值 stocks_num int 成分股數量 relation_security_list list 相關股票代碼列表 "CHAIN" 串聯型 "PARALLEL" 並列型 "UP_MID_DOWN" 上中下游型
- 數據格式如下:
Example
from futu import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data, next_page, all_count = quote_ctx.get_industrial_chain_list(market=Market.US, count=2)
if ret == RET_OK:
print(f'總數據量: {all_count}')
print(data)
else:
print('error:', data)
quote_ctx.close()
2
3
4
5
6
7
8
9
10
11
12
- Output
總數據量: 70
chain_id chain_type name detail market_cap stocks_num relation_security_list
0 9610020 UP_MID_DOWN AI AIGC(Artificial Intelligence Generated Content... 4.801784e+13 329 [US.NVDA, US.AAPL]
1 9610085 UP_MID_DOWN 商業航天 2.590359e+12 155 [US.GE, US.RTX]
2
3
4
# Qot_GetIndustrialChainList.proto
介紹
獲取產業鏈列表,返回指定市場的產業鏈信息(含產業鏈類型、市值、成分股數量等),支持關鍵字搜索和遊標翻頁。
參數
// 產業鏈類型
enum IndustrialChainType {
IndustrialChainType_Chain = 1; // 串聯型
IndustrialChainType_Parallel = 2; // 並列型
IndustrialChainType_UpMidDown = 3; // 上中下游型
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket
optional string keyword = 2; // 搜索關鍵字(可選)
optional int32 count = 3; // 條數 [1,50], 默認20
optional string page = 4; // 翻頁遊標, 首次不傳
}
message IndustrialChainInfo {
optional int64 chainId = 1; // 產業鏈ID
optional int32 chainType = 2; // IndustrialChainType
optional string name = 3; // 名稱
optional string detail = 4; // 詳情描述
optional double marketCap = 5; // 市值
optional int64 stocksNum = 6; // 成分股數量
repeated Qot_Common.Security relationSecurityList = 7; // 相關股票
}
message S2C {
repeated IndustrialChainInfo dataList = 1;
optional int32 allCount = 2;
optional string nextPage = 3;
}
message Request {
required C2S c2s = 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
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
協議 ID
3427
uint GetIndustrialChainList(Qot_GetIndustrialChainList.Request req);
virtual void OnReply_GetIndustrialChainList(FTAPI_Conn client, uint nSerialNo, Qot_GetIndustrialChainList.Response rsp);
介紹
獲取產業鏈列表,返回指定市場的產業鏈信息(含產業鏈類型、市值、成分股數量等),支持關鍵字搜索和遊標翻頁。
參數
// 產業鏈類型
enum IndustrialChainType {
IndustrialChainType_Chain = 1; // 串聯型
IndustrialChainType_Parallel = 2; // 並列型
IndustrialChainType_UpMidDown = 3; // 上中下游型
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket
optional string keyword = 2; // 搜索關鍵字(可選)
optional int32 count = 3; // 條數 [1,50], 默認20
optional string page = 4; // 翻頁遊標, 首次不傳
}
message IndustrialChainInfo {
optional int64 chainId = 1; // 產業鏈ID
optional int32 chainType = 2; // IndustrialChainType
optional string name = 3; // 名稱
optional string detail = 4; // 詳情描述
optional double marketCap = 5; // 市值
optional int64 stocksNum = 6; // 成分股數量
repeated Qot_Common.Security relationSecurityList = 7; // 相關股票
}
message S2C {
repeated IndustrialChainInfo dataList = 1;
optional int32 allCount = 2;
optional string nextPage = 3;
}
message Request {
required C2S c2s = 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
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
- 接口調用結果,結構參見 RetType
協議 ID
3427
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;
QotGetIndustrialChainList.C2S c2s = QotGetIndustrialChainList.C2S.CreateBuilder()
.SetMarket(11)
.SetCount(3)
.Build();
QotGetIndustrialChainList.Request req = QotGetIndustrialChainList.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetIndustrialChainList(req);
Console.Write("Send QotGetIndustrialChainList: {0}
", seqNo);
}
public void OnDisconnect(FTAPI_Conn client, long errCode) {
Console.Write("Qot onDisConnect: {0}
", errCode);
}
public void OnReply_GetIndustrialChainList(FTAPI_Conn client, uint nSerialNo, QotGetIndustrialChainList.Response rsp)
{
Console.Write("Reply: QotGetIndustrialChainList: {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
53
- Output
Send QotGetIndustrialChainList: 3
Reply: QotGetIndustrialChainList: 3
GetIndustrialChainList: errCode 0, retMsg , retType 0
{
"allCount": 70,
"dataList": [
{ "chainId": "9610020", "name": "AI", "chainType": 1, "stocksNum": 329 },
{ "chainId": "9610085", "name": "商業航天", "chainType": 1, "stocksNum": 155 },
{ "chainId": "9610033", "name": "半導體", "chainType": 1, "stocksNum": 256 }
]
}
2
3
4
5
6
7
8
9
10
11
int getIndustrialChainList(Qot_GetIndustrialChainList.Request req);
onReply_GetIndustrialChainList(FTAPI_Conn client, int nSerialNo, Qot_GetIndustrialChainList.Response rsp)
介紹
獲取產業鏈列表,返回指定市場的產業鏈信息(含產業鏈類型、市值、成分股數量等),支持關鍵字搜索和遊標翻頁。
參數
// 產業鏈類型
enum IndustrialChainType {
IndustrialChainType_Chain = 1; // 串聯型
IndustrialChainType_Parallel = 2; // 並列型
IndustrialChainType_UpMidDown = 3; // 上中下游型
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket
optional string keyword = 2; // 搜索關鍵字(可選)
optional int32 count = 3; // 條數 [1,50], 默認20
optional string page = 4; // 翻頁遊標, 首次不傳
}
message IndustrialChainInfo {
optional int64 chainId = 1; // 產業鏈ID
optional int32 chainType = 2; // IndustrialChainType
optional string name = 3; // 名稱
optional string detail = 4; // 詳情描述
optional double marketCap = 5; // 市值
optional int64 stocksNum = 6; // 成分股數量
repeated Qot_Common.Security relationSecurityList = 7; // 相關股票
}
message S2C {
repeated IndustrialChainInfo dataList = 1;
optional int32 allCount = 2;
optional string nextPage = 3;
}
message Request {
required C2S c2s = 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
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
- 接口調用結果,結構參見 RetType
協議 ID
3427
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;
QotGetIndustrialChainList.C2S c2s = QotGetIndustrialChainList.C2S.newBuilder()
.setMarket(11)
.setCount(3)
.build();
QotGetIndustrialChainList.Request req = QotGetIndustrialChainList.Request.newBuilder().setC2S(c2s).build();
int seqNo = qot.getIndustrialChainList(req);
System.out.printf("Send QotGetIndustrialChainList: %d
", seqNo);
}
@Override
public void onDisconnect(FTAPI_Conn client, long errCode) {
System.out.printf("Qot onDisConnect: %d
", errCode);
}
@Override
public void onReply_GetIndustrialChainList(FTAPI_Conn client, int nSerialNo, QotGetIndustrialChainList.Response rsp) {
if (rsp.getRetType() != 0) {
System.out.printf("QotGetIndustrialChainList failed: %s
", rsp.getRetMsg());
} else {
try {
String json = JsonFormat.printer().print(rsp);
System.out.printf("Receive QotGetIndustrialChainList: %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
67
- Output
Send QotGetIndustrialChainList: 3
Receive QotGetIndustrialChainList: {
"allCount": 70,
"dataList": [
{ "chainId": "9610020", "name": "AI", "chainType": 1, "stocksNum": 329 },
{ "chainId": "9610085", "name": "商業航天", "chainType": 1, "stocksNum": 155 },
{ "chainId": "9610033", "name": "半導體", "chainType": 1, "stocksNum": 256 }
]
}
2
3
4
5
6
7
8
9
Futu::u32_t GetIndustrialChainList(const Qot_GetIndustrialChainList::Request &stReq); virtual void OnReply_GetIndustrialChainList(Futu::u32_t nSerialNo, const Qot_GetIndustrialChainList::Response &stRsp) = 0;
介紹
協議請求及回應定義
參數
// 產業鏈類型
enum IndustrialChainType {
IndustrialChainType_Chain = 1; // 串聯型
IndustrialChainType_Parallel = 2; // 並列型
IndustrialChainType_UpMidDown = 3; // 上中下游型
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket
optional string keyword = 2; // 搜索關鍵字(可選)
optional int32 count = 3; // 條數 [1,50], 默認20
optional string page = 4; // 翻頁遊標, 首次不傳
}
message IndustrialChainInfo {
optional int64 chainId = 1; // 產業鏈ID
optional int32 chainType = 2; // IndustrialChainType
optional string name = 3; // 名稱
optional string detail = 4; // 詳情描述
optional double marketCap = 5; // 市值
optional int64 stocksNum = 6; // 成分股數量
repeated Qot_Common.Security relationSecurityList = 7; // 相關股票
}
message S2C {
repeated IndustrialChainInfo dataList = 1;
optional int32 allCount = 2;
optional string nextPage = 3;
}
message Request {
required C2S c2s = 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
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
- 介面呼叫結果,結構參見 RetType
協議 ID
3427
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_GetIndustrialChainList::Request req;
Qot_GetIndustrialChainList::C2S *c2s = req.mutable_c2s();
c2s->set_market(Qot_Common::QotMarket::QotMarket_US_Security);
c2s->set_count(20);
m_GetIndustrialChainListSerialNo = m_pQotApi->GetIndustrialChainList(req);
}
virtual void OnReply_GetIndustrialChainList(Futu::u32_t nSerialNo, const Qot_GetIndustrialChainList::Response &stRsp) {
if (nSerialNo != m_GetIndustrialChainListSerialNo) return;
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
FTAPI_Qot *m_pQotApi;
Futu::u32_t m_GetIndustrialChainListSerialNo = 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
- Output
{
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"dataList": [
{
"chainId": 1001,
"chainName": "AI Supply Chain",
"plateCount": 8
}
],
"allCount": 120
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
getIndustrialChainList(qotGetIndustrialChainList)
介紹
獲取產業鏈列表,返回指定市場的產業鏈信息(含產業鏈類型、市值、成分股數量等),支持關鍵字搜索和遊標翻頁。
參數
// 產業鏈類型
enum IndustrialChainType {
IndustrialChainType_Chain = 1; // 串聯型
IndustrialChainType_Parallel = 2; // 並列型
IndustrialChainType_UpMidDown = 3; // 上中下游型
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket
optional string keyword = 2; // 搜索關鍵字(可選)
optional int32 count = 3; // 條數 [1,50], 默認20
optional string page = 4; // 翻頁遊標, 首次不傳
}
message IndustrialChainInfo {
optional int64 chainId = 1; // 產業鏈ID
optional int32 chainType = 2; // IndustrialChainType
optional string name = 3; // 名稱
optional string detail = 4; // 詳情描述
optional double marketCap = 5; // 市值
optional int64 stocksNum = 6; // 成分股數量
repeated Qot_Common.Security relationSecurityList = 7; // 相關股票
}
message S2C {
repeated IndustrialChainInfo dataList = 1;
optional int32 allCount = 2;
optional string nextPage = 3;
}
message Request {
required C2S c2s = 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
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
- 接口調用結果,結構參見 RetType
協議 ID
3427
Example
import ftWebsocket from "futu-api";
import { Common, Qot_Common } from "futu-api/proto";
import beautify from "js-beautify";
function QotGetIndustrialChainList(){
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: { market: 11, count: 3 },
};
websocket.GetIndustrialChainList(req)
.then((res)=>{
let { errCode, retMsg, retType, s2c } = res
console.log("GetIndustrialChainList: 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);
}
QotGetIndustrialChainList()
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
GetIndustrialChainList: errCode 0, retMsg , retType 0
{
"allCount": 70,
"dataList": [
{ "chainId": "9610020", "name": "AI", "chainType": 1, "stocksNum": 329 },
{ "chainId": "9610085", "name": "商業航天", "chainType": 1, "stocksNum": 155 },
{ "chainId": "9610033", "name": "半導體", "chainType": 1, "stocksNum": 256 }
]
}
2
3
4
5
6
7
8
9
接口限制
- 30 秒內最多 60 次請求
- 分頁請求僅首頁計入限頻統計
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_industrial_chain_list(market, keyword=None, count=None, page=None)
介紹
獲取產業鏈列表,返回指定市場的產業鏈信息(含產業鏈類型、市值、成分股數量等),支持關鍵字搜索和遊標翻頁。
參數
參數 類型 說明 market Market 市場類型(必填) keyword str 搜索關鍵字 count int 返回數量 [1, 50],默認 20 page str 翻頁遊標 返回
參數 類型 說明 ret RET_CODE 接口調用結果 data pd.DataFrame 當 ret == RET_OK,返回數據 str 當 ret != RET_OK,返回錯誤描述 - 數據格式如下:
字段 類型 說明 chain_id int 產業鏈 ID chain_type str 產業鏈類型("CHAIN"/"PARALLEL"/"UP_MID_DOWN") name str 產業鏈名稱 detail str 詳情描述 market_cap float 市值 stocks_num int 成分股數量 relation_security_list list 相關股票代碼列表 "CHAIN" 串聯型 "PARALLEL" 並列型 "UP_MID_DOWN" 上中下游型
- 數據格式如下:
Example
from futu import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data, next_page, all_count = quote_ctx.get_industrial_chain_list(market=Market.US, count=2)
if ret == RET_OK:
print(f'總數據量: {all_count}')
print(data)
else:
print('error:', data)
quote_ctx.close()
2
3
4
5
6
7
8
9
10
11
12
- Output
總數據量: 70
chain_id chain_type name detail market_cap stocks_num relation_security_list
0 9610020 UP_MID_DOWN AI AIGC(Artificial Intelligence Generated Content... 4.801784e+13 329 [US.NVDA, US.AAPL]
1 9610085 UP_MID_DOWN 商業航天 2.590359e+12 155 [US.GE, US.RTX]
2
3
4
# Qot_GetIndustrialChainList.proto
介紹
獲取產業鏈列表,返回指定市場的產業鏈信息(含產業鏈類型、市值、成分股數量等),支持關鍵字搜索和遊標翻頁。
參數
// 產業鏈類型
enum IndustrialChainType {
IndustrialChainType_Chain = 1; // 串聯型
IndustrialChainType_Parallel = 2; // 並列型
IndustrialChainType_UpMidDown = 3; // 上中下游型
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket
optional string keyword = 2; // 搜索關鍵字(可選)
optional int32 count = 3; // 條數 [1,50], 默認20
optional string page = 4; // 翻頁遊標, 首次不傳
}
message IndustrialChainInfo {
optional int64 chainId = 1; // 產業鏈ID
optional int32 chainType = 2; // IndustrialChainType
optional string name = 3; // 名稱
optional string detail = 4; // 詳情描述
optional double marketCap = 5; // 市值
optional int64 stocksNum = 6; // 成分股數量
repeated Qot_Common.Security relationSecurityList = 7; // 相關股票
}
message S2C {
repeated IndustrialChainInfo dataList = 1;
optional int32 allCount = 2;
optional string nextPage = 3;
}
message Request {
required C2S c2s = 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
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
協議 ID
3427
uint GetIndustrialChainList(Qot_GetIndustrialChainList.Request req);
virtual void OnReply_GetIndustrialChainList(FTAPI_Conn client, uint nSerialNo, Qot_GetIndustrialChainList.Response rsp);
介紹
獲取產業鏈列表,返回指定市場的產業鏈信息(含產業鏈類型、市值、成分股數量等),支持關鍵字搜索和遊標翻頁。
參數
// 產業鏈類型
enum IndustrialChainType {
IndustrialChainType_Chain = 1; // 串聯型
IndustrialChainType_Parallel = 2; // 並列型
IndustrialChainType_UpMidDown = 3; // 上中下游型
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket
optional string keyword = 2; // 搜索關鍵字(可選)
optional int32 count = 3; // 條數 [1,50], 默認20
optional string page = 4; // 翻頁遊標, 首次不傳
}
message IndustrialChainInfo {
optional int64 chainId = 1; // 產業鏈ID
optional int32 chainType = 2; // IndustrialChainType
optional string name = 3; // 名稱
optional string detail = 4; // 詳情描述
optional double marketCap = 5; // 市值
optional int64 stocksNum = 6; // 成分股數量
repeated Qot_Common.Security relationSecurityList = 7; // 相關股票
}
message S2C {
repeated IndustrialChainInfo dataList = 1;
optional int32 allCount = 2;
optional string nextPage = 3;
}
message Request {
required C2S c2s = 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
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
- 接口調用結果,結構參見 RetType
協議 ID
3427
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;
QotGetIndustrialChainList.C2S c2s = QotGetIndustrialChainList.C2S.CreateBuilder()
.SetMarket(11)
.SetCount(3)
.Build();
QotGetIndustrialChainList.Request req = QotGetIndustrialChainList.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetIndustrialChainList(req);
Console.Write("Send QotGetIndustrialChainList: {0}
", seqNo);
}
public void OnDisconnect(MMAPI_Conn client, long errCode) {
Console.Write("Qot onDisConnect: {0}
", errCode);
}
public void OnReply_GetIndustrialChainList(MMAPI_Conn client, uint nSerialNo, QotGetIndustrialChainList.Response rsp)
{
Console.Write("Reply: QotGetIndustrialChainList: {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
53
- Output
Send QotGetIndustrialChainList: 3
Reply: QotGetIndustrialChainList: 3
GetIndustrialChainList: errCode 0, retMsg , retType 0
{
"allCount": 70,
"dataList": [
{ "chainId": "9610020", "name": "AI", "chainType": 1, "stocksNum": 329 },
{ "chainId": "9610085", "name": "商業航天", "chainType": 1, "stocksNum": 155 },
{ "chainId": "9610033", "name": "半導體", "chainType": 1, "stocksNum": 256 }
]
}
2
3
4
5
6
7
8
9
10
11
int getIndustrialChainList(Qot_GetIndustrialChainList.Request req);
onReply_GetIndustrialChainList(FTAPI_Conn client, int nSerialNo, Qot_GetIndustrialChainList.Response rsp)
介紹
獲取產業鏈列表,返回指定市場的產業鏈信息(含產業鏈類型、市值、成分股數量等),支持關鍵字搜索和遊標翻頁。
參數
// 產業鏈類型
enum IndustrialChainType {
IndustrialChainType_Chain = 1; // 串聯型
IndustrialChainType_Parallel = 2; // 並列型
IndustrialChainType_UpMidDown = 3; // 上中下游型
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket
optional string keyword = 2; // 搜索關鍵字(可選)
optional int32 count = 3; // 條數 [1,50], 默認20
optional string page = 4; // 翻頁遊標, 首次不傳
}
message IndustrialChainInfo {
optional int64 chainId = 1; // 產業鏈ID
optional int32 chainType = 2; // IndustrialChainType
optional string name = 3; // 名稱
optional string detail = 4; // 詳情描述
optional double marketCap = 5; // 市值
optional int64 stocksNum = 6; // 成分股數量
repeated Qot_Common.Security relationSecurityList = 7; // 相關股票
}
message S2C {
repeated IndustrialChainInfo dataList = 1;
optional int32 allCount = 2;
optional string nextPage = 3;
}
message Request {
required C2S c2s = 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
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
- 接口調用結果,結構參見 RetType
協議 ID
3427
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;
QotGetIndustrialChainList.C2S c2s = QotGetIndustrialChainList.C2S.newBuilder()
.setMarket(11)
.setCount(3)
.build();
QotGetIndustrialChainList.Request req = QotGetIndustrialChainList.Request.newBuilder().setC2S(c2s).build();
int seqNo = qot.getIndustrialChainList(req);
System.out.printf("Send QotGetIndustrialChainList: %d
", seqNo);
}
@Override
public void onDisconnect(MMAPI_Conn client, long errCode) {
System.out.printf("Qot onDisConnect: %d
", errCode);
}
@Override
public void onReply_GetIndustrialChainList(MMAPI_Conn client, int nSerialNo, QotGetIndustrialChainList.Response rsp) {
if (rsp.getRetType() != 0) {
System.out.printf("QotGetIndustrialChainList failed: %s
", rsp.getRetMsg());
} else {
try {
String json = JsonFormat.printer().print(rsp);
System.out.printf("Receive QotGetIndustrialChainList: %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
67
- Output
Send QotGetIndustrialChainList: 3
Receive QotGetIndustrialChainList: {
"allCount": 70,
"dataList": [
{ "chainId": "9610020", "name": "AI", "chainType": 1, "stocksNum": 329 },
{ "chainId": "9610085", "name": "商業航天", "chainType": 1, "stocksNum": 155 },
{ "chainId": "9610033", "name": "半導體", "chainType": 1, "stocksNum": 256 }
]
}
2
3
4
5
6
7
8
9
moomoo::u32_t GetIndustrialChainList(const Qot_GetIndustrialChainList::Request &stReq); virtual void OnReply_GetIndustrialChainList(moomoo::u32_t nSerialNo, const Qot_GetIndustrialChainList::Response &stRsp) = 0;
介紹
協議請求及回應定義
參數
// 產業鏈類型
enum IndustrialChainType {
IndustrialChainType_Chain = 1; // 串聯型
IndustrialChainType_Parallel = 2; // 並列型
IndustrialChainType_UpMidDown = 3; // 上中下游型
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket
optional string keyword = 2; // 搜索關鍵字(可選)
optional int32 count = 3; // 條數 [1,50], 默認20
optional string page = 4; // 翻頁遊標, 首次不傳
}
message IndustrialChainInfo {
optional int64 chainId = 1; // 產業鏈ID
optional int32 chainType = 2; // IndustrialChainType
optional string name = 3; // 名稱
optional string detail = 4; // 詳情描述
optional double marketCap = 5; // 市值
optional int64 stocksNum = 6; // 成分股數量
repeated Qot_Common.Security relationSecurityList = 7; // 相關股票
}
message S2C {
repeated IndustrialChainInfo dataList = 1;
optional int32 allCount = 2;
optional string nextPage = 3;
}
message Request {
required C2S c2s = 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
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
- 介面呼叫結果,結構參見 RetType
協議 ID
3427
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_GetIndustrialChainList::Request req;
Qot_GetIndustrialChainList::C2S *c2s = req.mutable_c2s();
c2s->set_market(Qot_Common::QotMarket::QotMarket_US_Security);
c2s->set_count(20);
m_GetIndustrialChainListSerialNo = m_pQotApi->GetIndustrialChainList(req);
}
virtual void OnReply_GetIndustrialChainList(moomoo::u32_t nSerialNo, const Qot_GetIndustrialChainList::Response &stRsp) {
if (nSerialNo != m_GetIndustrialChainListSerialNo) return;
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
MMAPI_Qot *m_pQotApi;
moomoo::u32_t m_GetIndustrialChainListSerialNo = 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
- Output
{
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"dataList": [
{
"chainId": 1001,
"chainName": "AI Supply Chain",
"plateCount": 8
}
],
"allCount": 120
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
getIndustrialChainList(qotGetIndustrialChainList)
介紹
獲取產業鏈列表,返回指定市場的產業鏈信息(含產業鏈類型、市值、成分股數量等),支持關鍵字搜索和遊標翻頁。
參數
// 產業鏈類型
enum IndustrialChainType {
IndustrialChainType_Chain = 1; // 串聯型
IndustrialChainType_Parallel = 2; // 並列型
IndustrialChainType_UpMidDown = 3; // 上中下游型
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket
optional string keyword = 2; // 搜索關鍵字(可選)
optional int32 count = 3; // 條數 [1,50], 默認20
optional string page = 4; // 翻頁遊標, 首次不傳
}
message IndustrialChainInfo {
optional int64 chainId = 1; // 產業鏈ID
optional int32 chainType = 2; // IndustrialChainType
optional string name = 3; // 名稱
optional string detail = 4; // 詳情描述
optional double marketCap = 5; // 市值
optional int64 stocksNum = 6; // 成分股數量
repeated Qot_Common.Security relationSecurityList = 7; // 相關股票
}
message S2C {
repeated IndustrialChainInfo dataList = 1;
optional int32 allCount = 2;
optional string nextPage = 3;
}
message Request {
required C2S c2s = 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
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
- 接口調用結果,結構參見 RetType
協議 ID
3427
Example
import mmWebsocket from "moomoo-api";
import { Common, Qot_Common } from "moomoo-api/proto";
import beautify from "js-beautify";
function QotGetIndustrialChainList(){
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: { market: 11, count: 3 },
};
websocket.GetIndustrialChainList(req)
.then((res)=>{
let { errCode, retMsg, retType, s2c } = res
console.log("GetIndustrialChainList: 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);
}
QotGetIndustrialChainList()
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
GetIndustrialChainList: errCode 0, retMsg , retType 0
{
"allCount": 70,
"dataList": [
{ "chainId": "9610020", "name": "AI", "chainType": 1, "stocksNum": 329 },
{ "chainId": "9610085", "name": "商業航天", "chainType": 1, "stocksNum": 155 },
{ "chainId": "9610033", "name": "半導體", "chainType": 1, "stocksNum": 256 }
]
}
2
3
4
5
6
7
8
9
接口限制
- 30 秒內最多 60 次請求
- 分頁請求僅首頁計入限頻統計