# 獲取板塊/指數成分股估值列表
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_valuation_plate_stock_list(code, valuation_type=None, next_key=None, num=None, sort_type=None, sort_id=None, filter_security=None)
介紹
獲取板塊或指數成分股的估值列表,包含估值、預測估值、歷史分位、市值;指數首次全量請求還返回所屬板塊列表
參數
參數 類型 說明 code str 板塊或指數代碼 如 HK.LIST23363(板塊)或 HK.800000(指數);不支持個股valuation_type ValuationType 估值類型 0=Unknown,1=PE(市盈率),2=PB(市淨率),3=PS(市銷率);預設 None(1=PE)next_key str 分頁標識 首次不傳,續拉時填上次返回的 next_key;"-1" 表示無更多數據num int 每頁數量 預設 10,範圍 1~50sort_type SortType 排序方向 1=Desc(降序),2=Asc(升序);預設 None(升序)sort_id SortField 排序列 51=市值(預設),52=估值,53=預測估值,54=歷史分位filter_security str 板塊篩選 僅指數有效,按行業/板塊篩選成分股,如 HK.LIST23363;不傳則不篩選返回
參數 類型 說明 ret RET_CODE 接口調用結果 data dict 當 ret == RET_OK,返回成分股估值數據字典 str 當 ret != RET_OK,返回錯誤描述 返回字典包含以下欄位:
欄位 類型 說明 count int 成分股總數 stock_list list 成分股估值列表,每項見 stock_list 欄位表 next_key str 分頁標識 "-1" 表示無更多數據plate_list list 所屬板塊列表 僅指數全量首次請求時返回,每項見 plate_list 欄位表stock_list 欄位(成分股估值條目):
欄位 類型 說明 symbol str 股票代碼 valuation_val float 估值 forward_value float 預測估值 當前僅支持 PE 和 PSvaluation_percentile float 歷史分位 百分號前的值,如 12.34 表示 12.34%market_cap float 市值 name str 股票名稱 plate_list 欄位(指數所屬板塊條目):
欄位 類型 說明 symbol str 板塊代碼 name str 板塊名稱
Example
from futu import *
import pandas as pd
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data = quote_ctx.get_valuation_plate_stock_list("HK.LIST23363")
if ret == RET_OK:
df = pd.DataFrame(data.get('stock_list', []))
print(df.to_string(index=False))
else:
print('error:', data)
quote_ctx.close()
2
3
4
5
6
7
8
9
10
11
- Output
symbol name valuation_val valuation_percentile market_cap
HK.08076 SING LEE -2.300 65.337673 3.029652e+07
HK.08092 ITE HOLDINGS 19.500 98.209927 3.609481e+07
HK.08036 EBROKER GROUP -12.000 35.313263 4.428000e+07
HK.01561 PAN ASIA DATA H -23.500 1.057770 5.007634e+07
HK.08071 CH NETCOMTECH -13.000 31.489015 6.091863e+07
HK.00248 HKC INT'L HOLD -2.056 19.446705 6.771489e+07
HK.01613 SYNERTONE -2.796 72.660700 8.841764e+07
HK.08062 EFT SOLUTIONS -93.333 0.244101 1.344000e+08
HK.01949 PLATT NERA -5.147 36.523929 1.344000e+08
HK.01206 TECHNOVATOR -0.314 41.171684 1.720823e+08
2
3
4
5
6
7
8
9
10
11
# Qot_GetValuationPlateStockList.proto
介紹
獲取板塊/指數成分股估值列表
參數
message C2S
{
required Qot_Common.Security security = 1; // 股票(板塊或指數)
optional Qot_Common.ValuationType valuationType = 2; // 估值類型,詳見 Qot_Common.ValuationType 定義,支持 1-3,預設 1(PE)
optional string nextKey = 3; // 分頁標識,首次不填,續拉時填上次返回的 nextKey;"-1" 表示無更多數據
optional int32 num = 4; // 每頁返回數量,預設 10,範圍 1~50
optional Qot_Common.SortType sortType = 5; // 排序方向,詳見 Qot_Common.SortType 定義,預設升序(SortType_Asc=2)
optional Qot_Common.SortField sortId = 6; // 排序列,詳見 Qot_Common.SortField 定義,51=市值(預設)52=估值 53=預測估值 54=歷史分位
optional Qot_Common.Security filterSecurity = 7; // 僅指數成分股估值有效,按板塊篩選成分股,不傳則不篩選
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
- 股票結構參見 Security
- 估值類型參見 ValuationType
- 排序方式參見 SortType
- 排序欄位參見 SortField
- 返回
// 指數所屬板塊條目
message PlateItem
{
optional Qot_Common.Security security = 1; // 股票
optional string name = 2; // 板塊名稱
}
// 成分股估值條目
message StockItem
{
optional Qot_Common.Security security = 1; // 股票
optional string name = 6; // 股票名稱
optional double valuationVal = 2; // 估值
optional double forwardValue = 3; // 預測估值,當前僅支持 PE 和 PS
optional double valuationPercentile = 4; // 估值歷史分位,百分號前的值,如 12.34 表示 12.34%
optional double marketCap = 5; // 市值
}
message S2C
{
optional int32 count = 1; // 成分股總數
repeated StockItem stockList = 2; // 成分股估值列表
optional string nextKey = 3; // 分頁標識,"-1" 表示無更多數據
repeated PlateItem plateList = 4; // 指數成分股所屬行業/板塊列表;僅在指數全部板塊首次請求時返回
}
message Response
{
required int32 retType = 1 [default = -400]; // 返回結果,詳見 Common.RetType
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
- 接口調用結果,結構參見 RetType
協議 ID
3233
uint GetValuationPlateStockList(QotGetValuationPlateStockList.Request req);
virtual void OnReply_GetValuationPlateStockList(FTAPI_Conn client, uint nSerialNo, QotGetValuationPlateStockList.Response rsp);
介紹
獲取板塊/指數成分股估值列表
參數
message C2S
{
required Qot_Common.Security security = 1; // 股票(板塊或指數)
optional Qot_Common.ValuationType valuationType = 2; // 估值類型,詳見 Qot_Common.ValuationType 定義,支持 1-3,預設 1(PE)
optional string nextKey = 3; // 分頁標識,首次不填,續拉時填上次返回的 nextKey;"-1" 表示無更多數據
optional int32 num = 4; // 每頁返回數量,預設 10,範圍 1~50
optional Qot_Common.SortType sortType = 5; // 排序方向,詳見 Qot_Common.SortType 定義,預設升序(SortType_Asc=2)
optional Qot_Common.SortField sortId = 6; // 排序列,詳見 Qot_Common.SortField 定義,51=市值(預設)52=估值 53=預測估值 54=歷史分位
optional Qot_Common.Security filterSecurity = 7; // 僅指數成分股估值有效,按板塊篩選成分股,不傳則不篩選
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
- 股票結構參見 Security
- 返回
// 指數所屬板塊條目
message PlateItem
{
optional Qot_Common.Security security = 1; // 股票
optional string name = 2; // 板塊名稱
}
// 成分股估值條目
message StockItem
{
optional Qot_Common.Security security = 1; // 股票
optional string name = 6; // 股票名稱
optional double valuationVal = 2; // 估值
optional double forwardValue = 3; // 預測估值,當前僅支持 PE 和 PS
optional double valuationPercentile = 4; // 估值歷史分位,百分號前的值,如 12.34 表示 12.34%
optional double marketCap = 5; // 市值
}
message S2C
{
optional int32 count = 1; // 成分股總數
repeated StockItem stockList = 2; // 成分股估值列表
optional string nextKey = 3; // 分頁標識,"-1" 表示無更多數據
repeated PlateItem plateList = 4; // 指數成分股所屬行業/板塊列表;僅在指數全部板塊首次請求時返回
}
message Response
{
required int32 retType = 1 [default = -400]; // 返回結果,詳見 Common.RetType
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
- 接口調用結果,結構參見 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)
{
Console.Write("Qot onInitConnect: ret={0} desc={1} connID={2}\n", errCode, desc, client.GetConnectID());
if (errCode != 0)
return;
QotCommon.Security sec = QotCommon.Security.CreateBuilder()
.SetMarket((int)QotCommon.QotMarket.QotMarket_HK_Security)
.SetCode("LIST23363")
.Build();
QotGetValuationPlateStockList.C2S c2s = QotGetValuationPlateStockList.C2S.CreateBuilder()
.SetSecurity(sec)
.Build();
QotGetValuationPlateStockList.Request req = QotGetValuationPlateStockList.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetValuationPlateStockList(req);
Console.Write("Send QotGetValuationPlateStockList: {0}\n", seqNo);
}
public void OnDisconnect(FTAPI_Conn client, long errCode)
{
Console.Write("Qot onDisConnect: {0}\n", errCode);
}
public void OnReply_GetValuationPlateStockList(FTAPI_Conn client, uint nSerialNo, QotGetValuationPlateStockList.Response rsp)
{
Console.Write("Reply: QotGetValuationPlateStockList: {0} {1}\n", nSerialNo, rsp.ToString());
}
public static void Main(String[] args)
{
FTAPI.Init();
Program qot = new Program();
qot.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
54
55
56
- Output
sent seqNo=3
retType: 0
retMsg: ""
errCode: 0
s2c {
count: 69
stockList {
security {
market: 1
code: "08076"
}
valuationVal: -2.3
valuationPercentile: 65.3658536
marketCap: 30296520
name: "SING LEE"
}
stockList {
//...
}
nextKey: "10"
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
int getValuationPlateStockList(QotGetValuationPlateStockList.Request req);
void onReply_GetValuationPlateStockList(FTAPI_Conn client, int nSerialNo, QotGetValuationPlateStockList.Response rsp);
介紹
獲取板塊/指數成分股估值列表
參數
message C2S
{
required Qot_Common.Security security = 1; // 股票(板塊或指數)
optional Qot_Common.ValuationType valuationType = 2; // 估值類型,詳見 Qot_Common.ValuationType 定義,支持 1-3,預設 1(PE)
optional string nextKey = 3; // 分頁標識,首次不填,續拉時填上次返回的 nextKey;"-1" 表示無更多數據
optional int32 num = 4; // 每頁返回數量,預設 10,範圍 1~50
optional Qot_Common.SortType sortType = 5; // 排序方向,詳見 Qot_Common.SortType 定義,預設升序(SortType_Asc=2)
optional Qot_Common.SortField sortId = 6; // 排序列,詳見 Qot_Common.SortField 定義,51=市值(預設)52=估值 53=預測估值 54=歷史分位
optional Qot_Common.Security filterSecurity = 7; // 僅指數成分股估值有效,按板塊篩選成分股,不傳則不篩選
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
- 股票結構參見 Security
- 返回
// 指數所屬板塊條目
message PlateItem
{
optional Qot_Common.Security security = 1; // 股票
optional string name = 2; // 板塊名稱
}
// 成分股估值條目
message StockItem
{
optional Qot_Common.Security security = 1; // 股票
optional string name = 6; // 股票名稱
optional double valuationVal = 2; // 估值
optional double forwardValue = 3; // 預測估值,當前僅支持 PE 和 PS
optional double valuationPercentile = 4; // 估值歷史分位,百分號前的值,如 12.34 表示 12.34%
optional double marketCap = 5; // 市值
}
message S2C
{
optional int32 count = 1; // 成分股總數
repeated StockItem stockList = 2; // 成分股估值列表
optional string nextKey = 3; // 分頁標識,"-1" 表示無更多數據
repeated PlateItem plateList = 4; // 指數成分股所屬行業/板塊列表;僅在指數全部板塊首次請求時返回
}
message Response
{
required int32 retType = 1 [default = -400]; // 返回結果,詳見 Common.RetType
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
- 接口調用結果,結構參見 RetType
- 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=%b desc=%s connID=%d\n", errCode, desc, client.getConnectID());
if (errCode != 0)
return;
QotCommon.Security sec = QotCommon.Security.newBuilder()
.setMarket(QotCommon.QotMarket.QotMarket_HK_Security_VALUE)
.setCode("LIST23363")
.build();
QotGetValuationPlateStockList.C2S c2s = QotGetValuationPlateStockList.C2S.newBuilder()
.setSecurity(sec)
.build();
QotGetValuationPlateStockList.Request req = QotGetValuationPlateStockList.Request.newBuilder().setC2S(c2s).build();
int seqNo = qot.getValuationPlateStockList(req);
System.out.printf("Send QotGetValuationPlateStockList: %d\n", seqNo);
}
@Override
public void onDisconnect(FTAPI_Conn client, long errCode) {
System.out.printf("Qot onDisConnect: %d\n", errCode);
}
@Override
public void onReply_GetValuationPlateStockList(FTAPI_Conn client, int nSerialNo, QotGetValuationPlateStockList.Response rsp) {
if (rsp.getRetType() != 0) {
System.out.printf("QotGetValuationPlateStockList failed: %s\n", rsp.getRetMsg());
}
else {
try {
String json = JsonFormat.printer().print(rsp);
System.out.printf("Receive QotGetValuationPlateStockList: %s\n", 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
Qot onInitConnect: ret=0 desc= connID=7459212604361842573
Send Qot_GetValuationPlateStockList: 2
Receive Qot_GetValuationPlateStockList: retType: 0
retMsg: ""
errCode: 0
s2c {
count: 69
stockList {
security {
market: 1
code: "08076"
}
valuationVal: -2.3
valuationPercentile: 65.3658536
marketCap: 3.029652E7
name: "SING LEE"
}
stockList {
//...
}
nextKey: "10"
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Futu::u32_t GetValuationPlateStockList(const Qot_GetValuationPlateStockList::Request &stReq);
virtual void OnReply_GetValuationPlateStockList(Futu::u32_t nSerialNo, const Qot_GetValuationPlateStockList::Response &stRsp) = 0;
介紹
獲取板塊/指數成分股估值列表
參數
message C2S
{
required Qot_Common.Security security = 1; // 股票(板塊或指數)
optional Qot_Common.ValuationType valuationType = 2; // 估值類型,詳見 Qot_Common.ValuationType 定義,支持 1-3,預設 1(PE)
optional string nextKey = 3; // 分頁標識,首次不填,續拉時填上次返回的 nextKey;"-1" 表示無更多數據
optional int32 num = 4; // 每頁返回數量,預設 10,範圍 1~50
optional Qot_Common.SortType sortType = 5; // 排序方向,詳見 Qot_Common.SortType 定義,預設升序(SortType_Asc=2)
optional Qot_Common.SortField sortId = 6; // 排序列,詳見 Qot_Common.SortField 定義,51=市值(預設)52=估值 53=預測估值 54=歷史分位
optional Qot_Common.Security filterSecurity = 7; // 僅指數成分股估值有效,按板塊篩選成分股,不傳則不篩選
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
- 股票結構參見 Security
- 返回
// 指數所屬板塊條目
message PlateItem
{
optional Qot_Common.Security security = 1; // 股票
optional string name = 2; // 板塊名稱
}
// 成分股估值條目
message StockItem
{
optional Qot_Common.Security security = 1; // 股票
optional string name = 6; // 股票名稱
optional double valuationVal = 2; // 估值
optional double forwardValue = 3; // 預測估值,當前僅支持 PE 和 PS
optional double valuationPercentile = 4; // 估值歷史分位,百分號前的值,如 12.34 表示 12.34%
optional double marketCap = 5; // 市值
}
message S2C
{
optional int32 count = 1; // 成分股總數
repeated StockItem stockList = 2; // 成分股估值列表
optional string nextKey = 3; // 分頁標識,"-1" 表示無更多數據
repeated PlateItem plateList = 4; // 指數成分股所屬行業/板塊列表;僅在指數全部板塊首次請求時返回
}
message Response
{
required int32 retType = 1 [default = -400]; // 返回結果,詳見 Common.RetType
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
- 接口調用結果,結構參見 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;
// construct request message
Qot_GetValuationPlateStockList::Request req;
Qot_GetValuationPlateStockList::C2S *c2s = req.mutable_c2s();
Qot_Common::Security *sec = c2s->mutable_security();
sec->set_code("LIST23363");
sec->set_market(Qot_Common::QotMarket::QotMarket_HK_Security);
m_pQotApi->GetValuationPlateStockList(req);
cout << "GetValuationPlateStockList" << endl;
}
virtual void OnReply_GetValuationPlateStockList(Futu::u32_t nSerialNo, const Qot_GetValuationPlateStockList::Response &stRsp){
cout << "OnReply_GetValuationPlateStockList:" << endl;
// print response
// ProtoBufToBodyData and UTF8ToLocal refer to tool.h in Samples
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
FTAPI_Qot *m_pQotApi;
};
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
- Output
onInitConnect: ret=0 desc=Succeed!
Send Qot_GetValuationPlateStockList seqNo=3
retType: 0
retMsg: ""
errCode: 0
s2c {
count: 69
stockList {
security {
market: 1
code: "08076"
}
valuationVal: -2.3
valuationPercentile: 65.3658536
marketCap: 30296520
name: "SING LEE"
}
stockList {
//...
}
nextKey: "10"
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
GetValuationPlateStockList(req);
介紹
獲取板塊/指數成分股估值列表
參數
message C2S
{
required Qot_Common.Security security = 1; // 股票(板塊或指數)
optional Qot_Common.ValuationType valuationType = 2; // 估值類型,詳見 Qot_Common.ValuationType 定義,支持 1-3,預設 1(PE)
optional string nextKey = 3; // 分頁標識,首次不填,續拉時填上次返回的 nextKey;"-1" 表示無更多數據
optional int32 num = 4; // 每頁返回數量,預設 10,範圍 1~50
optional Qot_Common.SortType sortType = 5; // 排序方向,詳見 Qot_Common.SortType 定義,預設升序(SortType_Asc=2)
optional Qot_Common.SortField sortId = 6; // 排序列,詳見 Qot_Common.SortField 定義,51=市值(預設)52=估值 53=預測估值 54=歷史分位
optional Qot_Common.Security filterSecurity = 7; // 僅指數成分股估值有效,按板塊篩選成分股,不傳則不篩選
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
- 股票結構參見 Security
- 返回
// 指數所屬板塊條目
message PlateItem
{
optional Qot_Common.Security security = 1; // 股票
optional string name = 2; // 板塊名稱
}
// 成分股估值條目
message StockItem
{
optional Qot_Common.Security security = 1; // 股票
optional string name = 6; // 股票名稱
optional double valuationVal = 2; // 估值
optional double forwardValue = 3; // 預測估值,當前僅支持 PE 和 PS
optional double valuationPercentile = 4; // 估值歷史分位,百分號前的值,如 12.34 表示 12.34%
optional double marketCap = 5; // 市值
}
message S2C
{
optional int32 count = 1; // 成分股總數
repeated StockItem stockList = 2; // 成分股估值列表
optional string nextKey = 3; // 分頁標識,"-1" 表示無更多數據
repeated PlateItem plateList = 4; // 指數成分股所屬行業/板塊列表;僅在指數全部板塊首次請求時返回
}
message Response
{
required int32 retType = 1 [default = -400]; // 返回結果,詳見 Common.RetType
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
- 接口調用結果,結構參見 RetType
- Example
import ftWebsocket from "futu-api";
import { Common, Qot_Common } from "futu-api/proto";
import beautify from "js-beautify";
function QotGetValuationPlateStockList(){
const { RetType } = Common
const { QotMarket } = Qot_Common
let [addr, port, enable_ssl, key] = ["127.0.0.1", 33333, false, '7522027ccf5a06b1'];
let websocket = new ftWebsocket();
websocket.onlogin = (ret, msg)=>{
if (ret) {
const req = {
c2s: {
security: {
market: QotMarket.QotMarket_HK_Security,
code: "LIST23363",
},
},
};
websocket.GetValuationPlateStockList(req)
.then((res) => {
let { errCode, retMsg, retType,s2c } = res
console.log("GetValuationPlateStockList: 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("error", msg);
}
};
websocket.start(addr, port, enable_ssl, key);
setTimeout(()=>{
websocket.stop();
console.log("stop");
}, 5000);
}
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
- Output
GetValuationPlateStockList: errCode 0, retMsg , retType 0
{
"count": 69,
"stockList": [{
"security": {
"market": 1,
"code": "08076"
},
"valuationVal": -2.3,
"valuationPercentile": 65.3376729,
"marketCap": 30296520,
"name": "SING LEE"
//...
}],
"nextKey": "10"
}
stop
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
接口限制
- 每 30 秒內最多請求 30 次。
- 支持板塊和指數,不支持個股。
- 指數首次全量請求時額外返回所屬板塊列表(plate_list)。
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_valuation_plate_stock_list(code, valuation_type=None, next_key=None, num=None, sort_type=None, sort_id=None, filter_security=None)
介紹
獲取板塊或指數成分股的估值列表,包含估值、預測估值、歷史分位、市值;指數首次全量請求還返回所屬板塊列表
參數
參數 類型 說明 code str 板塊或指數代碼 如 HK.LIST23363(板塊)或 HK.800000(指數);不支持個股valuation_type ValuationType 估值類型 0=Unknown,1=PE(市盈率),2=PB(市淨率),3=PS(市銷率);預設 None(1=PE)next_key str 分頁標識 首次不傳,續拉時填上次返回的 next_key;"-1" 表示無更多數據num int 每頁數量 預設 10,範圍 1~50sort_type SortType 排序方向 1=Desc(降序),2=Asc(升序);預設 None(升序)sort_id SortField 排序列 51=市值(預設),52=估值,53=預測估值,54=歷史分位filter_security str 板塊篩選 僅指數有效,按行業/板塊篩選成分股,如 HK.LIST23363;不傳則不篩選返回
參數 類型 說明 ret RET_CODE 接口調用結果 data dict 當 ret == RET_OK,返回成分股估值數據字典 str 當 ret != RET_OK,返回錯誤描述 返回字典包含以下欄位:
欄位 類型 說明 count int 成分股總數 stock_list list 成分股估值列表,每項見 stock_list 欄位表 next_key str 分頁標識 "-1" 表示無更多數據plate_list list 所屬板塊列表 僅指數全量首次請求時返回,每項見 plate_list 欄位表stock_list 欄位(成分股估值條目):
欄位 類型 說明 symbol str 股票代碼 valuation_val float 估值 forward_value float 預測估值 當前僅支持 PE 和 PSvaluation_percentile float 歷史分位 百分號前的值,如 12.34 表示 12.34%market_cap float 市值 name str 股票名稱 plate_list 欄位(指數所屬板塊條目):
欄位 類型 說明 symbol str 板塊代碼 name str 板塊名稱
Example
from moomoo import *
import pandas as pd
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data = quote_ctx.get_valuation_plate_stock_list("HK.LIST23363")
if ret == RET_OK:
df = pd.DataFrame(data.get('stock_list', []))
print(df.to_string(index=False))
else:
print('error:', data)
quote_ctx.close()
2
3
4
5
6
7
8
9
10
- Output
symbol name valuation_val valuation_percentile market_cap
HK.08076 SING LEE -2.300 65.337673 3.029652e+07
HK.08092 ITE HOLDINGS 19.500 98.209927 3.609481e+07
HK.08036 EBROKER GROUP -12.000 35.313263 4.428000e+07
HK.01561 PAN ASIA DATA H -23.500 1.057770 5.007634e+07
HK.08071 CH NETCOMTECH -13.000 31.489015 6.091863e+07
HK.00248 HKC INT'L HOLD -2.056 19.446705 6.771489e+07
HK.01613 SYNERTONE -2.796 72.660700 8.841764e+07
HK.08062 EFT SOLUTIONS -93.333 0.244101 1.344000e+08
HK.01949 PLATT NERA -5.147 36.523929 1.344000e+08
HK.01206 TECHNOVATOR -0.314 41.171684 1.720823e+08
2
3
4
5
6
7
8
9
10
11
# Qot_GetValuationPlateStockList.proto
介紹
獲取板塊/指數成分股估值列表
參數
message C2S
{
required Qot_Common.Security security = 1; // 股票(板塊或指數)
optional Qot_Common.ValuationType valuationType = 2; // 估值類型,詳見 Qot_Common.ValuationType 定義,支持 1-3,預設 1(PE)
optional string nextKey = 3; // 分頁標識,首次不填,續拉時填上次返回的 nextKey;"-1" 表示無更多數據
optional int32 num = 4; // 每頁返回數量,預設 10,範圍 1~50
optional Qot_Common.SortType sortType = 5; // 排序方向,詳見 Qot_Common.SortType 定義,預設升序(SortType_Asc=2)
optional Qot_Common.SortField sortId = 6; // 排序列,詳見 Qot_Common.SortField 定義,51=市值(預設)52=估值 53=預測估值 54=歷史分位
optional Qot_Common.Security filterSecurity = 7; // 僅指數成分股估值有效,按板塊篩選成分股,不傳則不篩選
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
- 股票結構參見 Security
- 估值類型參見 ValuationType
- 排序方式參見 SortType
- 排序欄位參見 SortField
- 返回
// 指數所屬板塊條目
message PlateItem
{
optional Qot_Common.Security security = 1; // 股票
optional string name = 2; // 板塊名稱
}
// 成分股估值條目
message StockItem
{
optional Qot_Common.Security security = 1; // 股票
optional string name = 6; // 股票名稱
optional double valuationVal = 2; // 估值
optional double forwardValue = 3; // 預測估值,當前僅支持 PE 和 PS
optional double valuationPercentile = 4; // 估值歷史分位,百分號前的值,如 12.34 表示 12.34%
optional double marketCap = 5; // 市值
}
message S2C
{
optional int32 count = 1; // 成分股總數
repeated StockItem stockList = 2; // 成分股估值列表
optional string nextKey = 3; // 分頁標識,"-1" 表示無更多數據
repeated PlateItem plateList = 4; // 指數成分股所屬行業/板塊列表;僅在指數全部板塊首次請求時返回
}
message Response
{
required int32 retType = 1 [default = -400]; // 返回結果,詳見 Common.RetType
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
- 接口調用結果,結構參見 RetType
協議 ID
3233
uint GetValuationPlateStockList(QotGetValuationPlateStockList.Request req);
virtual void OnReply_GetValuationPlateStockList(MMAPI_Conn client, uint nSerialNo, QotGetValuationPlateStockList.Response rsp);
介紹
獲取板塊/指數成分股估值列表
參數
message C2S
{
required Qot_Common.Security security = 1; // 股票(板塊或指數)
optional Qot_Common.ValuationType valuationType = 2; // 估值類型,詳見 Qot_Common.ValuationType 定義,支持 1-3,預設 1(PE)
optional string nextKey = 3; // 分頁標識,首次不填,續拉時填上次返回的 nextKey;"-1" 表示無更多數據
optional int32 num = 4; // 每頁返回數量,預設 10,範圍 1~50
optional Qot_Common.SortType sortType = 5; // 排序方向,詳見 Qot_Common.SortType 定義,預設升序(SortType_Asc=2)
optional Qot_Common.SortField sortId = 6; // 排序列,詳見 Qot_Common.SortField 定義,51=市值(預設)52=估值 53=預測估值 54=歷史分位
optional Qot_Common.Security filterSecurity = 7; // 僅指數成分股估值有效,按板塊篩選成分股,不傳則不篩選
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
- 股票結構參見 Security
- 返回
// 指數所屬板塊條目
message PlateItem
{
optional Qot_Common.Security security = 1; // 股票
optional string name = 2; // 板塊名稱
}
// 成分股估值條目
message StockItem
{
optional Qot_Common.Security security = 1; // 股票
optional string name = 6; // 股票名稱
optional double valuationVal = 2; // 估值
optional double forwardValue = 3; // 預測估值,當前僅支持 PE 和 PS
optional double valuationPercentile = 4; // 估值歷史分位,百分號前的值,如 12.34 表示 12.34%
optional double marketCap = 5; // 市值
}
message S2C
{
optional int32 count = 1; // 成分股總數
repeated StockItem stockList = 2; // 成分股估值列表
optional string nextKey = 3; // 分頁標識,"-1" 表示無更多數據
repeated PlateItem plateList = 4; // 指數成分股所屬行業/板塊列表;僅在指數全部板塊首次請求時返回
}
message Response
{
required int32 retType = 1 [default = -400]; // 返回結果,詳見 Common.RetType
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
- 接口調用結果,結構參見 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)
{
Console.Write("Qot onInitConnect: ret={0} desc={1} connID={2}\n", errCode, desc, client.GetConnectID());
if (errCode != 0)
return;
QotCommon.Security sec = QotCommon.Security.CreateBuilder()
.SetMarket((int)QotCommon.QotMarket.QotMarket_HK_Security)
.SetCode("LIST23363")
.Build();
QotGetValuationPlateStockList.C2S c2s = QotGetValuationPlateStockList.C2S.CreateBuilder()
.SetSecurity(sec)
.Build();
QotGetValuationPlateStockList.Request req = QotGetValuationPlateStockList.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetValuationPlateStockList(req);
Console.Write("Send QotGetValuationPlateStockList: {0}\n", seqNo);
}
public void OnDisconnect(MMAPI_Conn client, long errCode)
{
Console.Write("Qot onDisConnect: {0}\n", errCode);
}
public void OnReply_GetValuationPlateStockList(MMAPI_Conn client, uint nSerialNo, QotGetValuationPlateStockList.Response rsp)
{
Console.Write("Reply: QotGetValuationPlateStockList: {0} {1}\n", nSerialNo, rsp.ToString());
}
public static void Main(String[] args)
{
MMAPI.Init();
Program qot = new Program();
qot.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
54
55
56
- Output
sent seqNo=3
retType: 0
retMsg: ""
errCode: 0
s2c {
count: 69
stockList {
security {
market: 1
code: "08076"
}
valuationVal: -2.3
valuationPercentile: 65.3658536
marketCap: 30296520
name: "SING LEE"
}
stockList {
//...
}
nextKey: "10"
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
int getValuationPlateStockList(QotGetValuationPlateStockList.Request req);
void onReply_GetValuationPlateStockList(MMAPI_Conn client, int nSerialNo, QotGetValuationPlateStockList.Response rsp);
介紹
獲取板塊/指數成分股估值列表
參數
message C2S
{
required Qot_Common.Security security = 1; // 股票(板塊或指數)
optional Qot_Common.ValuationType valuationType = 2; // 估值類型,詳見 Qot_Common.ValuationType 定義,支持 1-3,預設 1(PE)
optional string nextKey = 3; // 分頁標識,首次不填,續拉時填上次返回的 nextKey;"-1" 表示無更多數據
optional int32 num = 4; // 每頁返回數量,預設 10,範圍 1~50
optional Qot_Common.SortType sortType = 5; // 排序方向,詳見 Qot_Common.SortType 定義,預設升序(SortType_Asc=2)
optional Qot_Common.SortField sortId = 6; // 排序列,詳見 Qot_Common.SortField 定義,51=市值(預設)52=估值 53=預測估值 54=歷史分位
optional Qot_Common.Security filterSecurity = 7; // 僅指數成分股估值有效,按板塊篩選成分股,不傳則不篩選
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
- 股票結構參見 Security
- 返回
// 指數所屬板塊條目
message PlateItem
{
optional Qot_Common.Security security = 1; // 股票
optional string name = 2; // 板塊名稱
}
// 成分股估值條目
message StockItem
{
optional Qot_Common.Security security = 1; // 股票
optional string name = 6; // 股票名稱
optional double valuationVal = 2; // 估值
optional double forwardValue = 3; // 預測估值,當前僅支持 PE 和 PS
optional double valuationPercentile = 4; // 估值歷史分位,百分號前的值,如 12.34 表示 12.34%
optional double marketCap = 5; // 市值
}
message S2C
{
optional int32 count = 1; // 成分股總數
repeated StockItem stockList = 2; // 成分股估值列表
optional string nextKey = 3; // 分頁標識,"-1" 表示無更多數據
repeated PlateItem plateList = 4; // 指數成分股所屬行業/板塊列表;僅在指數全部板塊首次請求時返回
}
message Response
{
required int32 retType = 1 [default = -400]; // 返回結果,詳見 Common.RetType
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
- 接口調用結果,結構參見 RetType
- 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=%b desc=%s connID=%d\n", errCode, desc, client.getConnectID());
if (errCode != 0)
return;
QotCommon.Security sec = QotCommon.Security.newBuilder()
.setMarket(QotCommon.QotMarket.QotMarket_HK_Security_VALUE)
.setCode("LIST23363")
.build();
QotGetValuationPlateStockList.C2S c2s = QotGetValuationPlateStockList.C2S.newBuilder()
.setSecurity(sec)
.build();
QotGetValuationPlateStockList.Request req = QotGetValuationPlateStockList.Request.newBuilder().setC2S(c2s).build();
int seqNo = qot.getValuationPlateStockList(req);
System.out.printf("Send QotGetValuationPlateStockList: %d\n", seqNo);
}
@Override
public void onDisconnect(MMAPI_Conn client, long errCode) {
System.out.printf("Qot onDisConnect: %d\n", errCode);
}
@Override
public void onReply_GetValuationPlateStockList(MMAPI_Conn client, int nSerialNo, QotGetValuationPlateStockList.Response rsp) {
if (rsp.getRetType() != 0) {
System.out.printf("QotGetValuationPlateStockList failed: %s\n", rsp.getRetMsg());
}
else {
try {
String json = JsonFormat.printer().print(rsp);
System.out.printf("Receive QotGetValuationPlateStockList: %s\n", 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
Qot onInitConnect: ret=0 desc= connID=7459212604361842573
Send Qot_GetValuationPlateStockList: 2
Receive Qot_GetValuationPlateStockList: retType: 0
retMsg: ""
errCode: 0
s2c {
count: 69
stockList {
security {
market: 1
code: "08076"
}
valuationVal: -2.3
valuationPercentile: 65.3658536
marketCap: 3.029652E7
name: "SING LEE"
}
stockList {
//...
}
nextKey: "10"
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
moomoo::u32_t GetValuationPlateStockList(const Qot_GetValuationPlateStockList::Request &stReq);
virtual void OnReply_GetValuationPlateStockList(moomoo::u32_t nSerialNo, const Qot_GetValuationPlateStockList::Response &stRsp) = 0;
介紹
獲取板塊/指數成分股估值列表
參數
message C2S
{
required Qot_Common.Security security = 1; // 股票(板塊或指數)
optional Qot_Common.ValuationType valuationType = 2; // 估值類型,詳見 Qot_Common.ValuationType 定義,支持 1-3,預設 1(PE)
optional string nextKey = 3; // 分頁標識,首次不填,續拉時填上次返回的 nextKey;"-1" 表示無更多數據
optional int32 num = 4; // 每頁返回數量,預設 10,範圍 1~50
optional Qot_Common.SortType sortType = 5; // 排序方向,詳見 Qot_Common.SortType 定義,預設升序(SortType_Asc=2)
optional Qot_Common.SortField sortId = 6; // 排序列,詳見 Qot_Common.SortField 定義,51=市值(預設)52=估值 53=預測估值 54=歷史分位
optional Qot_Common.Security filterSecurity = 7; // 僅指數成分股估值有效,按板塊篩選成分股,不傳則不篩選
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
- 股票結構參見 Security
- 返回
// 指數所屬板塊條目
message PlateItem
{
optional Qot_Common.Security security = 1; // 股票
optional string name = 2; // 板塊名稱
}
// 成分股估值條目
message StockItem
{
optional Qot_Common.Security security = 1; // 股票
optional string name = 6; // 股票名稱
optional double valuationVal = 2; // 估值
optional double forwardValue = 3; // 預測估值,當前僅支持 PE 和 PS
optional double valuationPercentile = 4; // 估值歷史分位,百分號前的值,如 12.34 表示 12.34%
optional double marketCap = 5; // 市值
}
message S2C
{
optional int32 count = 1; // 成分股總數
repeated StockItem stockList = 2; // 成分股估值列表
optional string nextKey = 3; // 分頁標識,"-1" 表示無更多數據
repeated PlateItem plateList = 4; // 指數成分股所屬行業/板塊列表;僅在指數全部板塊首次請求時返回
}
message Response
{
required int32 retType = 1 [default = -400]; // 返回結果,詳見 Common.RetType
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
- 接口調用結果,結構參見 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;
// construct request message
Qot_GetValuationPlateStockList::Request req;
Qot_GetValuationPlateStockList::C2S *c2s = req.mutable_c2s();
Qot_Common::Security *sec = c2s->mutable_security();
sec->set_code("LIST23363");
sec->set_market(Qot_Common::QotMarket::QotMarket_HK_Security);
m_pQotApi->GetValuationPlateStockList(req);
cout << "GetValuationPlateStockList" << endl;
}
virtual void OnReply_GetValuationPlateStockList(moomoo::u32_t nSerialNo, const Qot_GetValuationPlateStockList::Response &stRsp){
cout << "OnReply_GetValuationPlateStockList:" << endl;
// print response
// ProtoBufToBodyData and UTF8ToLocal refer to tool.h in Samples
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
MMAPI_Qot *m_pQotApi;
};
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
- Output
onInitConnect: ret=0 desc=Succeed!
Send Qot_GetValuationPlateStockList seqNo=3
retType: 0
retMsg: ""
errCode: 0
s2c {
count: 69
stockList {
security {
market: 1
code: "08076"
}
valuationVal: -2.3
valuationPercentile: 65.3658536
marketCap: 30296520
name: "SING LEE"
}
stockList {
//...
}
nextKey: "10"
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
GetValuationPlateStockList(req);
介紹
獲取板塊/指數成分股估值列表
參數
message C2S
{
required Qot_Common.Security security = 1; // 股票(板塊或指數)
optional Qot_Common.ValuationType valuationType = 2; // 估值類型,詳見 Qot_Common.ValuationType 定義,支持 1-3,預設 1(PE)
optional string nextKey = 3; // 分頁標識,首次不填,續拉時填上次返回的 nextKey;"-1" 表示無更多數據
optional int32 num = 4; // 每頁返回數量,預設 10,範圍 1~50
optional Qot_Common.SortType sortType = 5; // 排序方向,詳見 Qot_Common.SortType 定義,預設升序(SortType_Asc=2)
optional Qot_Common.SortField sortId = 6; // 排序列,詳見 Qot_Common.SortField 定義,51=市值(預設)52=估值 53=預測估值 54=歷史分位
optional Qot_Common.Security filterSecurity = 7; // 僅指數成分股估值有效,按板塊篩選成分股,不傳則不篩選
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
- 股票結構參見 Security
- 返回
// 指數所屬板塊條目
message PlateItem
{
optional Qot_Common.Security security = 1; // 股票
optional string name = 2; // 板塊名稱
}
// 成分股估值條目
message StockItem
{
optional Qot_Common.Security security = 1; // 股票
optional string name = 6; // 股票名稱
optional double valuationVal = 2; // 估值
optional double forwardValue = 3; // 預測估值,當前僅支持 PE 和 PS
optional double valuationPercentile = 4; // 估值歷史分位,百分號前的值,如 12.34 表示 12.34%
optional double marketCap = 5; // 市值
}
message S2C
{
optional int32 count = 1; // 成分股總數
repeated StockItem stockList = 2; // 成分股估值列表
optional string nextKey = 3; // 分頁標識,"-1" 表示無更多數據
repeated PlateItem plateList = 4; // 指數成分股所屬行業/板塊列表;僅在指數全部板塊首次請求時返回
}
message Response
{
required int32 retType = 1 [default = -400]; // 返回結果,詳見 Common.RetType
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
- 接口調用結果,結構參見 RetType
- Example
import mmWebsocket from "moomoo-api";
import { Common, Qot_Common } from "moomoo-api/proto";
import beautify from "js-beautify";
function QotGetValuationPlateStockList(){
const { RetType } = Common
const { QotMarket } = Qot_Common
let [addr, port, enable_ssl, key] = ["127.0.0.1", 33333, false, '7522027ccf5a06b1'];
let websocket = new mmWebsocket();
websocket.onlogin = (ret, msg)=>{
if (ret) {
const req = {
c2s: {
security: {
market: QotMarket.QotMarket_HK_Security,
code: "LIST23363",
},
},
};
websocket.GetValuationPlateStockList(req)
.then((res) => {
let { errCode, retMsg, retType,s2c } = res
console.log("GetValuationPlateStockList: 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("error", msg);
}
};
websocket.start(addr, port, enable_ssl, key);
setTimeout(()=>{
websocket.stop();
console.log("stop");
}, 5000);
}
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
- Output
GetValuationPlateStockList: errCode 0, retMsg , retType 0
{
"count": 69,
"stockList": [{
"security": {
"market": 1,
"code": "08076"
},
"valuationVal": -2.3,
"valuationPercentile": 65.3376729,
"marketCap": 30296520,
"name": "SING LEE"
//...
}],
"nextKey": "10"
}
stop
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
接口限制
- 每 30 秒內最多請求 30 次。
- 支持板塊和指數,不支持個股。
- 指數首次全量請求時額外返回所屬板塊列表(plate_list)。
← 獲取個股/指數估值詳情 獲取分紅派息 →