# 獲取產業鏈詳情
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_industrial_chain_detail(chain_id)
介紹
獲取產業鏈詳情,返回指定產業鏈的完整結構信息,包含層級節點列表和相關資訊鏈接。
參數
參數 類型 說明 chain_id int 產業鏈 ID(從 get_industrial_chain_list獲取)(必填)返回
參數 類型 說明 ret RET_CODE 接口調用結果 data dict 當 ret == RET_OK,返回字典數據 str 當 ret != RET_OK,返回錯誤描述 - 數據格式如下:
字段 類型 說明 chain_id int 產業鏈 ID chain_type str 產業鏈類型("CHAIN"/"PARALLEL"/"UP_MID_DOWN") name str 產業鏈名稱 node_list list[dict] 節點列表(按層級分組) information_list list[dict] 資訊鏈接列表 node_id int 節點 ID parent_node_id int 父節點 ID(根節點爲 0) layer int 節點層級(從 1 開始) name str 節點名稱 plate_id int 關聯產業板塊 ID(無關聯爲 N/A) title str 資訊標題 url str 資訊鏈接
- 數據格式如下:
Example
from futu import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data = quote_ctx.get_industrial_chain_detail(chain_id=9610020)
if ret == RET_OK:
print(f"chain_id: {data['chain_id']}")
print(f"chain_type: {data['chain_type']}")
print(f"name: {data['name']}")
print(f"node_list (前2項):")
for node in data['node_list'][:2]:
print(f" {node}")
print(f"information_list: {data['information_list']}")
else:
print('error:', data)
quote_ctx.close()
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
- Output
chain_id: 9610020
chain_type: UP_MID_DOWN
name: AI
node_list (前2項):
{'node_id': 1, 'parent_node_id': 'N/A', 'layer': 1, 'name': '基礎建設層', 'plate_id': 'N/A'}
{'node_id': 4, 'parent_node_id': 'N/A', 'layer': 1, 'name': '算法層', 'plate_id': 'N/A'}
information_list: []
2
3
4
5
6
7
# Qot_GetIndustrialChainDetail.proto
介紹
獲取產業鏈詳情,返回指定產業鏈的完整結構信息,包含層級節點列表和相關資訊鏈接。
參數
message C2S {
required int64 chainId = 1; // 產業鏈ID
}
message IndustrialChainNode {
optional int64 nodeId = 1; // 節點ID
optional int64 parentNodeId = 2; // 父節點ID (根節點爲0)
optional int64 layerSth = 3; // 節點層級(從1開始)
optional string name = 4; // 節點名稱
optional int64 plateId = 5; // 關聯板塊ID(可選)
}
message InformationLink {
optional string title = 1; // 資訊標題
optional string url = 2; // 資訊鏈接
}
message S2C {
optional int64 chainId = 1; // 產業鏈ID
optional int32 chainType = 2; // 類型
optional string name = 3; // 名稱
repeated IndustrialChainNode nodeList = 4; // 節點列表(按層級分組)
repeated InformationLink informationList = 5; // 資訊鏈接
}
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
協議 ID
3428
uint GetIndustrialChainDetail(Qot_GetIndustrialChainDetail.Request req);
virtual void OnReply_GetIndustrialChainDetail(FTAPI_Conn client, uint nSerialNo, Qot_GetIndustrialChainDetail.Response rsp);
介紹
獲取產業鏈詳情,返回指定產業鏈的完整結構信息,包含層級節點列表和相關資訊鏈接。
參數
message C2S {
required int64 chainId = 1; // 產業鏈ID
}
message IndustrialChainNode {
optional int64 nodeId = 1; // 節點ID
optional int64 parentNodeId = 2; // 父節點ID (根節點爲0)
optional int64 layerSth = 3; // 節點層級(從1開始)
optional string name = 4; // 節點名稱
optional int64 plateId = 5; // 關聯板塊ID(可選)
}
message InformationLink {
optional string title = 1; // 資訊標題
optional string url = 2; // 資訊鏈接
}
message S2C {
optional int64 chainId = 1; // 產業鏈ID
optional int32 chainType = 2; // 類型
optional string name = 3; // 名稱
repeated IndustrialChainNode nodeList = 4; // 節點列表(按層級分組)
repeated InformationLink informationList = 5; // 資訊鏈接
}
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
- 接口調用結果,結構參見 RetType
協議 ID
3428
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;
QotGetIndustrialChainDetail.C2S c2s = QotGetIndustrialChainDetail.C2S.CreateBuilder()
.SetChainId(9610020)
.Build();
QotGetIndustrialChainDetail.Request req = QotGetIndustrialChainDetail.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetIndustrialChainDetail(req);
Console.Write("Send QotGetIndustrialChainDetail: {0}
", seqNo);
}
public void OnDisconnect(FTAPI_Conn client, long errCode) {
Console.Write("Qot onDisConnect: {0}
", errCode);
}
public void OnReply_GetIndustrialChainDetail(FTAPI_Conn client, uint nSerialNo, QotGetIndustrialChainDetail.Response rsp)
{
Console.Write("Reply: QotGetIndustrialChainDetail: {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 QotGetIndustrialChainDetail: 3
Reply: QotGetIndustrialChainDetail: 3
GetIndustrialChainDetail: errCode 0, retMsg , retType 0
{
"chainId": "9610020",
"name": "AI",
"chainType": 1,
"nodeList": [
{ "plateName": "基礎建設層", "level": 1 },
{ "plateName": "算法層", "level": 1 },
{ "plateName": "應用層", "level": 1, "plateId": "10010508" }
]
}
2
3
4
5
6
7
8
9
10
11
12
13
int getIndustrialChainDetail(Qot_GetIndustrialChainDetail.Request req);
onReply_GetIndustrialChainDetail(FTAPI_Conn client, int nSerialNo, Qot_GetIndustrialChainDetail.Response rsp)
介紹
獲取產業鏈詳情,返回指定產業鏈的完整結構信息,包含層級節點列表和相關資訊鏈接。
參數
message C2S {
required int64 chainId = 1; // 產業鏈ID
}
message IndustrialChainNode {
optional int64 nodeId = 1; // 節點ID
optional int64 parentNodeId = 2; // 父節點ID (根節點爲0)
optional int64 layerSth = 3; // 節點層級(從1開始)
optional string name = 4; // 節點名稱
optional int64 plateId = 5; // 關聯板塊ID(可選)
}
message InformationLink {
optional string title = 1; // 資訊標題
optional string url = 2; // 資訊鏈接
}
message S2C {
optional int64 chainId = 1; // 產業鏈ID
optional int32 chainType = 2; // 類型
optional string name = 3; // 名稱
repeated IndustrialChainNode nodeList = 4; // 節點列表(按層級分組)
repeated InformationLink informationList = 5; // 資訊鏈接
}
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
- 接口調用結果,結構參見 RetType
協議 ID
3428
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;
QotGetIndustrialChainDetail.C2S c2s = QotGetIndustrialChainDetail.C2S.newBuilder()
.setChainId(9610020)
.build();
QotGetIndustrialChainDetail.Request req = QotGetIndustrialChainDetail.Request.newBuilder().setC2S(c2s).build();
int seqNo = qot.getIndustrialChainDetail(req);
System.out.printf("Send QotGetIndustrialChainDetail: %d
", seqNo);
}
@Override
public void onDisconnect(FTAPI_Conn client, long errCode) {
System.out.printf("Qot onDisConnect: %d
", errCode);
}
@Override
public void onReply_GetIndustrialChainDetail(FTAPI_Conn client, int nSerialNo, QotGetIndustrialChainDetail.Response rsp) {
if (rsp.getRetType() != 0) {
System.out.printf("QotGetIndustrialChainDetail failed: %s
", rsp.getRetMsg());
} else {
try {
String json = JsonFormat.printer().print(rsp);
System.out.printf("Receive QotGetIndustrialChainDetail: %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 QotGetIndustrialChainDetail: 3
Receive QotGetIndustrialChainDetail: {
"chainId": "9610020",
"name": "AI",
"chainType": 1,
"nodeList": [
{ "plateName": "基礎建設層", "level": 1 },
{ "plateName": "算法層", "level": 1 },
{ "plateName": "應用層", "level": 1, "plateId": "10010508" }
]
}
2
3
4
5
6
7
8
9
10
11
Futu::u32_t GetIndustrialChainDetail(const Qot_GetIndustrialChainDetail::Request &stReq); virtual void OnReply_GetIndustrialChainDetail(Futu::u32_t nSerialNo, const Qot_GetIndustrialChainDetail::Response &stRsp) = 0;
介紹
協議請求及回應定義
參數
message C2S {
required int64 chainId = 1; // 產業鏈ID
}
message IndustrialChainNode {
optional int64 nodeId = 1; // 節點ID
optional int64 parentNodeId = 2; // 父節點ID (根節點爲0)
optional int64 layerSth = 3; // 節點層級(從1開始)
optional string name = 4; // 節點名稱
optional int64 plateId = 5; // 關聯板塊ID(可選)
}
message InformationLink {
optional string title = 1; // 資訊標題
optional string url = 2; // 資訊鏈接
}
message S2C {
optional int64 chainId = 1; // 產業鏈ID
optional int32 chainType = 2; // 類型
optional string name = 3; // 名稱
repeated IndustrialChainNode nodeList = 4; // 節點列表(按層級分組)
repeated InformationLink informationList = 5; // 資訊鏈接
}
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
- 介面呼叫結果,結構參見 RetType
協議 ID
3428
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_GetIndustrialChainDetail::Request req;
Qot_GetIndustrialChainDetail::C2S *c2s = req.mutable_c2s();
c2s->set_chainid(1234); // example chain ID, obtain from GetIndustrialChainList
m_GetIndustrialChainDetailSerialNo = m_pQotApi->GetIndustrialChainDetail(req);
}
virtual void OnReply_GetIndustrialChainDetail(Futu::u32_t nSerialNo, const Qot_GetIndustrialChainDetail::Response &stRsp) {
if (nSerialNo != m_GetIndustrialChainDetailSerialNo) return;
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
FTAPI_Qot *m_pQotApi;
Futu::u32_t m_GetIndustrialChainDetailSerialNo = 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": {
"chainId": 1001,
"chainType": 1,
"name": "AI Supply Chain",
"nodeList": [
{
"nodeName": "AI Chips",
"stockCount": 25
}
]
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
getIndustrialChainDetail(qotGetIndustrialChainDetail)
介紹
獲取產業鏈詳情,返回指定產業鏈的完整結構信息,包含層級節點列表和相關資訊鏈接。
參數
message C2S {
required int64 chainId = 1; // 產業鏈ID
}
message IndustrialChainNode {
optional int64 nodeId = 1; // 節點ID
optional int64 parentNodeId = 2; // 父節點ID (根節點爲0)
optional int64 layerSth = 3; // 節點層級(從1開始)
optional string name = 4; // 節點名稱
optional int64 plateId = 5; // 關聯板塊ID(可選)
}
message InformationLink {
optional string title = 1; // 資訊標題
optional string url = 2; // 資訊鏈接
}
message S2C {
optional int64 chainId = 1; // 產業鏈ID
optional int32 chainType = 2; // 類型
optional string name = 3; // 名稱
repeated IndustrialChainNode nodeList = 4; // 節點列表(按層級分組)
repeated InformationLink informationList = 5; // 資訊鏈接
}
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
- 接口調用結果,結構參見 RetType
協議 ID
3428
Example
import ftWebsocket from "futu-api";
import { Common, Qot_Common } from "futu-api/proto";
import beautify from "js-beautify";
function QotGetIndustrialChainDetail(){
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: { chainId: 9610020 },
};
websocket.GetIndustrialChainDetail(req)
.then((res)=>{
let { errCode, retMsg, retType, s2c } = res
console.log("GetIndustrialChainDetail: 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);
}
QotGetIndustrialChainDetail()
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
GetIndustrialChainDetail: errCode 0, retMsg , retType 0
{
"chainId": "9610020",
"name": "AI",
"chainType": 1,
"nodeList": [
{ "plateName": "基礎建設層", "level": 1 },
{ "plateName": "算法層", "level": 1 },
{ "plateName": "應用層", "level": 1, "plateId": "10010508" }
]
}
2
3
4
5
6
7
8
9
10
11
接口限制
- 30 秒內最多 60 次請求
- 分頁請求僅首頁計入限頻統計
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_industrial_chain_detail(chain_id)
介紹
獲取產業鏈詳情,返回指定產業鏈的完整結構信息,包含層級節點列表和相關資訊鏈接。
參數
參數 類型 說明 chain_id int 產業鏈 ID(從 get_industrial_chain_list獲取)(必填)返回
參數 類型 說明 ret RET_CODE 接口調用結果 data dict 當 ret == RET_OK,返回字典數據 str 當 ret != RET_OK,返回錯誤描述 - 數據格式如下:
字段 類型 說明 chain_id int 產業鏈 ID chain_type str 產業鏈類型("CHAIN"/"PARALLEL"/"UP_MID_DOWN") name str 產業鏈名稱 node_list list[dict] 節點列表(按層級分組) information_list list[dict] 資訊鏈接列表 node_id int 節點 ID parent_node_id int 父節點 ID(根節點爲 0) layer int 節點層級(從 1 開始) name str 節點名稱 plate_id int 關聯產業板塊 ID(無關聯爲 N/A) title str 資訊標題 url str 資訊鏈接
- 數據格式如下:
Example
from futu import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data = quote_ctx.get_industrial_chain_detail(chain_id=9610020)
if ret == RET_OK:
print(f"chain_id: {data['chain_id']}")
print(f"chain_type: {data['chain_type']}")
print(f"name: {data['name']}")
print(f"node_list (前2項):")
for node in data['node_list'][:2]:
print(f" {node}")
print(f"information_list: {data['information_list']}")
else:
print('error:', data)
quote_ctx.close()
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
- Output
chain_id: 9610020
chain_type: UP_MID_DOWN
name: AI
node_list (前2項):
{'node_id': 1, 'parent_node_id': 'N/A', 'layer': 1, 'name': '基礎建設層', 'plate_id': 'N/A'}
{'node_id': 4, 'parent_node_id': 'N/A', 'layer': 1, 'name': '算法層', 'plate_id': 'N/A'}
information_list: []
2
3
4
5
6
7
# Qot_GetIndustrialChainDetail.proto
介紹
獲取產業鏈詳情,返回指定產業鏈的完整結構信息,包含層級節點列表和相關資訊鏈接。
參數
message C2S {
required int64 chainId = 1; // 產業鏈ID
}
message IndustrialChainNode {
optional int64 nodeId = 1; // 節點ID
optional int64 parentNodeId = 2; // 父節點ID (根節點爲0)
optional int64 layerSth = 3; // 節點層級(從1開始)
optional string name = 4; // 節點名稱
optional int64 plateId = 5; // 關聯板塊ID(可選)
}
message InformationLink {
optional string title = 1; // 資訊標題
optional string url = 2; // 資訊鏈接
}
message S2C {
optional int64 chainId = 1; // 產業鏈ID
optional int32 chainType = 2; // 類型
optional string name = 3; // 名稱
repeated IndustrialChainNode nodeList = 4; // 節點列表(按層級分組)
repeated InformationLink informationList = 5; // 資訊鏈接
}
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
協議 ID
3428
uint GetIndustrialChainDetail(Qot_GetIndustrialChainDetail.Request req);
virtual void OnReply_GetIndustrialChainDetail(FTAPI_Conn client, uint nSerialNo, Qot_GetIndustrialChainDetail.Response rsp);
介紹
獲取產業鏈詳情,返回指定產業鏈的完整結構信息,包含層級節點列表和相關資訊鏈接。
參數
message C2S {
required int64 chainId = 1; // 產業鏈ID
}
message IndustrialChainNode {
optional int64 nodeId = 1; // 節點ID
optional int64 parentNodeId = 2; // 父節點ID (根節點爲0)
optional int64 layerSth = 3; // 節點層級(從1開始)
optional string name = 4; // 節點名稱
optional int64 plateId = 5; // 關聯板塊ID(可選)
}
message InformationLink {
optional string title = 1; // 資訊標題
optional string url = 2; // 資訊鏈接
}
message S2C {
optional int64 chainId = 1; // 產業鏈ID
optional int32 chainType = 2; // 類型
optional string name = 3; // 名稱
repeated IndustrialChainNode nodeList = 4; // 節點列表(按層級分組)
repeated InformationLink informationList = 5; // 資訊鏈接
}
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
- 接口調用結果,結構參見 RetType
協議 ID
3428
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;
QotGetIndustrialChainDetail.C2S c2s = QotGetIndustrialChainDetail.C2S.CreateBuilder()
.SetChainId(9610020)
.Build();
QotGetIndustrialChainDetail.Request req = QotGetIndustrialChainDetail.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetIndustrialChainDetail(req);
Console.Write("Send QotGetIndustrialChainDetail: {0}
", seqNo);
}
public void OnDisconnect(MMAPI_Conn client, long errCode) {
Console.Write("Qot onDisConnect: {0}
", errCode);
}
public void OnReply_GetIndustrialChainDetail(MMAPI_Conn client, uint nSerialNo, QotGetIndustrialChainDetail.Response rsp)
{
Console.Write("Reply: QotGetIndustrialChainDetail: {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 QotGetIndustrialChainDetail: 3
Reply: QotGetIndustrialChainDetail: 3
GetIndustrialChainDetail: errCode 0, retMsg , retType 0
{
"chainId": "9610020",
"name": "AI",
"chainType": 1,
"nodeList": [
{ "plateName": "基礎建設層", "level": 1 },
{ "plateName": "算法層", "level": 1 },
{ "plateName": "應用層", "level": 1, "plateId": "10010508" }
]
}
2
3
4
5
6
7
8
9
10
11
12
13
int getIndustrialChainDetail(Qot_GetIndustrialChainDetail.Request req);
onReply_GetIndustrialChainDetail(FTAPI_Conn client, int nSerialNo, Qot_GetIndustrialChainDetail.Response rsp)
介紹
獲取產業鏈詳情,返回指定產業鏈的完整結構信息,包含層級節點列表和相關資訊鏈接。
參數
message C2S {
required int64 chainId = 1; // 產業鏈ID
}
message IndustrialChainNode {
optional int64 nodeId = 1; // 節點ID
optional int64 parentNodeId = 2; // 父節點ID (根節點爲0)
optional int64 layerSth = 3; // 節點層級(從1開始)
optional string name = 4; // 節點名稱
optional int64 plateId = 5; // 關聯板塊ID(可選)
}
message InformationLink {
optional string title = 1; // 資訊標題
optional string url = 2; // 資訊鏈接
}
message S2C {
optional int64 chainId = 1; // 產業鏈ID
optional int32 chainType = 2; // 類型
optional string name = 3; // 名稱
repeated IndustrialChainNode nodeList = 4; // 節點列表(按層級分組)
repeated InformationLink informationList = 5; // 資訊鏈接
}
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
- 接口調用結果,結構參見 RetType
協議 ID
3428
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;
QotGetIndustrialChainDetail.C2S c2s = QotGetIndustrialChainDetail.C2S.newBuilder()
.setChainId(9610020)
.build();
QotGetIndustrialChainDetail.Request req = QotGetIndustrialChainDetail.Request.newBuilder().setC2S(c2s).build();
int seqNo = qot.getIndustrialChainDetail(req);
System.out.printf("Send QotGetIndustrialChainDetail: %d
", seqNo);
}
@Override
public void onDisconnect(MMAPI_Conn client, long errCode) {
System.out.printf("Qot onDisConnect: %d
", errCode);
}
@Override
public void onReply_GetIndustrialChainDetail(MMAPI_Conn client, int nSerialNo, QotGetIndustrialChainDetail.Response rsp) {
if (rsp.getRetType() != 0) {
System.out.printf("QotGetIndustrialChainDetail failed: %s
", rsp.getRetMsg());
} else {
try {
String json = JsonFormat.printer().print(rsp);
System.out.printf("Receive QotGetIndustrialChainDetail: %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 QotGetIndustrialChainDetail: 3
Receive QotGetIndustrialChainDetail: {
"chainId": "9610020",
"name": "AI",
"chainType": 1,
"nodeList": [
{ "plateName": "基礎建設層", "level": 1 },
{ "plateName": "算法層", "level": 1 },
{ "plateName": "應用層", "level": 1, "plateId": "10010508" }
]
}
2
3
4
5
6
7
8
9
10
11
moomoo::u32_t GetIndustrialChainDetail(const Qot_GetIndustrialChainDetail::Request &stReq); virtual void OnReply_GetIndustrialChainDetail(moomoo::u32_t nSerialNo, const Qot_GetIndustrialChainDetail::Response &stRsp) = 0;
介紹
協議請求及回應定義
參數
message C2S {
required int64 chainId = 1; // 產業鏈ID
}
message IndustrialChainNode {
optional int64 nodeId = 1; // 節點ID
optional int64 parentNodeId = 2; // 父節點ID (根節點爲0)
optional int64 layerSth = 3; // 節點層級(從1開始)
optional string name = 4; // 節點名稱
optional int64 plateId = 5; // 關聯板塊ID(可選)
}
message InformationLink {
optional string title = 1; // 資訊標題
optional string url = 2; // 資訊鏈接
}
message S2C {
optional int64 chainId = 1; // 產業鏈ID
optional int32 chainType = 2; // 類型
optional string name = 3; // 名稱
repeated IndustrialChainNode nodeList = 4; // 節點列表(按層級分組)
repeated InformationLink informationList = 5; // 資訊鏈接
}
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
- 介面呼叫結果,結構參見 RetType
協議 ID
3428
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_GetIndustrialChainDetail::Request req;
Qot_GetIndustrialChainDetail::C2S *c2s = req.mutable_c2s();
c2s->set_chainid(1234); // example chain ID, obtain from GetIndustrialChainList
m_GetIndustrialChainDetailSerialNo = m_pQotApi->GetIndustrialChainDetail(req);
}
virtual void OnReply_GetIndustrialChainDetail(moomoo::u32_t nSerialNo, const Qot_GetIndustrialChainDetail::Response &stRsp) {
if (nSerialNo != m_GetIndustrialChainDetailSerialNo) return;
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
MMAPI_Qot *m_pQotApi;
moomoo::u32_t m_GetIndustrialChainDetailSerialNo = 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": {
"chainId": 1001,
"chainType": 1,
"name": "AI Supply Chain",
"nodeList": [
{
"nodeName": "AI Chips",
"stockCount": 25
}
]
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
getIndustrialChainDetail(qotGetIndustrialChainDetail)
介紹
獲取產業鏈詳情,返回指定產業鏈的完整結構信息,包含層級節點列表和相關資訊鏈接。
參數
message C2S {
required int64 chainId = 1; // 產業鏈ID
}
message IndustrialChainNode {
optional int64 nodeId = 1; // 節點ID
optional int64 parentNodeId = 2; // 父節點ID (根節點爲0)
optional int64 layerSth = 3; // 節點層級(從1開始)
optional string name = 4; // 節點名稱
optional int64 plateId = 5; // 關聯板塊ID(可選)
}
message InformationLink {
optional string title = 1; // 資訊標題
optional string url = 2; // 資訊鏈接
}
message S2C {
optional int64 chainId = 1; // 產業鏈ID
optional int32 chainType = 2; // 類型
optional string name = 3; // 名稱
repeated IndustrialChainNode nodeList = 4; // 節點列表(按層級分組)
repeated InformationLink informationList = 5; // 資訊鏈接
}
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
- 接口調用結果,結構參見 RetType
協議 ID
3428
Example
import mmWebsocket from "moomoo-api";
import { Common, Qot_Common } from "moomoo-api/proto";
import beautify from "js-beautify";
function QotGetIndustrialChainDetail(){
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: { chainId: 9610020 },
};
websocket.GetIndustrialChainDetail(req)
.then((res)=>{
let { errCode, retMsg, retType, s2c } = res
console.log("GetIndustrialChainDetail: 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);
}
QotGetIndustrialChainDetail()
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
GetIndustrialChainDetail: errCode 0, retMsg , retType 0
{
"chainId": "9610020",
"name": "AI",
"chainType": 1,
"nodeList": [
{ "plateName": "基礎建設層", "level": 1 },
{ "plateName": "算法層", "level": 1 },
{ "plateName": "應用層", "level": 1, "plateId": "10010508" }
]
}
2
3
4
5
6
7
8
9
10
11
接口限制
- 30 秒內最多 60 次請求
- 分頁請求僅首頁計入限頻統計