# 获取板块/指数成分股估值列表
- 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 新利软件 -2.300 65.337673 3.029652e+07
HK.08092 ITE HOLDINGS 19.500 98.209927 3.609481e+07
HK.08036 电子交易集团 -12.000 35.313263 4.428000e+07
HK.01561 联洋智能控股 -23.500 1.057770 5.007634e+07
HK.08071 中彩网通控股 -12.000 39.951180 5.623258e+07
HK.00248 香港通讯国际控股 -2.056 19.446705 6.771489e+07
HK.01613 协同通信 -2.796 72.660700 8.841764e+07
HK.08062 俊盟国际 -93.333 0.244101 1.344000e+08
HK.01949 佰达国际控股 -5.147 36.523929 1.344000e+08
HK.01206 同方泰德 -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: "新利软件"
}
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=7459213552347179650
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: "新利软件"
}
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: "新利软件"
}
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.3658536,
"marketCap": 30296520,
"name": "新利软件"
//...
}],
"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 新利软件 -2.300 65.337673 3.029652e+07
HK.08092 ITE HOLDINGS 19.500 98.209927 3.609481e+07
HK.08036 电子交易集团 -12.000 35.313263 4.428000e+07
HK.01561 联洋智能控股 -23.500 1.057770 5.007634e+07
HK.08071 中彩网通控股 -12.000 39.951180 5.623258e+07
HK.00248 香港通讯国际控股 -2.056 19.446705 6.771489e+07
HK.01613 协同通信 -2.796 72.660700 8.841764e+07
HK.08062 俊盟国际 -93.333 0.244101 1.344000e+08
HK.01949 佰达国际控股 -5.147 36.523929 1.344000e+08
HK.01206 同方泰德 -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: "新利软件"
}
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=7459213552347179650
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: "新利软件"
}
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: "新利软件"
}
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.3658536,
"marketCap": 30296520,
"name": "新利软件"
//...
}],
"nextKey": "10"
}
stop
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
接口限制
- 每 30 秒内最多请求 30 次。
- 支持板块和指数,不支持个股。
- 指数首次全量请求时额外返回所属板块列表(plate_list)。
← 获取个股/指数估值详情 获取分红派息 →