# 获取个股/指数估值详情
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_valuation_detail(code, valuation_type=None, interval_type=None)
介绍
获取指定股票或指数的估值详情,包含估值走势、市场分布、行业分布(仅个股)、盈利/营收增速(仅个股,PB 无)
参数
参数 类型 说明 code str 股票代码 valuation_type ValuationType 估值类型 0=Unknown(使用推荐类型),1=PE(市盈率),2=PB(市净率),3=PS(市销率);默认 None(使用推荐类型)interval_type ValuationIntervalType 历史数据时间周期 0=Unknown,1=Month3,2=Month6,3=Year1,4=Year3,5=Since2019,6=Year5,7=Year10,8=Year2,9=Year20,10=Year30;默认 None返回
参数 类型 说明 ret RET_CODE 接口调用结果 data dict 当 ret == RET_OK,返回估值详情数据字典 str 当 ret != RET_OK,返回错误描述 返回字典包含以下字段:
字段 类型 说明 valuation_type ValuationType 实际估值类型 0=Unknown,1=PE,2=PB,3=PSlast_update_time int 最后更新时间戳(秒,对应市场时区) last_update_time_str str 最后更新时间 格式 YYYY-MM-DD HH:MM:SS,对应市场时区trend dict 走势数据,见 trend 字段表 market_distribution dict 市场分布数据,见 market_distribution 字段表 plate_distribution dict 行业分布数据,见 plate_distribution 字段表 仅个股返回profit_growth_rate dict 盈利/营收增速数据,见 profit_growth_rate 字段表 仅个股返回,PB 估值无此字段trend 字段(估值走势摘要):
字段 类型 说明 current_value float 当前估值 average_value float 历史平均估值 avg_minus_1_stddev float 历史平均 - 1σ avg_plus_1_stddev float 历史平均 + 1σ valuation_percentile float 历史分位 百分号前的值,如 12.34 表示 12.34%forward_value float 预测估值 仅 PE / PS 有historical_items list 历史估值列表,每项见 historical_items 字段表 historical_items 字段(历史估值条目):
字段 类型 说明 value float 估值 time int 时间戳(秒,对应市场时区) time_str str 日期 格式 YYYY-MM-DD,对应市场时区plate_value float 行业均值 market_distribution 字段(市场/成分股分布):
字段 类型 说明 sections list 区间分布列表(降序),每项见 sections 字段表 total int 市场总数/成分股总数 ranking int 该股票估值在市场中的排名 指数无此字段average_value float 市场估值均值 指数无此字段median_value float 市场估值中位数 指数无此字段sections 字段(区间分布条目):
字段 类型 说明 start float 区间开始值 end float 区间结束值 0 表示无上限number int 该区间个股数量 plate_distribution 字段(行业分布,仅个股):
字段 类型 说明 plate str 所属板块代码 plate_name str 所属板块名称 plate_average_value float 板块估值均值 plate_ranking int 该股票估值在板块中的排名 plate_stock_item_count int 板块个股总数 stock_items list 板块成分股估值明细,每项见 stock_items 字段表 stock_items 字段(板块成分股条目):
字段 类型 说明 security str 股票代码 name str 个股名称 value float 估值 market_cap float 市值 profit_growth_rate 字段(盈利/营收增速,仅个股非 PB):
字段 类型 说明 financial_ttm_multiple float TTM 增长倍数 market_cap_multiple float 市值增长倍数 year_count int 计算增长倍数时实际用到的年份数量 profit_data list 各期数据列表,每项见 profit_data 字段表 conclusion_detailed str 估值结论描述 profit_data 字段(各期盈利/营收条目):
字段 类型 说明 financial_year int 财报年度 financial_quarter int 财报季度 1=Q1,2=Q2,3=Q3,4=FYperiod_str str 财报周期 如 "2024/Q3"、"2024/FY"report_date int 报告日时间戳(秒,对应市场时区) report_date_str str 报告日 格式 YYYY-MM-DD,对应市场时区market_cap_multiple float 报告日市值倍数 基准期 = 1finance_data_multiple float 盈利/营收倍数 基准期 = 1,依 valuation_type 而定
Example
from futu import *
import pandas as pd
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data = quote_ctx.get_valuation_detail("HK.00700")
if ret == RET_OK:
trend = data.get('trend', {})
items = trend.get('historical_items', [])
df = pd.DataFrame(items)
print(df.to_string(index=False))
else:
print('error:', data)
quote_ctx.close()
2
3
4
5
6
7
8
9
10
11
12
13
- Output
value time time_str plate_value
22.690 1746979200 2025-05-12 22.678
22.186 1747065600 2025-05-13 22.179
22.843 1747152000 2025-05-14 22.817
22.046 1747238400 2025-05-15 22.050
21.538 1747324800 2025-05-16 21.577
21.792 1747584000 2025-05-19 21.821
//...
18.087 1776960000 2026-04-24 18.147
17.544 1777219200 2026-04-27 17.617
17.368 1777305600 2026-04-28 17.444
17.566 1777392000 2026-04-29 17.650
17.148 1777478400 2026-04-30 17.227
17.339 1777824000 2026-05-04 17.421
17.310 1777910400 2026-05-05 17.393
16.972 1777996800 2026-05-06 17.059
17.500 1778083200 2026-05-07 17.589
17.266 1778169600 2026-05-08 17.364
17.039 1778428800 2026-05-11 17.143
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Qot_GetValuationDetail.proto
介绍
获取个股/指数估值详情
参数
message C2S
{
required Qot_Common.Security security = 1; // 股票
optional Qot_Common.ValuationType valuationType = 2; // 估值类型,详见 Qot_Common.ValuationType 定义,默认 0(Unknown,使用推荐类型)
optional Qot_Common.ValuationIntervalType intervalType = 3; // 历史数据时间周期,详见 Qot_Common.ValuationIntervalType 定义
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 股票结构参见 Security
- ValuationType:0=Unknown,1=PE,2=PB,3=PS
- ValuationIntervalType:0=Unknown,1=Month3,2=Month6,3=Year1,4=Year3,5=Since2019,6=Year5,7=Year10,8=Year2,9=Year20,10=Year30
- 返回
// 走势
message ValuationTrend
{
message ValuationHistoricalItem
{
optional double value = 1; // 估值
optional uint64 time = 2; // 时间戳(秒)
optional string timeStr = 3; // 时间字符串,格式 YYYY-MM-DD,对应市场时区
optional double plateValue = 4; // 行业均值
}
optional double currentValue = 1; // 当前估值
optional double averageValue = 2; // 历史平均估值
optional double avgMinus1Stddev = 3; // 历史平均 - 1σ
optional double avgPlus1Stddev = 4; // 历史平均 + 1σ
optional double valuationPercentile = 5; // 估值历史分位,百分号前的值,如 12.34 表示 12.34%
optional double forwardValue = 6; // 预测估值,仅 PE / PS 有
repeated ValuationHistoricalItem historicalItems = 7; // 历史数据
}
// 市场分布
message MarketDistribution
{
message DistributionSection
{
optional double start = 1; // 区间开始值
optional double end = 2; // 区间结束值(0 表示无上限)
optional int32 number = 3; // 该区间个股数量
}
repeated DistributionSection sections = 1; // 区间分布(降序)
optional int32 total = 2; // 市场总数 / 成分股总数
optional int32 ranking = 3; // 该股票估值在市场中的排名(指数无)
optional double averageValue = 4; // 市场估值均值(指数无)
optional double medianValue = 5; // 市场估值中位数(指数无)
}
// 行业分布
message PlateDistribution
{
message PlateStockItem
{
optional Qot_Common.Security security = 1; // 股票
optional string name = 2; // 个股名称
optional double value = 3; // 估值
optional double marketCap = 4; // 市值
}
optional Qot_Common.Security plate = 1; // 所属板块
optional string plateName = 2; // 所属板块名称
optional double plateAverageValue = 3; // 板块估值均值
optional int32 plateRanking = 4; // 该股票估值在板块中的排名
optional int32 plateStockItemCount = 5; // 板块个股总数
repeated PlateStockItem stockItems = 6; // 板块成分股估值明细
}
// 盈利 / 营收增速
message ProfitGrowthRate
{
message ProfitGrowthItem
{
optional uint32 financialYear = 1; // 财报年度
optional uint32 financialQuarter = 2; // 财报季度(1=Q1, 2=Q2, 3=Q3, 4=FY)
optional string periodStr = 3; // 财报周期,如 "2024/Q3"、"2024/FY"
optional int64 reportDate = 4; // 报告日时间戳(秒)
optional string reportDateStr = 5; // 报告日字符串,格式 YYYY-MM-DD,对应市场时区
optional double marketCapMultiple = 6; // 报告日市值倍数(基准期 = 1)
optional double financeDataMultiple = 7; // 盈利 / 营收倍数(基准期 = 1,依 valuationType 而定)
}
optional double financialTtmMultiple = 1; // TTM 增长倍数
optional double marketCapMultiple = 2; // 市值增长倍数
optional int32 yearCount = 3; // 计算增长倍数时实际用到的年份数量
repeated ProfitGrowthItem profitData = 4; // 各期数据
optional string conclusionDetailed = 5; // 估值结论描述(已多语言翻译)
}
message S2C
{
optional Qot_Common.ValuationType valuationType = 1; // 实际返回的估值类型,详见 Qot_Common.ValuationType 定义
optional uint64 lastUpdateTime = 2; // 最后更新时间戳(秒)
optional string lastUpdateTimeStr = 3; // 最后更新时间字符串,格式 YYYY-MM-DD HH:MM:SS,对应市场时区
optional ValuationTrend trend = 4; // 走势(个股 + 指数)
optional MarketDistribution marketDistribution = 5; // 市场分布 / 成分股分布(个股 + 指数)
optional PlateDistribution plateDistribution = 6; // 行业分布(仅个股)
optional ProfitGrowthRate profitGrowthRate = 7; // 盈利 / 营收增速(仅个股,PB 无)
}
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
- 接口调用结果,结构参见 RetType
- 估值类型参见 ValuationType
协议 ID
3232
uint GetValuationDetail(QotGetValuationDetail.Request req);
virtual void OnReply_GetValuationDetail(FTAPI_Conn client, uint nSerialNo, QotGetValuationDetail.Response rsp);
介绍
获取个股/指数估值详情
参数
message C2S
{
required Qot_Common.Security security = 1; // 股票
optional Qot_Common.ValuationType valuationType = 2; // 估值类型,详见 Qot_Common.ValuationType 定义,默认 0(Unknown,使用推荐类型)
optional Qot_Common.ValuationIntervalType intervalType = 3; // 历史数据时间周期,详见 Qot_Common.ValuationIntervalType 定义
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 股票结构参见 Security
- 估值类型参见 ValuationType
- 估值历史区间类型参见 ValuationIntervalType
- 返回
// 走势
message ValuationTrend
{
message ValuationHistoricalItem
{
optional double value = 1; // 估值
optional uint64 time = 2; // 时间戳(秒)
optional string timeStr = 3; // 时间字符串,格式 YYYY-MM-DD,对应市场时区
optional double plateValue = 4; // 行业均值
}
optional double currentValue = 1; // 当前估值
optional double averageValue = 2; // 历史平均估值
optional double avgMinus1Stddev = 3; // 历史平均 - 1σ
optional double avgPlus1Stddev = 4; // 历史平均 + 1σ
optional double valuationPercentile = 5; // 估值历史分位,百分号前的值,如 12.34 表示 12.34%
optional double forwardValue = 6; // 预测估值,仅 PE / PS 有
repeated ValuationHistoricalItem historicalItems = 7; // 历史数据
}
// 市场分布
message MarketDistribution
{
message DistributionSection
{
optional double start = 1; // 区间开始值
optional double end = 2; // 区间结束值(0 表示无上限)
optional int32 number = 3; // 该区间个股数量
}
repeated DistributionSection sections = 1; // 区间分布(降序)
optional int32 total = 2; // 市场总数 / 成分股总数
optional int32 ranking = 3; // 该股票估值在市场中的排名(指数无)
optional double averageValue = 4; // 市场估值均值(指数无)
optional double medianValue = 5; // 市场估值中位数(指数无)
}
// 行业分布
message PlateDistribution
{
message PlateStockItem
{
optional Qot_Common.Security security = 1; // 股票
optional string name = 2; // 个股名称
optional double value = 3; // 估值
optional double marketCap = 4; // 市值
}
optional Qot_Common.Security plate = 1; // 所属板块
optional string plateName = 2; // 所属板块名称
optional double plateAverageValue = 3; // 板块估值均值
optional int32 plateRanking = 4; // 该股票估值在板块中的排名
optional int32 plateStockItemCount = 5; // 板块个股总数
repeated PlateStockItem stockItems = 6; // 板块成分股估值明细
}
// 盈利 / 营收增速
message ProfitGrowthRate
{
message ProfitGrowthItem
{
optional uint32 financialYear = 1; // 财报年度
optional uint32 financialQuarter = 2; // 财报季度(1=Q1, 2=Q2, 3=Q3, 4=FY)
optional string periodStr = 3; // 财报周期,如 "2024/Q3"、"2024/FY"
optional int64 reportDate = 4; // 报告日时间戳(秒)
optional string reportDateStr = 5; // 报告日字符串,格式 YYYY-MM-DD,对应市场时区
optional double marketCapMultiple = 6; // 报告日市值倍数(基准期 = 1)
optional double financeDataMultiple = 7; // 盈利 / 营收倍数(基准期 = 1,依 valuationType 而定)
}
optional double financialTtmMultiple = 1; // TTM 增长倍数
optional double marketCapMultiple = 2; // 市值增长倍数
optional int32 yearCount = 3; // 计算增长倍数时实际用到的年份数量
repeated ProfitGrowthItem profitData = 4; // 各期数据
optional string conclusionDetailed = 5; // 估值结论描述(已多语言翻译)
}
message S2C
{
optional Qot_Common.ValuationType valuationType = 1; // 实际返回的估值类型,详见 Qot_Common.ValuationType 定义
optional uint64 lastUpdateTime = 2; // 最后更新时间戳(秒)
optional string lastUpdateTimeStr = 3; // 最后更新时间字符串,格式 YYYY-MM-DD HH:MM:SS,对应市场时区
optional ValuationTrend trend = 4; // 走势(个股 + 指数)
optional MarketDistribution marketDistribution = 5; // 市场分布 / 成分股分布(个股 + 指数)
optional PlateDistribution plateDistribution = 6; // 行业分布(仅个股)
optional ProfitGrowthRate profitGrowthRate = 7; // 盈利 / 营收增速(仅个股,PB 无)
}
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
- 接口调用结果,结构参见 RetType
- 估值类型参见 ValuationType
- 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("00700")
.Build();
QotGetValuationDetail.C2S c2s = QotGetValuationDetail.C2S.CreateBuilder()
.SetSecurity(sec)
.Build();
QotGetValuationDetail.Request req = QotGetValuationDetail.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetValuationDetail(req);
Console.Write("Send QotGetValuationDetail: {0}\n", seqNo);
}
public void OnDisconnect(FTAPI_Conn client, long errCode)
{
Console.Write("Qot onDisConnect: {0}\n", errCode);
}
public void OnReply_GetValuationDetail(FTAPI_Conn client, uint nSerialNo, QotGetValuationDetail.Response rsp)
{
Console.Write("Reply: QotGetValuationDetail: {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 {
valuationType: ValuationType_PE
lastUpdateTime: 1778415094
lastUpdateTimeStr: "2026-05-10 20:11:34"
trend {
currentValue: 17.266
averageValue: 22.499
avgMinus1Stddev: 20.043
avgPlus1Stddev: 24.955
valuationPercentile: 1.2195121
forwardValue: 15.449
historicalItems {
value: 22.69
time: 1746979200
timeStr: "2025-05-12"
plateValue: 22.678
}
historicalItems {
//...
}
}
//...
}
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
int getValuationDetail(QotGetValuationDetail.Request req);
void onReply_GetValuationDetail(FTAPI_Conn client, int nSerialNo, QotGetValuationDetail.Response rsp);
介绍
获取个股/指数估值详情
参数
message C2S
{
required Qot_Common.Security security = 1; // 股票
optional Qot_Common.ValuationType valuationType = 2; // 估值类型,详见 Qot_Common.ValuationType 定义,默认 0(Unknown,使用推荐类型)
optional Qot_Common.ValuationIntervalType intervalType = 3; // 历史数据时间周期,详见 Qot_Common.ValuationIntervalType 定义
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 股票结构参见 Security
- 估值类型参见 ValuationType
- 估值历史区间类型参见 ValuationIntervalType
- 返回
// 走势
message ValuationTrend
{
message ValuationHistoricalItem
{
optional double value = 1; // 估值
optional uint64 time = 2; // 时间戳(秒)
optional string timeStr = 3; // 时间字符串,格式 YYYY-MM-DD,对应市场时区
optional double plateValue = 4; // 行业均值
}
optional double currentValue = 1; // 当前估值
optional double averageValue = 2; // 历史平均估值
optional double avgMinus1Stddev = 3; // 历史平均 - 1σ
optional double avgPlus1Stddev = 4; // 历史平均 + 1σ
optional double valuationPercentile = 5; // 估值历史分位,百分号前的值,如 12.34 表示 12.34%
optional double forwardValue = 6; // 预测估值,仅 PE / PS 有
repeated ValuationHistoricalItem historicalItems = 7; // 历史数据
}
// 市场分布
message MarketDistribution
{
message DistributionSection
{
optional double start = 1; // 区间开始值
optional double end = 2; // 区间结束值(0 表示无上限)
optional int32 number = 3; // 该区间个股数量
}
repeated DistributionSection sections = 1; // 区间分布(降序)
optional int32 total = 2; // 市场总数 / 成分股总数
optional int32 ranking = 3; // 该股票估值在市场中的排名(指数无)
optional double averageValue = 4; // 市场估值均值(指数无)
optional double medianValue = 5; // 市场估值中位数(指数无)
}
// 行业分布
message PlateDistribution
{
message PlateStockItem
{
optional Qot_Common.Security security = 1; // 股票
optional string name = 2; // 个股名称
optional double value = 3; // 估值
optional double marketCap = 4; // 市值
}
optional Qot_Common.Security plate = 1; // 所属板块
optional string plateName = 2; // 所属板块名称
optional double plateAverageValue = 3; // 板块估值均值
optional int32 plateRanking = 4; // 该股票估值在板块中的排名
optional int32 plateStockItemCount = 5; // 板块个股总数
repeated PlateStockItem stockItems = 6; // 板块成分股估值明细
}
// 盈利 / 营收增速
message ProfitGrowthRate
{
message ProfitGrowthItem
{
optional uint32 financialYear = 1; // 财报年度
optional uint32 financialQuarter = 2; // 财报季度(1=Q1, 2=Q2, 3=Q3, 4=FY)
optional string periodStr = 3; // 财报周期,如 "2024/Q3"、"2024/FY"
optional int64 reportDate = 4; // 报告日时间戳(秒)
optional string reportDateStr = 5; // 报告日字符串,格式 YYYY-MM-DD,对应市场时区
optional double marketCapMultiple = 6; // 报告日市值倍数(基准期 = 1)
optional double financeDataMultiple = 7; // 盈利 / 营收倍数(基准期 = 1,依 valuationType 而定)
}
optional double financialTtmMultiple = 1; // TTM 增长倍数
optional double marketCapMultiple = 2; // 市值增长倍数
optional int32 yearCount = 3; // 计算增长倍数时实际用到的年份数量
repeated ProfitGrowthItem profitData = 4; // 各期数据
optional string conclusionDetailed = 5; // 估值结论描述(已多语言翻译)
}
message S2C
{
optional Qot_Common.ValuationType valuationType = 1; // 实际返回的估值类型,详见 Qot_Common.ValuationType 定义
optional uint64 lastUpdateTime = 2; // 最后更新时间戳(秒)
optional string lastUpdateTimeStr = 3; // 最后更新时间字符串,格式 YYYY-MM-DD HH:MM:SS,对应市场时区
optional ValuationTrend trend = 4; // 走势(个股 + 指数)
optional MarketDistribution marketDistribution = 5; // 市场分布 / 成分股分布(个股 + 指数)
optional PlateDistribution plateDistribution = 6; // 行业分布(仅个股)
optional ProfitGrowthRate profitGrowthRate = 7; // 盈利 / 营收增速(仅个股,PB 无)
}
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
- 接口调用结果,结构参见 RetType
- 估值类型参见 ValuationType
- 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("00700")
.build();
QotGetValuationDetail.C2S c2s = QotGetValuationDetail.C2S.newBuilder()
.setSecurity(sec)
.build();
QotGetValuationDetail.Request req = QotGetValuationDetail.Request.newBuilder().setC2S(c2s).build();
int seqNo = qot.getValuationDetail(req);
System.out.printf("Send QotGetValuationDetail: %d\n", seqNo);
}
@Override
public void onDisconnect(FTAPI_Conn client, long errCode) {
System.out.printf("Qot onDisConnect: %d\n", errCode);
}
@Override
public void onReply_GetValuationDetail(FTAPI_Conn client, int nSerialNo, QotGetValuationDetail.Response rsp) {
if (rsp.getRetType() != 0) {
System.out.printf("QotGetValuationDetail failed: %s\n", rsp.getRetMsg());
}
else {
try {
String json = JsonFormat.printer().print(rsp);
System.out.printf("Receive QotGetValuationDetail: %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=7459213545847524693
Send Qot_GetValuationDetail: 2
Receive Qot_GetValuationDetail: retType: 0
retMsg: ""
errCode: 0
s2c {
valuationType: ValuationType_PE
lastUpdateTime: 1778415095
lastUpdateTimeStr: "2026-05-10 20:11:35"
trend {
currentValue: 17.266
averageValue: 22.499
avgMinus1Stddev: 20.043
avgPlus1Stddev: 24.955
valuationPercentile: 1.2195121
forwardValue: 15.449
historicalItems {
value: 22.69
time: 1746979200
timeStr: "2025-05-12"
plateValue: 22.678
}
historicalItems {
//...
}
}
//...
}
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
Futu::u32_t GetValuationDetail(const Qot_GetValuationDetail::Request &stReq);
virtual void OnReply_GetValuationDetail(Futu::u32_t nSerialNo, const Qot_GetValuationDetail::Response &stRsp) = 0;
介绍
获取个股/指数估值详情
参数
message C2S
{
required Qot_Common.Security security = 1; // 股票
optional Qot_Common.ValuationType valuationType = 2; // 估值类型,详见 Qot_Common.ValuationType 定义,默认 0(Unknown,使用推荐类型)
optional Qot_Common.ValuationIntervalType intervalType = 3; // 历史数据时间周期,详见 Qot_Common.ValuationIntervalType 定义
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 股票结构参见 Security
- 估值类型参见 ValuationType
- 估值历史区间类型参见 ValuationIntervalType
- 返回
// 走势
message ValuationTrend
{
message ValuationHistoricalItem
{
optional double value = 1; // 估值
optional uint64 time = 2; // 时间戳(秒)
optional string timeStr = 3; // 时间字符串,格式 YYYY-MM-DD,对应市场时区
optional double plateValue = 4; // 行业均值
}
optional double currentValue = 1; // 当前估值
optional double averageValue = 2; // 历史平均估值
optional double avgMinus1Stddev = 3; // 历史平均 - 1σ
optional double avgPlus1Stddev = 4; // 历史平均 + 1σ
optional double valuationPercentile = 5; // 估值历史分位,百分号前的值,如 12.34 表示 12.34%
optional double forwardValue = 6; // 预测估值,仅 PE / PS 有
repeated ValuationHistoricalItem historicalItems = 7; // 历史数据
}
// 市场分布
message MarketDistribution
{
message DistributionSection
{
optional double start = 1; // 区间开始值
optional double end = 2; // 区间结束值(0 表示无上限)
optional int32 number = 3; // 该区间个股数量
}
repeated DistributionSection sections = 1; // 区间分布(降序)
optional int32 total = 2; // 市场总数 / 成分股总数
optional int32 ranking = 3; // 该股票估值在市场中的排名(指数无)
optional double averageValue = 4; // 市场估值均值(指数无)
optional double medianValue = 5; // 市场估值中位数(指数无)
}
// 行业分布
message PlateDistribution
{
message PlateStockItem
{
optional Qot_Common.Security security = 1; // 股票
optional string name = 2; // 个股名称
optional double value = 3; // 估值
optional double marketCap = 4; // 市值
}
optional Qot_Common.Security plate = 1; // 所属板块
optional string plateName = 2; // 所属板块名称
optional double plateAverageValue = 3; // 板块估值均值
optional int32 plateRanking = 4; // 该股票估值在板块中的排名
optional int32 plateStockItemCount = 5; // 板块个股总数
repeated PlateStockItem stockItems = 6; // 板块成分股估值明细
}
// 盈利 / 营收增速
message ProfitGrowthRate
{
message ProfitGrowthItem
{
optional uint32 financialYear = 1; // 财报年度
optional uint32 financialQuarter = 2; // 财报季度(1=Q1, 2=Q2, 3=Q3, 4=FY)
optional string periodStr = 3; // 财报周期,如 "2024/Q3"、"2024/FY"
optional int64 reportDate = 4; // 报告日时间戳(秒)
optional string reportDateStr = 5; // 报告日字符串,格式 YYYY-MM-DD,对应市场时区
optional double marketCapMultiple = 6; // 报告日市值倍数(基准期 = 1)
optional double financeDataMultiple = 7; // 盈利 / 营收倍数(基准期 = 1,依 valuationType 而定)
}
optional double financialTtmMultiple = 1; // TTM 增长倍数
optional double marketCapMultiple = 2; // 市值增长倍数
optional int32 yearCount = 3; // 计算增长倍数时实际用到的年份数量
repeated ProfitGrowthItem profitData = 4; // 各期数据
optional string conclusionDetailed = 5; // 估值结论描述(已多语言翻译)
}
message S2C
{
optional Qot_Common.ValuationType valuationType = 1; // 实际返回的估值类型,详见 Qot_Common.ValuationType 定义
optional uint64 lastUpdateTime = 2; // 最后更新时间戳(秒)
optional string lastUpdateTimeStr = 3; // 最后更新时间字符串,格式 YYYY-MM-DD HH:MM:SS,对应市场时区
optional ValuationTrend trend = 4; // 走势(个股 + 指数)
optional MarketDistribution marketDistribution = 5; // 市场分布 / 成分股分布(个股 + 指数)
optional PlateDistribution plateDistribution = 6; // 行业分布(仅个股)
optional ProfitGrowthRate profitGrowthRate = 7; // 盈利 / 营收增速(仅个股,PB 无)
}
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
- 接口调用结果,结构参见 RetType
- 估值类型参见 ValuationType
- 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_GetValuationDetail::Request req;
Qot_GetValuationDetail::C2S *c2s = req.mutable_c2s();
Qot_Common::Security *sec = c2s->mutable_security();
sec->set_code("00700");
sec->set_market(Qot_Common::QotMarket::QotMarket_HK_Security);
m_pQotApi->GetValuationDetail(req);
cout << "GetValuationDetail" << endl;
}
virtual void OnReply_GetValuationDetail(Futu::u32_t nSerialNo, const Qot_GetValuationDetail::Response &stRsp){
cout << "OnReply_GetValuationDetail:" << 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_GetValuationDetail seqNo=3
retType: 0
retMsg: ""
errCode: 0
s2c {
valuationType: ValuationType_PE
lastUpdateTime: 1778415093
lastUpdateTimeStr: "2026-05-10 20:11:33"
trend {
currentValue: 17.266
averageValue: 22.499
avgMinus1Stddev: 20.043
avgPlus1Stddev: 24.955
valuationPercentile: 1.2195121
forwardValue: 15.449
historicalItems {
value: 22.69
time: 1746979200
timeStr: "2025-05-12"
plateValue: 22.678
}
historicalItems {
//...
}
}
//...
}
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
GetValuationDetail(req);
介绍
获取个股/指数估值详情
参数
message C2S
{
required Qot_Common.Security security = 1; // 股票
optional Qot_Common.ValuationType valuationType = 2; // 估值类型,详见 Qot_Common.ValuationType 定义,默认 0(Unknown,使用推荐类型)
optional Qot_Common.ValuationIntervalType intervalType = 3; // 历史数据时间周期,详见 Qot_Common.ValuationIntervalType 定义
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 股票结构参见 Security
- 估值类型参见 ValuationType
- 估值历史区间类型参见 ValuationIntervalType
- 返回
// 走势
message ValuationTrend
{
message ValuationHistoricalItem
{
optional double value = 1; // 估值
optional uint64 time = 2; // 时间戳(秒)
optional string timeStr = 3; // 时间字符串,格式 YYYY-MM-DD,对应市场时区
optional double plateValue = 4; // 行业均值
}
optional double currentValue = 1; // 当前估值
optional double averageValue = 2; // 历史平均估值
optional double avgMinus1Stddev = 3; // 历史平均 - 1σ
optional double avgPlus1Stddev = 4; // 历史平均 + 1σ
optional double valuationPercentile = 5; // 估值历史分位,百分号前的值,如 12.34 表示 12.34%
optional double forwardValue = 6; // 预测估值,仅 PE / PS 有
repeated ValuationHistoricalItem historicalItems = 7; // 历史数据
}
// 市场分布
message MarketDistribution
{
message DistributionSection
{
optional double start = 1; // 区间开始值
optional double end = 2; // 区间结束值(0 表示无上限)
optional int32 number = 3; // 该区间个股数量
}
repeated DistributionSection sections = 1; // 区间分布(降序)
optional int32 total = 2; // 市场总数 / 成分股总数
optional int32 ranking = 3; // 该股票估值在市场中的排名(指数无)
optional double averageValue = 4; // 市场估值均值(指数无)
optional double medianValue = 5; // 市场估值中位数(指数无)
}
// 行业分布
message PlateDistribution
{
message PlateStockItem
{
optional Qot_Common.Security security = 1; // 股票
optional string name = 2; // 个股名称
optional double value = 3; // 估值
optional double marketCap = 4; // 市值
}
optional Qot_Common.Security plate = 1; // 所属板块
optional string plateName = 2; // 所属板块名称
optional double plateAverageValue = 3; // 板块估值均值
optional int32 plateRanking = 4; // 该股票估值在板块中的排名
optional int32 plateStockItemCount = 5; // 板块个股总数
repeated PlateStockItem stockItems = 6; // 板块成分股估值明细
}
// 盈利 / 营收增速
message ProfitGrowthRate
{
message ProfitGrowthItem
{
optional uint32 financialYear = 1; // 财报年度
optional uint32 financialQuarter = 2; // 财报季度(1=Q1, 2=Q2, 3=Q3, 4=FY)
optional string periodStr = 3; // 财报周期,如 "2024/Q3"、"2024/FY"
optional int64 reportDate = 4; // 报告日时间戳(秒)
optional string reportDateStr = 5; // 报告日字符串,格式 YYYY-MM-DD,对应市场时区
optional double marketCapMultiple = 6; // 报告日市值倍数(基准期 = 1)
optional double financeDataMultiple = 7; // 盈利 / 营收倍数(基准期 = 1,依 valuationType 而定)
}
optional double financialTtmMultiple = 1; // TTM 增长倍数
optional double marketCapMultiple = 2; // 市值增长倍数
optional int32 yearCount = 3; // 计算增长倍数时实际用到的年份数量
repeated ProfitGrowthItem profitData = 4; // 各期数据
optional string conclusionDetailed = 5; // 估值结论描述(已多语言翻译)
}
message S2C
{
optional Qot_Common.ValuationType valuationType = 1; // 实际返回的估值类型,详见 Qot_Common.ValuationType 定义
optional uint64 lastUpdateTime = 2; // 最后更新时间戳(秒)
optional string lastUpdateTimeStr = 3; // 最后更新时间字符串,格式 YYYY-MM-DD HH:MM:SS,对应市场时区
optional ValuationTrend trend = 4; // 走势(个股 + 指数)
optional MarketDistribution marketDistribution = 5; // 市场分布 / 成分股分布(个股 + 指数)
optional PlateDistribution plateDistribution = 6; // 行业分布(仅个股)
optional ProfitGrowthRate profitGrowthRate = 7; // 盈利 / 营收增速(仅个股,PB 无)
}
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
- 接口调用结果,结构参见 RetType
- 估值类型参见 ValuationType
- Example
import ftWebsocket from "futu-api";
import { Common, Qot_Common } from "futu-api/proto";
import beautify from "js-beautify";
function QotGetValuationDetail(){
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: "00700",
},
},
};
websocket.GetValuationDetail(req)
.then((res) => {
let { errCode, retMsg, retType,s2c } = res
console.log("GetValuationDetail: 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
GetValuationDetail: errCode 0, retMsg , retType 0
{
"valuationType": "ValuationType_PE",
"lastUpdateTime": "1778421956",
"lastUpdateTimeStr": "2026-05-10 22:05:56",
"trend": {
"currentValue": 17.266,
"averageValue": 22.499,
"avgMinus1Stddev": 20.043,
"avgPlus1Stddev": 24.955,
"valuationPercentile": 1.2195121,
"forwardValue": 15.449,
"historicalItems": [{
"value": 22.69,
"time": "1746979200",
"timeStr": "2025-05-12",
"plateValue": 22.678
//...
}]
},
//...
}
stop
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
接口限制
- 每 30 秒内最多请求 30 次。
- 支持正股、基金及指数。
- PB 估值无盈利/营收增速模块。
- 指数无排名、均值、中位数。
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_valuation_detail(code, valuation_type=None, interval_type=None)
介绍
获取指定股票或指数的估值详情,包含估值走势、市场分布、行业分布(仅个股)、盈利/营收增速(仅个股,PB 无)
参数
参数 类型 说明 code str 股票代码 valuation_type ValuationType 估值类型 0=Unknown(使用推荐类型),1=PE(市盈率),2=PB(市净率),3=PS(市销率);默认 None(使用推荐类型)interval_type ValuationIntervalType 历史数据时间周期 0=Unknown,1=Month3,2=Month6,3=Year1,4=Year3,5=Since2019,6=Year5,7=Year10,8=Year2,9=Year20,10=Year30;默认 None返回
参数 类型 说明 ret RET_CODE 接口调用结果 data dict 当 ret == RET_OK,返回估值详情数据字典 str 当 ret != RET_OK,返回错误描述 返回字典包含以下字段:
字段 类型 说明 valuation_type ValuationType 实际估值类型 0=Unknown,1=PE,2=PB,3=PSlast_update_time int 最后更新时间戳(秒,对应市场时区) last_update_time_str str 最后更新时间 格式 YYYY-MM-DD HH:MM:SS,对应市场时区trend dict 走势数据,见 trend 字段表 market_distribution dict 市场分布数据,见 market_distribution 字段表 plate_distribution dict 行业分布数据,见 plate_distribution 字段表 仅个股返回profit_growth_rate dict 盈利/营收增速数据,见 profit_growth_rate 字段表 仅个股返回,PB 估值无此字段trend 字段(估值走势摘要):
字段 类型 说明 current_value float 当前估值 average_value float 历史平均估值 avg_minus_1_stddev float 历史平均 - 1σ avg_plus_1_stddev float 历史平均 + 1σ valuation_percentile float 历史分位 百分号前的值,如 12.34 表示 12.34%forward_value float 预测估值 仅 PE / PS 有historical_items list 历史估值列表,每项见 historical_items 字段表 historical_items 字段(历史估值条目):
字段 类型 说明 value float 估值 time int 时间戳(秒,对应市场时区) time_str str 日期 格式 YYYY-MM-DD,对应市场时区plate_value float 行业均值 market_distribution 字段(市场/成分股分布):
字段 类型 说明 sections list 区间分布列表(降序),每项见 sections 字段表 total int 市场总数/成分股总数 ranking int 该股票估值在市场中的排名 指数无此字段average_value float 市场估值均值 指数无此字段median_value float 市场估值中位数 指数无此字段sections 字段(区间分布条目):
字段 类型 说明 start float 区间开始值 end float 区间结束值 0 表示无上限number int 该区间个股数量 plate_distribution 字段(行业分布,仅个股):
字段 类型 说明 plate str 所属板块代码 plate_name str 所属板块名称 plate_average_value float 板块估值均值 plate_ranking int 该股票估值在板块中的排名 plate_stock_item_count int 板块个股总数 stock_items list 板块成分股估值明细,每项见 stock_items 字段表 stock_items 字段(板块成分股条目):
字段 类型 说明 security str 股票代码 name str 个股名称 value float 估值 market_cap float 市值 profit_growth_rate 字段(盈利/营收增速,仅个股非 PB):
字段 类型 说明 financial_ttm_multiple float TTM 增长倍数 market_cap_multiple float 市值增长倍数 year_count int 计算增长倍数时实际用到的年份数量 profit_data list 各期数据列表,每项见 profit_data 字段表 conclusion_detailed str 估值结论描述 profit_data 字段(各期盈利/营收条目):
字段 类型 说明 financial_year int 财报年度 financial_quarter int 财报季度 1=Q1,2=Q2,3=Q3,4=FYperiod_str str 财报周期 如 "2024/Q3"、"2024/FY"report_date int 报告日时间戳(秒,对应市场时区) report_date_str str 报告日 格式 YYYY-MM-DD,对应市场时区market_cap_multiple float 报告日市值倍数 基准期 = 1finance_data_multiple float 盈利/营收倍数 基准期 = 1,依 valuation_type 而定
Example
from moomoo import *
import pandas as pd
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data = quote_ctx.get_valuation_detail("HK.00700")
if ret == RET_OK:
trend = data.get('trend', {})
items = trend.get('historical_items', [])
df = pd.DataFrame(items)
print(df.to_string(index=False))
else:
print('error:', data)
quote_ctx.close()
2
3
4
5
6
7
8
9
10
11
12
- Output
value time time_str plate_value
22.690 1746979200 2025-05-12 22.678
22.186 1747065600 2025-05-13 22.179
22.843 1747152000 2025-05-14 22.817
22.046 1747238400 2025-05-15 22.050
21.538 1747324800 2025-05-16 21.577
21.792 1747584000 2025-05-19 21.821
//...
18.087 1776960000 2026-04-24 18.147
17.544 1777219200 2026-04-27 17.617
17.368 1777305600 2026-04-28 17.444
17.566 1777392000 2026-04-29 17.650
17.148 1777478400 2026-04-30 17.227
17.339 1777824000 2026-05-04 17.421
17.310 1777910400 2026-05-05 17.393
16.972 1777996800 2026-05-06 17.059
17.500 1778083200 2026-05-07 17.589
17.266 1778169600 2026-05-08 17.364
17.039 1778428800 2026-05-11 17.143
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Qot_GetValuationDetail.proto
介绍
获取个股/指数估值详情
参数
message C2S
{
required Qot_Common.Security security = 1; // 股票
optional Qot_Common.ValuationType valuationType = 2; // 估值类型,详见 Qot_Common.ValuationType 定义,默认 0(Unknown,使用推荐类型)
optional Qot_Common.ValuationIntervalType intervalType = 3; // 历史数据时间周期,详见 Qot_Common.ValuationIntervalType 定义
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 股票结构参见 Security
- ValuationType:0=Unknown,1=PE,2=PB,3=PS
- ValuationIntervalType:0=Unknown,1=Month3,2=Month6,3=Year1,4=Year3,5=Since2019,6=Year5,7=Year10,8=Year2,9=Year20,10=Year30
- 返回
// 走势
message ValuationTrend
{
message ValuationHistoricalItem
{
optional double value = 1; // 估值
optional uint64 time = 2; // 时间戳(秒)
optional string timeStr = 3; // 时间字符串,格式 YYYY-MM-DD,对应市场时区
optional double plateValue = 4; // 行业均值
}
optional double currentValue = 1; // 当前估值
optional double averageValue = 2; // 历史平均估值
optional double avgMinus1Stddev = 3; // 历史平均 - 1σ
optional double avgPlus1Stddev = 4; // 历史平均 + 1σ
optional double valuationPercentile = 5; // 估值历史分位,百分号前的值,如 12.34 表示 12.34%
optional double forwardValue = 6; // 预测估值,仅 PE / PS 有
repeated ValuationHistoricalItem historicalItems = 7; // 历史数据
}
// 市场分布
message MarketDistribution
{
message DistributionSection
{
optional double start = 1; // 区间开始值
optional double end = 2; // 区间结束值(0 表示无上限)
optional int32 number = 3; // 该区间个股数量
}
repeated DistributionSection sections = 1; // 区间分布(降序)
optional int32 total = 2; // 市场总数 / 成分股总数
optional int32 ranking = 3; // 该股票估值在市场中的排名(指数无)
optional double averageValue = 4; // 市场估值均值(指数无)
optional double medianValue = 5; // 市场估值中位数(指数无)
}
// 行业分布
message PlateDistribution
{
message PlateStockItem
{
optional Qot_Common.Security security = 1; // 股票
optional string name = 2; // 个股名称
optional double value = 3; // 估值
optional double marketCap = 4; // 市值
}
optional Qot_Common.Security plate = 1; // 所属板块
optional string plateName = 2; // 所属板块名称
optional double plateAverageValue = 3; // 板块估值均值
optional int32 plateRanking = 4; // 该股票估值在板块中的排名
optional int32 plateStockItemCount = 5; // 板块个股总数
repeated PlateStockItem stockItems = 6; // 板块成分股估值明细
}
// 盈利 / 营收增速
message ProfitGrowthRate
{
message ProfitGrowthItem
{
optional uint32 financialYear = 1; // 财报年度
optional uint32 financialQuarter = 2; // 财报季度(1=Q1, 2=Q2, 3=Q3, 4=FY)
optional string periodStr = 3; // 财报周期,如 "2024/Q3"、"2024/FY"
optional int64 reportDate = 4; // 报告日时间戳(秒)
optional string reportDateStr = 5; // 报告日字符串,格式 YYYY-MM-DD,对应市场时区
optional double marketCapMultiple = 6; // 报告日市值倍数(基准期 = 1)
optional double financeDataMultiple = 7; // 盈利 / 营收倍数(基准期 = 1,依 valuationType 而定)
}
optional double financialTtmMultiple = 1; // TTM 增长倍数
optional double marketCapMultiple = 2; // 市值增长倍数
optional int32 yearCount = 3; // 计算增长倍数时实际用到的年份数量
repeated ProfitGrowthItem profitData = 4; // 各期数据
optional string conclusionDetailed = 5; // 估值结论描述(已多语言翻译)
}
message S2C
{
optional Qot_Common.ValuationType valuationType = 1; // 实际返回的估值类型,详见 Qot_Common.ValuationType 定义
optional uint64 lastUpdateTime = 2; // 最后更新时间戳(秒)
optional string lastUpdateTimeStr = 3; // 最后更新时间字符串,格式 YYYY-MM-DD HH:MM:SS,对应市场时区
optional ValuationTrend trend = 4; // 走势(个股 + 指数)
optional MarketDistribution marketDistribution = 5; // 市场分布 / 成分股分布(个股 + 指数)
optional PlateDistribution plateDistribution = 6; // 行业分布(仅个股)
optional ProfitGrowthRate profitGrowthRate = 7; // 盈利 / 营收增速(仅个股,PB 无)
}
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
- 接口调用结果,结构参见 RetType
- 估值类型参见 ValuationType
协议 ID
3232
uint GetValuationDetail(QotGetValuationDetail.Request req);
virtual void OnReply_GetValuationDetail(MMAPI_Conn client, uint nSerialNo, QotGetValuationDetail.Response rsp);
介绍
获取个股/指数估值详情
参数
message C2S
{
required Qot_Common.Security security = 1; // 股票
optional Qot_Common.ValuationType valuationType = 2; // 估值类型,详见 Qot_Common.ValuationType 定义,默认 0(Unknown,使用推荐类型)
optional Qot_Common.ValuationIntervalType intervalType = 3; // 历史数据时间周期,详见 Qot_Common.ValuationIntervalType 定义
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 股票结构参见 Security
- 估值类型参见 ValuationType
- 估值历史区间类型参见 ValuationIntervalType
- 返回
// 走势
message ValuationTrend
{
message ValuationHistoricalItem
{
optional double value = 1; // 估值
optional uint64 time = 2; // 时间戳(秒)
optional string timeStr = 3; // 时间字符串,格式 YYYY-MM-DD,对应市场时区
optional double plateValue = 4; // 行业均值
}
optional double currentValue = 1; // 当前估值
optional double averageValue = 2; // 历史平均估值
optional double avgMinus1Stddev = 3; // 历史平均 - 1σ
optional double avgPlus1Stddev = 4; // 历史平均 + 1σ
optional double valuationPercentile = 5; // 估值历史分位,百分号前的值,如 12.34 表示 12.34%
optional double forwardValue = 6; // 预测估值,仅 PE / PS 有
repeated ValuationHistoricalItem historicalItems = 7; // 历史数据
}
// 市场分布
message MarketDistribution
{
message DistributionSection
{
optional double start = 1; // 区间开始值
optional double end = 2; // 区间结束值(0 表示无上限)
optional int32 number = 3; // 该区间个股数量
}
repeated DistributionSection sections = 1; // 区间分布(降序)
optional int32 total = 2; // 市场总数 / 成分股总数
optional int32 ranking = 3; // 该股票估值在市场中的排名(指数无)
optional double averageValue = 4; // 市场估值均值(指数无)
optional double medianValue = 5; // 市场估值中位数(指数无)
}
// 行业分布
message PlateDistribution
{
message PlateStockItem
{
optional Qot_Common.Security security = 1; // 股票
optional string name = 2; // 个股名称
optional double value = 3; // 估值
optional double marketCap = 4; // 市值
}
optional Qot_Common.Security plate = 1; // 所属板块
optional string plateName = 2; // 所属板块名称
optional double plateAverageValue = 3; // 板块估值均值
optional int32 plateRanking = 4; // 该股票估值在板块中的排名
optional int32 plateStockItemCount = 5; // 板块个股总数
repeated PlateStockItem stockItems = 6; // 板块成分股估值明细
}
// 盈利 / 营收增速
message ProfitGrowthRate
{
message ProfitGrowthItem
{
optional uint32 financialYear = 1; // 财报年度
optional uint32 financialQuarter = 2; // 财报季度(1=Q1, 2=Q2, 3=Q3, 4=FY)
optional string periodStr = 3; // 财报周期,如 "2024/Q3"、"2024/FY"
optional int64 reportDate = 4; // 报告日时间戳(秒)
optional string reportDateStr = 5; // 报告日字符串,格式 YYYY-MM-DD,对应市场时区
optional double marketCapMultiple = 6; // 报告日市值倍数(基准期 = 1)
optional double financeDataMultiple = 7; // 盈利 / 营收倍数(基准期 = 1,依 valuationType 而定)
}
optional double financialTtmMultiple = 1; // TTM 增长倍数
optional double marketCapMultiple = 2; // 市值增长倍数
optional int32 yearCount = 3; // 计算增长倍数时实际用到的年份数量
repeated ProfitGrowthItem profitData = 4; // 各期数据
optional string conclusionDetailed = 5; // 估值结论描述(已多语言翻译)
}
message S2C
{
optional Qot_Common.ValuationType valuationType = 1; // 实际返回的估值类型,详见 Qot_Common.ValuationType 定义
optional uint64 lastUpdateTime = 2; // 最后更新时间戳(秒)
optional string lastUpdateTimeStr = 3; // 最后更新时间字符串,格式 YYYY-MM-DD HH:MM:SS,对应市场时区
optional ValuationTrend trend = 4; // 走势(个股 + 指数)
optional MarketDistribution marketDistribution = 5; // 市场分布 / 成分股分布(个股 + 指数)
optional PlateDistribution plateDistribution = 6; // 行业分布(仅个股)
optional ProfitGrowthRate profitGrowthRate = 7; // 盈利 / 营收增速(仅个股,PB 无)
}
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
- 接口调用结果,结构参见 RetType
- 估值类型参见 ValuationType
- 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("00700")
.Build();
QotGetValuationDetail.C2S c2s = QotGetValuationDetail.C2S.CreateBuilder()
.SetSecurity(sec)
.Build();
QotGetValuationDetail.Request req = QotGetValuationDetail.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetValuationDetail(req);
Console.Write("Send QotGetValuationDetail: {0}\n", seqNo);
}
public void OnDisconnect(MMAPI_Conn client, long errCode)
{
Console.Write("Qot onDisConnect: {0}\n", errCode);
}
public void OnReply_GetValuationDetail(MMAPI_Conn client, uint nSerialNo, QotGetValuationDetail.Response rsp)
{
Console.Write("Reply: QotGetValuationDetail: {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 {
valuationType: ValuationType_PE
lastUpdateTime: 1778415094
lastUpdateTimeStr: "2026-05-10 20:11:34"
trend {
currentValue: 17.266
averageValue: 22.499
avgMinus1Stddev: 20.043
avgPlus1Stddev: 24.955
valuationPercentile: 1.2195121
forwardValue: 15.449
historicalItems {
value: 22.69
time: 1746979200
timeStr: "2025-05-12"
plateValue: 22.678
}
historicalItems {
//...
}
}
//...
}
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
int getValuationDetail(QotGetValuationDetail.Request req);
void onReply_GetValuationDetail(MMAPI_Conn client, int nSerialNo, QotGetValuationDetail.Response rsp);
介绍
获取个股/指数估值详情
参数
message C2S
{
required Qot_Common.Security security = 1; // 股票
optional Qot_Common.ValuationType valuationType = 2; // 估值类型,详见 Qot_Common.ValuationType 定义,默认 0(Unknown,使用推荐类型)
optional Qot_Common.ValuationIntervalType intervalType = 3; // 历史数据时间周期,详见 Qot_Common.ValuationIntervalType 定义
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 股票结构参见 Security
- 估值类型参见 ValuationType
- 估值历史区间类型参见 ValuationIntervalType
- 返回
// 走势
message ValuationTrend
{
message ValuationHistoricalItem
{
optional double value = 1; // 估值
optional uint64 time = 2; // 时间戳(秒)
optional string timeStr = 3; // 时间字符串,格式 YYYY-MM-DD,对应市场时区
optional double plateValue = 4; // 行业均值
}
optional double currentValue = 1; // 当前估值
optional double averageValue = 2; // 历史平均估值
optional double avgMinus1Stddev = 3; // 历史平均 - 1σ
optional double avgPlus1Stddev = 4; // 历史平均 + 1σ
optional double valuationPercentile = 5; // 估值历史分位,百分号前的值,如 12.34 表示 12.34%
optional double forwardValue = 6; // 预测估值,仅 PE / PS 有
repeated ValuationHistoricalItem historicalItems = 7; // 历史数据
}
// 市场分布
message MarketDistribution
{
message DistributionSection
{
optional double start = 1; // 区间开始值
optional double end = 2; // 区间结束值(0 表示无上限)
optional int32 number = 3; // 该区间个股数量
}
repeated DistributionSection sections = 1; // 区间分布(降序)
optional int32 total = 2; // 市场总数 / 成分股总数
optional int32 ranking = 3; // 该股票估值在市场中的排名(指数无)
optional double averageValue = 4; // 市场估值均值(指数无)
optional double medianValue = 5; // 市场估值中位数(指数无)
}
// 行业分布
message PlateDistribution
{
message PlateStockItem
{
optional Qot_Common.Security security = 1; // 股票
optional string name = 2; // 个股名称
optional double value = 3; // 估值
optional double marketCap = 4; // 市值
}
optional Qot_Common.Security plate = 1; // 所属板块
optional string plateName = 2; // 所属板块名称
optional double plateAverageValue = 3; // 板块估值均值
optional int32 plateRanking = 4; // 该股票估值在板块中的排名
optional int32 plateStockItemCount = 5; // 板块个股总数
repeated PlateStockItem stockItems = 6; // 板块成分股估值明细
}
// 盈利 / 营收增速
message ProfitGrowthRate
{
message ProfitGrowthItem
{
optional uint32 financialYear = 1; // 财报年度
optional uint32 financialQuarter = 2; // 财报季度(1=Q1, 2=Q2, 3=Q3, 4=FY)
optional string periodStr = 3; // 财报周期,如 "2024/Q3"、"2024/FY"
optional int64 reportDate = 4; // 报告日时间戳(秒)
optional string reportDateStr = 5; // 报告日字符串,格式 YYYY-MM-DD,对应市场时区
optional double marketCapMultiple = 6; // 报告日市值倍数(基准期 = 1)
optional double financeDataMultiple = 7; // 盈利 / 营收倍数(基准期 = 1,依 valuationType 而定)
}
optional double financialTtmMultiple = 1; // TTM 增长倍数
optional double marketCapMultiple = 2; // 市值增长倍数
optional int32 yearCount = 3; // 计算增长倍数时实际用到的年份数量
repeated ProfitGrowthItem profitData = 4; // 各期数据
optional string conclusionDetailed = 5; // 估值结论描述(已多语言翻译)
}
message S2C
{
optional Qot_Common.ValuationType valuationType = 1; // 实际返回的估值类型,详见 Qot_Common.ValuationType 定义
optional uint64 lastUpdateTime = 2; // 最后更新时间戳(秒)
optional string lastUpdateTimeStr = 3; // 最后更新时间字符串,格式 YYYY-MM-DD HH:MM:SS,对应市场时区
optional ValuationTrend trend = 4; // 走势(个股 + 指数)
optional MarketDistribution marketDistribution = 5; // 市场分布 / 成分股分布(个股 + 指数)
optional PlateDistribution plateDistribution = 6; // 行业分布(仅个股)
optional ProfitGrowthRate profitGrowthRate = 7; // 盈利 / 营收增速(仅个股,PB 无)
}
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
- 接口调用结果,结构参见 RetType
- 估值类型参见 ValuationType
- 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("00700")
.build();
QotGetValuationDetail.C2S c2s = QotGetValuationDetail.C2S.newBuilder()
.setSecurity(sec)
.build();
QotGetValuationDetail.Request req = QotGetValuationDetail.Request.newBuilder().setC2S(c2s).build();
int seqNo = qot.getValuationDetail(req);
System.out.printf("Send QotGetValuationDetail: %d\n", seqNo);
}
@Override
public void onDisconnect(MMAPI_Conn client, long errCode) {
System.out.printf("Qot onDisConnect: %d\n", errCode);
}
@Override
public void onReply_GetValuationDetail(MMAPI_Conn client, int nSerialNo, QotGetValuationDetail.Response rsp) {
if (rsp.getRetType() != 0) {
System.out.printf("QotGetValuationDetail failed: %s\n", rsp.getRetMsg());
}
else {
try {
String json = JsonFormat.printer().print(rsp);
System.out.printf("Receive QotGetValuationDetail: %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=7459213545847524693
Send Qot_GetValuationDetail: 2
Receive Qot_GetValuationDetail: retType: 0
retMsg: ""
errCode: 0
s2c {
valuationType: ValuationType_PE
lastUpdateTime: 1778415095
lastUpdateTimeStr: "2026-05-10 20:11:35"
trend {
currentValue: 17.266
averageValue: 22.499
avgMinus1Stddev: 20.043
avgPlus1Stddev: 24.955
valuationPercentile: 1.2195121
forwardValue: 15.449
historicalItems {
value: 22.69
time: 1746979200
timeStr: "2025-05-12"
plateValue: 22.678
}
historicalItems {
//...
}
}
//...
}
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
moomoo::u32_t GetValuationDetail(const Qot_GetValuationDetail::Request &stReq);
virtual void OnReply_GetValuationDetail(moomoo::u32_t nSerialNo, const Qot_GetValuationDetail::Response &stRsp) = 0;
介绍
获取个股/指数估值详情
参数
message C2S
{
required Qot_Common.Security security = 1; // 股票
optional Qot_Common.ValuationType valuationType = 2; // 估值类型,详见 Qot_Common.ValuationType 定义,默认 0(Unknown,使用推荐类型)
optional Qot_Common.ValuationIntervalType intervalType = 3; // 历史数据时间周期,详见 Qot_Common.ValuationIntervalType 定义
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 股票结构参见 Security
- 估值类型参见 ValuationType
- 估值历史区间类型参见 ValuationIntervalType
- 返回
// 走势
message ValuationTrend
{
message ValuationHistoricalItem
{
optional double value = 1; // 估值
optional uint64 time = 2; // 时间戳(秒)
optional string timeStr = 3; // 时间字符串,格式 YYYY-MM-DD,对应市场时区
optional double plateValue = 4; // 行业均值
}
optional double currentValue = 1; // 当前估值
optional double averageValue = 2; // 历史平均估值
optional double avgMinus1Stddev = 3; // 历史平均 - 1σ
optional double avgPlus1Stddev = 4; // 历史平均 + 1σ
optional double valuationPercentile = 5; // 估值历史分位,百分号前的值,如 12.34 表示 12.34%
optional double forwardValue = 6; // 预测估值,仅 PE / PS 有
repeated ValuationHistoricalItem historicalItems = 7; // 历史数据
}
// 市场分布
message MarketDistribution
{
message DistributionSection
{
optional double start = 1; // 区间开始值
optional double end = 2; // 区间结束值(0 表示无上限)
optional int32 number = 3; // 该区间个股数量
}
repeated DistributionSection sections = 1; // 区间分布(降序)
optional int32 total = 2; // 市场总数 / 成分股总数
optional int32 ranking = 3; // 该股票估值在市场中的排名(指数无)
optional double averageValue = 4; // 市场估值均值(指数无)
optional double medianValue = 5; // 市场估值中位数(指数无)
}
// 行业分布
message PlateDistribution
{
message PlateStockItem
{
optional Qot_Common.Security security = 1; // 股票
optional string name = 2; // 个股名称
optional double value = 3; // 估值
optional double marketCap = 4; // 市值
}
optional Qot_Common.Security plate = 1; // 所属板块
optional string plateName = 2; // 所属板块名称
optional double plateAverageValue = 3; // 板块估值均值
optional int32 plateRanking = 4; // 该股票估值在板块中的排名
optional int32 plateStockItemCount = 5; // 板块个股总数
repeated PlateStockItem stockItems = 6; // 板块成分股估值明细
}
// 盈利 / 营收增速
message ProfitGrowthRate
{
message ProfitGrowthItem
{
optional uint32 financialYear = 1; // 财报年度
optional uint32 financialQuarter = 2; // 财报季度(1=Q1, 2=Q2, 3=Q3, 4=FY)
optional string periodStr = 3; // 财报周期,如 "2024/Q3"、"2024/FY"
optional int64 reportDate = 4; // 报告日时间戳(秒)
optional string reportDateStr = 5; // 报告日字符串,格式 YYYY-MM-DD,对应市场时区
optional double marketCapMultiple = 6; // 报告日市值倍数(基准期 = 1)
optional double financeDataMultiple = 7; // 盈利 / 营收倍数(基准期 = 1,依 valuationType 而定)
}
optional double financialTtmMultiple = 1; // TTM 增长倍数
optional double marketCapMultiple = 2; // 市值增长倍数
optional int32 yearCount = 3; // 计算增长倍数时实际用到的年份数量
repeated ProfitGrowthItem profitData = 4; // 各期数据
optional string conclusionDetailed = 5; // 估值结论描述(已多语言翻译)
}
message S2C
{
optional Qot_Common.ValuationType valuationType = 1; // 实际返回的估值类型,详见 Qot_Common.ValuationType 定义
optional uint64 lastUpdateTime = 2; // 最后更新时间戳(秒)
optional string lastUpdateTimeStr = 3; // 最后更新时间字符串,格式 YYYY-MM-DD HH:MM:SS,对应市场时区
optional ValuationTrend trend = 4; // 走势(个股 + 指数)
optional MarketDistribution marketDistribution = 5; // 市场分布 / 成分股分布(个股 + 指数)
optional PlateDistribution plateDistribution = 6; // 行业分布(仅个股)
optional ProfitGrowthRate profitGrowthRate = 7; // 盈利 / 营收增速(仅个股,PB 无)
}
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
- 接口调用结果,结构参见 RetType
- 估值类型参见 ValuationType
- 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_GetValuationDetail::Request req;
Qot_GetValuationDetail::C2S *c2s = req.mutable_c2s();
Qot_Common::Security *sec = c2s->mutable_security();
sec->set_code("00700");
sec->set_market(Qot_Common::QotMarket::QotMarket_HK_Security);
m_pQotApi->GetValuationDetail(req);
cout << "GetValuationDetail" << endl;
}
virtual void OnReply_GetValuationDetail(moomoo::u32_t nSerialNo, const Qot_GetValuationDetail::Response &stRsp){
cout << "OnReply_GetValuationDetail:" << 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_GetValuationDetail seqNo=3
retType: 0
retMsg: ""
errCode: 0
s2c {
valuationType: ValuationType_PE
lastUpdateTime: 1778415093
lastUpdateTimeStr: "2026-05-10 20:11:33"
trend {
currentValue: 17.266
averageValue: 22.499
avgMinus1Stddev: 20.043
avgPlus1Stddev: 24.955
valuationPercentile: 1.2195121
forwardValue: 15.449
historicalItems {
value: 22.69
time: 1746979200
timeStr: "2025-05-12"
plateValue: 22.678
}
historicalItems {
//...
}
}
//...
}
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
GetValuationDetail(req);
介绍
获取个股/指数估值详情
参数
message C2S
{
required Qot_Common.Security security = 1; // 股票
optional Qot_Common.ValuationType valuationType = 2; // 估值类型,详见 Qot_Common.ValuationType 定义,默认 0(Unknown,使用推荐类型)
optional Qot_Common.ValuationIntervalType intervalType = 3; // 历史数据时间周期,详见 Qot_Common.ValuationIntervalType 定义
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 股票结构参见 Security
- 估值类型参见 ValuationType
- 估值历史区间类型参见 ValuationIntervalType
- 返回
// 走势
message ValuationTrend
{
message ValuationHistoricalItem
{
optional double value = 1; // 估值
optional uint64 time = 2; // 时间戳(秒)
optional string timeStr = 3; // 时间字符串,格式 YYYY-MM-DD,对应市场时区
optional double plateValue = 4; // 行业均值
}
optional double currentValue = 1; // 当前估值
optional double averageValue = 2; // 历史平均估值
optional double avgMinus1Stddev = 3; // 历史平均 - 1σ
optional double avgPlus1Stddev = 4; // 历史平均 + 1σ
optional double valuationPercentile = 5; // 估值历史分位,百分号前的值,如 12.34 表示 12.34%
optional double forwardValue = 6; // 预测估值,仅 PE / PS 有
repeated ValuationHistoricalItem historicalItems = 7; // 历史数据
}
// 市场分布
message MarketDistribution
{
message DistributionSection
{
optional double start = 1; // 区间开始值
optional double end = 2; // 区间结束值(0 表示无上限)
optional int32 number = 3; // 该区间个股数量
}
repeated DistributionSection sections = 1; // 区间分布(降序)
optional int32 total = 2; // 市场总数 / 成分股总数
optional int32 ranking = 3; // 该股票估值在市场中的排名(指数无)
optional double averageValue = 4; // 市场估值均值(指数无)
optional double medianValue = 5; // 市场估值中位数(指数无)
}
// 行业分布
message PlateDistribution
{
message PlateStockItem
{
optional Qot_Common.Security security = 1; // 股票
optional string name = 2; // 个股名称
optional double value = 3; // 估值
optional double marketCap = 4; // 市值
}
optional Qot_Common.Security plate = 1; // 所属板块
optional string plateName = 2; // 所属板块名称
optional double plateAverageValue = 3; // 板块估值均值
optional int32 plateRanking = 4; // 该股票估值在板块中的排名
optional int32 plateStockItemCount = 5; // 板块个股总数
repeated PlateStockItem stockItems = 6; // 板块成分股估值明细
}
// 盈利 / 营收增速
message ProfitGrowthRate
{
message ProfitGrowthItem
{
optional uint32 financialYear = 1; // 财报年度
optional uint32 financialQuarter = 2; // 财报季度(1=Q1, 2=Q2, 3=Q3, 4=FY)
optional string periodStr = 3; // 财报周期,如 "2024/Q3"、"2024/FY"
optional int64 reportDate = 4; // 报告日时间戳(秒)
optional string reportDateStr = 5; // 报告日字符串,格式 YYYY-MM-DD,对应市场时区
optional double marketCapMultiple = 6; // 报告日市值倍数(基准期 = 1)
optional double financeDataMultiple = 7; // 盈利 / 营收倍数(基准期 = 1,依 valuationType 而定)
}
optional double financialTtmMultiple = 1; // TTM 增长倍数
optional double marketCapMultiple = 2; // 市值增长倍数
optional int32 yearCount = 3; // 计算增长倍数时实际用到的年份数量
repeated ProfitGrowthItem profitData = 4; // 各期数据
optional string conclusionDetailed = 5; // 估值结论描述(已多语言翻译)
}
message S2C
{
optional Qot_Common.ValuationType valuationType = 1; // 实际返回的估值类型,详见 Qot_Common.ValuationType 定义
optional uint64 lastUpdateTime = 2; // 最后更新时间戳(秒)
optional string lastUpdateTimeStr = 3; // 最后更新时间字符串,格式 YYYY-MM-DD HH:MM:SS,对应市场时区
optional ValuationTrend trend = 4; // 走势(个股 + 指数)
optional MarketDistribution marketDistribution = 5; // 市场分布 / 成分股分布(个股 + 指数)
optional PlateDistribution plateDistribution = 6; // 行业分布(仅个股)
optional ProfitGrowthRate profitGrowthRate = 7; // 盈利 / 营收增速(仅个股,PB 无)
}
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
- 接口调用结果,结构参见 RetType
- 估值类型参见 ValuationType
- Example
import mmWebsocket from "moomoo-api";
import { Common, Qot_Common } from "moomoo-api/proto";
import beautify from "js-beautify";
function QotGetValuationDetail(){
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: "00700",
},
},
};
websocket.GetValuationDetail(req)
.then((res) => {
let { errCode, retMsg, retType,s2c } = res
console.log("GetValuationDetail: 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
GetValuationDetail: errCode 0, retMsg , retType 0
{
"valuationType": "ValuationType_PE",
"lastUpdateTime": "1778421956",
"lastUpdateTimeStr": "2026-05-10 22:05:56",
"trend": {
"currentValue": 17.266,
"averageValue": 22.499,
"avgMinus1Stddev": 20.043,
"avgPlus1Stddev": 24.955,
"valuationPercentile": 1.2195121,
"forwardValue": 15.449,
"historicalItems": [{
"value": 22.69,
"time": "1746979200",
"timeStr": "2025-05-12",
"plateValue": 22.678
//...
}]
},
//...
}
stop
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
接口限制
- 每 30 秒内最多请求 30 次。
- 支持正股、基金及指数。
- PB 估值无盈利/营收增速模块。
- 指数无排名、均值、中位数。