# Get Valuation Detail
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_valuation_detail(code, valuation_type=None, interval_type=None)
Description
Get valuation detail for the specified stock or index, including valuation trend, market distribution, sector distribution (stocks only), and earnings/revenue growth rate (stocks only, not available for PB)
Parameters
Parameter Type Description code str Stock code valuation_type ValuationType Valuation type 0=Unknown (use recommended type), 1=PE (Price-to-Earnings), 2=PB (Price-to-Book), 3=PS (Price-to-Sales); default None (use recommended type)interval_type ValuationIntervalType Historical data time interval 0=Unknown, 1=Month3, 2=Month6, 3=Year1, 4=Year3, 5=Since2019, 6=Year5, 7=Year10, 8=Year2, 9=Year20, 10=Year30; default NoneReturn
Parameter Type Description ret RET_CODE API call result data dict If ret == RET_OK, returns valuation detail data dict str If ret != RET_OK, returns error description The returned dict contains the following fields:
Field Type Description valuation_type ValuationType Actual valuation type 0=Unknown, 1=PE, 2=PB, 3=PSlast_update_time int Last update timestamp Seconds, in market timezonelast_update_time_str str Last update time Format YYYY-MM-DD HH:MM:SS, in market timezonetrend dict Valuation trend data, see trend field table market_distribution dict Market distribution data, see market_distribution field table plate_distribution dict Sector distribution data, see plate_distribution field table Stocks onlyprofit_growth_rate dict Earnings/revenue growth rate data, see profit_growth_rate field table Stocks only; not available for PB valuation typetrend fields (valuation trend summary):
Field Type Description current_value float Current valuation average_value float Historical average valuation avg_minus_1_stddev float Historical average - 1σ avg_plus_1_stddev float Historical average + 1σ valuation_percentile float Historical percentile Value before %, e.g. 12.34 means 12.34%forward_value float Forward valuation PE / PS onlyhistorical_items list Historical valuation list, each item see historical_items field table historical_items fields (historical valuation entry):
Field Type Description value float Valuation time int Timestamp Seconds, in market timezonetime_str str Date Format YYYY-MM-DD, in market timezoneplate_value float Sector average valuation market_distribution fields (market / constituent stock distribution):
Field Type Description sections list Distribution sections list (descending), each item see sections field table total int Total market count / constituent stock count ranking int Stock's valuation ranking in the market Not available for indexesaverage_value float Market average valuation Not available for indexesmedian_value float Market median valuation Not available for indexessections fields (distribution section entry):
Field Type Description start float Section start value end float Section end value 0 means no upper limitnumber int Number of stocks in this section plate_distribution fields (sector distribution, stocks only):
Field Type Description plate str Sector code plate_name str Sector name plate_average_value float Sector average valuation plate_ranking int Stock's valuation ranking within the sector plate_stock_item_count int Total stocks in the sector stock_items list Sector constituent stock valuation details, each item see stock_items field table stock_items fields (sector constituent stock entry):
Field Type Description security str Stock code name str Stock name value float Valuation market_cap float Market cap profit_growth_rate fields (earnings/revenue growth rate, stocks only, not PB):
Field Type Description financial_ttm_multiple float TTM growth multiple market_cap_multiple float Market cap growth multiple year_count int Number of years used to calculate growth multiple profit_data list Per-period data list, each item see profit_data field table conclusion_detailed str Valuation conclusion description profit_data fields (per-period earnings/revenue entry):
Field Type Description financial_year int Financial report year financial_quarter int Financial report quarter 1=Q1, 2=Q2, 3=Q3, 4=FYperiod_str str Financial report period e.g. "2024/Q3", "2024/FY"report_date int Report date timestamp Seconds, in market timezonereport_date_str str Report date Format YYYY-MM-DD, in market timezonemarket_cap_multiple float Market cap multiple on report date Base period = 1finance_data_multiple float Earnings/revenue multiple Base period = 1; depends on 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
Description
Get stock / index valuation detail
Parameters
message C2S
{
required Qot_Common.Security security = 1; // Stock
optional Qot_Common.ValuationType valuationType = 2; // Valuation type, refer to Qot_Common.ValuationType, default 0 (Unknown, use recommended type)
optional Qot_Common.ValuationIntervalType intervalType = 3; // Historical data time interval, refer to Qot_Common.ValuationIntervalType
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- Security structure, refer to 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
- Return
// Valuation trend
message ValuationTrend
{
message ValuationHistoricalItem
{
optional double value = 1; // Valuation
optional uint64 time = 2; // Timestamp (seconds)
optional string timeStr = 3; // Time string, format YYYY-MM-DD, in market timezone
optional double plateValue = 4; // Sector average valuation
}
optional double currentValue = 1; // Current valuation
optional double averageValue = 2; // Historical average valuation
optional double avgMinus1Stddev = 3; // Historical average - 1σ
optional double avgPlus1Stddev = 4; // Historical average + 1σ
optional double valuationPercentile = 5; // Historical percentile, value before %, e.g. 12.34 means 12.34%
optional double forwardValue = 6; // Forward valuation, PE / PS only
repeated ValuationHistoricalItem historicalItems = 7; // Historical data
}
// Market distribution
message MarketDistribution
{
message DistributionSection
{
optional double start = 1; // Section start value
optional double end = 2; // Section end value (0 means no upper limit)
optional int32 number = 3; // Number of stocks in this section
}
repeated DistributionSection sections = 1; // Distribution sections (descending)
optional int32 total = 2; // Total market count / constituent stock count
optional int32 ranking = 3; // Stock's valuation ranking in the market (not available for indexes)
optional double averageValue = 4; // Market average valuation (not available for indexes)
optional double medianValue = 5; // Market median valuation (not available for indexes)
}
// Sector distribution
message PlateDistribution
{
message PlateStockItem
{
optional Qot_Common.Security security = 1; // Stock
optional string name = 2; // Stock name
optional double value = 3; // Valuation
optional double marketCap = 4; // Market cap
}
optional Qot_Common.Security plate = 1; // Sector
optional string plateName = 2; // Sector name
optional double plateAverageValue = 3; // Sector average valuation
optional int32 plateRanking = 4; // Stock's valuation ranking within the sector
optional int32 plateStockItemCount = 5; // Total stocks in the sector
repeated PlateStockItem stockItems = 6; // Sector constituent stock valuation details
}
// Earnings / revenue growth rate
message ProfitGrowthRate
{
message ProfitGrowthItem
{
optional uint32 financialYear = 1; // Financial report year
optional uint32 financialQuarter = 2; // Financial report quarter (1=Q1, 2=Q2, 3=Q3, 4=FY)
optional string periodStr = 3; // Financial report period, e.g. "2024/Q3", "2024/FY"
optional int64 reportDate = 4; // Report date timestamp (seconds)
optional string reportDateStr = 5; // Report date string, format YYYY-MM-DD, in market timezone
optional double marketCapMultiple = 6; // Market cap multiple on report date (base period = 1)
optional double financeDataMultiple = 7; // Earnings / revenue multiple (base period = 1, depends on valuationType)
}
optional double financialTtmMultiple = 1; // TTM growth multiple
optional double marketCapMultiple = 2; // Market cap growth multiple
optional int32 yearCount = 3; // Number of years used to calculate growth multiple
repeated ProfitGrowthItem profitData = 4; // Per-period data
optional string conclusionDetailed = 5; // Valuation conclusion description (multi-language translated)
}
message S2C
{
optional Qot_Common.ValuationType valuationType = 1; // Actual returned valuation type, refer to Qot_Common.ValuationType
optional uint64 lastUpdateTime = 2; // Last update timestamp (seconds)
optional string lastUpdateTimeStr = 3; // Last update time string, format YYYY-MM-DD HH:MM:SS, in market timezone
optional ValuationTrend trend = 4; // Valuation trend (stocks + indexes)
optional MarketDistribution marketDistribution = 5; // Market distribution / constituent stock distribution (stocks + indexes)
optional PlateDistribution plateDistribution = 6; // Sector distribution (stocks only)
optional ProfitGrowthRate profitGrowthRate = 7; // Earnings / revenue growth rate (stocks only, not available for PB)
}
message Response
{
required int32 retType = 1 [default = -400]; // Return result, refer to Common.RetType
optional string retMsg = 2; // Return result description
optional int32 errCode = 3; // Error code
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
- API call result, refer to RetType
Protocol ID
3232
uint GetValuationDetail(QotGetValuationDetail.Request req);
virtual void OnReply_GetValuationDetail(FTAPI_Conn client, uint nSerialNo, QotGetValuationDetail.Response rsp);
Description
Get stock / index valuation detail
Parameters
message C2S
{
required Qot_Common.Security security = 1; // Stock
optional Qot_Common.ValuationType valuationType = 2; // Valuation type, refer to Qot_Common.ValuationType, default 0 (Unknown, use recommended type)
optional Qot_Common.ValuationIntervalType intervalType = 3; // Historical data time interval, refer to Qot_Common.ValuationIntervalType
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- Security structure, refer to Security
- Valuation type refer to ValuationType
- Valuation history interval type refer to ValuationIntervalType
- Return
// Valuation trend
message ValuationTrend
{
message ValuationHistoricalItem
{
optional double value = 1; // Valuation
optional uint64 time = 2; // Timestamp (seconds)
optional string timeStr = 3; // Time string, format YYYY-MM-DD, in market timezone
optional double plateValue = 4; // Sector average valuation
}
optional double currentValue = 1; // Current valuation
optional double averageValue = 2; // Historical average valuation
optional double avgMinus1Stddev = 3; // Historical average - 1σ
optional double avgPlus1Stddev = 4; // Historical average + 1σ
optional double valuationPercentile = 5; // Historical percentile, value before %, e.g. 12.34 means 12.34%
optional double forwardValue = 6; // Forward valuation, PE / PS only
repeated ValuationHistoricalItem historicalItems = 7; // Historical data
}
// Market distribution
message MarketDistribution
{
message DistributionSection
{
optional double start = 1; // Section start value
optional double end = 2; // Section end value (0 means no upper limit)
optional int32 number = 3; // Number of stocks in this section
}
repeated DistributionSection sections = 1; // Distribution sections (descending)
optional int32 total = 2; // Total market count / constituent stock count
optional int32 ranking = 3; // Stock's valuation ranking in the market (not available for indexes)
optional double averageValue = 4; // Market average valuation (not available for indexes)
optional double medianValue = 5; // Market median valuation (not available for indexes)
}
// Sector distribution
message PlateDistribution
{
message PlateStockItem
{
optional Qot_Common.Security security = 1; // Stock
optional string name = 2; // Stock name
optional double value = 3; // Valuation
optional double marketCap = 4; // Market cap
}
optional Qot_Common.Security plate = 1; // Sector
optional string plateName = 2; // Sector name
optional double plateAverageValue = 3; // Sector average valuation
optional int32 plateRanking = 4; // Stock's valuation ranking within the sector
optional int32 plateStockItemCount = 5; // Total stocks in the sector
repeated PlateStockItem stockItems = 6; // Sector constituent stock valuation details
}
// Earnings / revenue growth rate
message ProfitGrowthRate
{
message ProfitGrowthItem
{
optional uint32 financialYear = 1; // Financial report year
optional uint32 financialQuarter = 2; // Financial report quarter (1=Q1, 2=Q2, 3=Q3, 4=FY)
optional string periodStr = 3; // Financial report period, e.g. "2024/Q3", "2024/FY"
optional int64 reportDate = 4; // Report date timestamp (seconds)
optional string reportDateStr = 5; // Report date string, format YYYY-MM-DD, in market timezone
optional double marketCapMultiple = 6; // Market cap multiple on report date (base period = 1)
optional double financeDataMultiple = 7; // Earnings / revenue multiple (base period = 1, depends on valuationType)
}
optional double financialTtmMultiple = 1; // TTM growth multiple
optional double marketCapMultiple = 2; // Market cap growth multiple
optional int32 yearCount = 3; // Number of years used to calculate growth multiple
repeated ProfitGrowthItem profitData = 4; // Per-period data
optional string conclusionDetailed = 5; // Valuation conclusion description (multi-language translated)
}
message S2C
{
optional Qot_Common.ValuationType valuationType = 1; // Actual returned valuation type, refer to Qot_Common.ValuationType
optional uint64 lastUpdateTime = 2; // Last update timestamp (seconds)
optional string lastUpdateTimeStr = 3; // Last update time string, format YYYY-MM-DD HH:MM:SS, in market timezone
optional ValuationTrend trend = 4; // Valuation trend (stocks + indexes)
optional MarketDistribution marketDistribution = 5; // Market distribution / constituent stock distribution (stocks + indexes)
optional PlateDistribution plateDistribution = 6; // Sector distribution (stocks only)
optional ProfitGrowthRate profitGrowthRate = 7; // Earnings / revenue growth rate (stocks only, not available for PB)
}
message Response
{
required int32 retType = 1 [default = -400]; // Return result, refer to Common.RetType
optional string retMsg = 2; // Return result description
optional int32 errCode = 3; // Error code
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
- API call result, refer to 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("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: 1778414867
lastUpdateTimeStr: "2026-05-10 20:07:47"
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);
Description
Get stock / index valuation detail
Parameters
message C2S
{
required Qot_Common.Security security = 1; // Stock
optional Qot_Common.ValuationType valuationType = 2; // Valuation type, refer to Qot_Common.ValuationType, default 0 (Unknown, use recommended type)
optional Qot_Common.ValuationIntervalType intervalType = 3; // Historical data time interval, refer to Qot_Common.ValuationIntervalType
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- Security structure, refer to Security
- Valuation type refer to ValuationType
- Valuation history interval type refer to ValuationIntervalType
- Return
// Valuation trend
message ValuationTrend
{
message ValuationHistoricalItem
{
optional double value = 1; // Valuation
optional uint64 time = 2; // Timestamp (seconds)
optional string timeStr = 3; // Time string, format YYYY-MM-DD, in market timezone
optional double plateValue = 4; // Sector average valuation
}
optional double currentValue = 1; // Current valuation
optional double averageValue = 2; // Historical average valuation
optional double avgMinus1Stddev = 3; // Historical average - 1σ
optional double avgPlus1Stddev = 4; // Historical average + 1σ
optional double valuationPercentile = 5; // Historical percentile, value before %, e.g. 12.34 means 12.34%
optional double forwardValue = 6; // Forward valuation, PE / PS only
repeated ValuationHistoricalItem historicalItems = 7; // Historical data
}
// Market distribution
message MarketDistribution
{
message DistributionSection
{
optional double start = 1; // Section start value
optional double end = 2; // Section end value (0 means no upper limit)
optional int32 number = 3; // Number of stocks in this section
}
repeated DistributionSection sections = 1; // Distribution sections (descending)
optional int32 total = 2; // Total market count / constituent stock count
optional int32 ranking = 3; // Stock's valuation ranking in the market (not available for indexes)
optional double averageValue = 4; // Market average valuation (not available for indexes)
optional double medianValue = 5; // Market median valuation (not available for indexes)
}
// Sector distribution
message PlateDistribution
{
message PlateStockItem
{
optional Qot_Common.Security security = 1; // Stock
optional string name = 2; // Stock name
optional double value = 3; // Valuation
optional double marketCap = 4; // Market cap
}
optional Qot_Common.Security plate = 1; // Sector
optional string plateName = 2; // Sector name
optional double plateAverageValue = 3; // Sector average valuation
optional int32 plateRanking = 4; // Stock's valuation ranking within the sector
optional int32 plateStockItemCount = 5; // Total stocks in the sector
repeated PlateStockItem stockItems = 6; // Sector constituent stock valuation details
}
// Earnings / revenue growth rate
message ProfitGrowthRate
{
message ProfitGrowthItem
{
optional uint32 financialYear = 1; // Financial report year
optional uint32 financialQuarter = 2; // Financial report quarter (1=Q1, 2=Q2, 3=Q3, 4=FY)
optional string periodStr = 3; // Financial report period, e.g. "2024/Q3", "2024/FY"
optional int64 reportDate = 4; // Report date timestamp (seconds)
optional string reportDateStr = 5; // Report date string, format YYYY-MM-DD, in market timezone
optional double marketCapMultiple = 6; // Market cap multiple on report date (base period = 1)
optional double financeDataMultiple = 7; // Earnings / revenue multiple (base period = 1, depends on valuationType)
}
optional double financialTtmMultiple = 1; // TTM growth multiple
optional double marketCapMultiple = 2; // Market cap growth multiple
optional int32 yearCount = 3; // Number of years used to calculate growth multiple
repeated ProfitGrowthItem profitData = 4; // Per-period data
optional string conclusionDetailed = 5; // Valuation conclusion description (multi-language translated)
}
message S2C
{
optional Qot_Common.ValuationType valuationType = 1; // Actual returned valuation type, refer to Qot_Common.ValuationType
optional uint64 lastUpdateTime = 2; // Last update timestamp (seconds)
optional string lastUpdateTimeStr = 3; // Last update time string, format YYYY-MM-DD HH:MM:SS, in market timezone
optional ValuationTrend trend = 4; // Valuation trend (stocks + indexes)
optional MarketDistribution marketDistribution = 5; // Market distribution / constituent stock distribution (stocks + indexes)
optional PlateDistribution plateDistribution = 6; // Sector distribution (stocks only)
optional ProfitGrowthRate profitGrowthRate = 7; // Earnings / revenue growth rate (stocks only, not available for PB)
}
message Response
{
required int32 retType = 1 [default = -400]; // Return result, refer to Common.RetType
optional string retMsg = 2; // Return result description
optional int32 errCode = 3; // Error code
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
- API call result, refer to 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("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=7459212597324116291
Send Qot_GetValuationDetail: 2
Receive Qot_GetValuationDetail: retType: 0
retMsg: ""
errCode: 0
s2c {
valuationType: ValuationType_PE
lastUpdateTime: 1778414869
lastUpdateTimeStr: "2026-05-10 20:07:49"
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;
Description
Get stock / index valuation detail
Parameters
message C2S
{
required Qot_Common.Security security = 1; // Stock
optional Qot_Common.ValuationType valuationType = 2; // Valuation type, refer to Qot_Common.ValuationType, default 0 (Unknown, use recommended type)
optional Qot_Common.ValuationIntervalType intervalType = 3; // Historical data time interval, refer to Qot_Common.ValuationIntervalType
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- Security structure, refer to Security
- Valuation type refer to ValuationType
- Valuation history interval type refer to ValuationIntervalType
- Return
// Valuation trend
message ValuationTrend
{
message ValuationHistoricalItem
{
optional double value = 1; // Valuation
optional uint64 time = 2; // Timestamp (seconds)
optional string timeStr = 3; // Time string, format YYYY-MM-DD, in market timezone
optional double plateValue = 4; // Sector average valuation
}
optional double currentValue = 1; // Current valuation
optional double averageValue = 2; // Historical average valuation
optional double avgMinus1Stddev = 3; // Historical average - 1σ
optional double avgPlus1Stddev = 4; // Historical average + 1σ
optional double valuationPercentile = 5; // Historical percentile, value before %, e.g. 12.34 means 12.34%
optional double forwardValue = 6; // Forward valuation, PE / PS only
repeated ValuationHistoricalItem historicalItems = 7; // Historical data
}
// Market distribution
message MarketDistribution
{
message DistributionSection
{
optional double start = 1; // Section start value
optional double end = 2; // Section end value (0 means no upper limit)
optional int32 number = 3; // Number of stocks in this section
}
repeated DistributionSection sections = 1; // Distribution sections (descending)
optional int32 total = 2; // Total market count / constituent stock count
optional int32 ranking = 3; // Stock's valuation ranking in the market (not available for indexes)
optional double averageValue = 4; // Market average valuation (not available for indexes)
optional double medianValue = 5; // Market median valuation (not available for indexes)
}
// Sector distribution
message PlateDistribution
{
message PlateStockItem
{
optional Qot_Common.Security security = 1; // Stock
optional string name = 2; // Stock name
optional double value = 3; // Valuation
optional double marketCap = 4; // Market cap
}
optional Qot_Common.Security plate = 1; // Sector
optional string plateName = 2; // Sector name
optional double plateAverageValue = 3; // Sector average valuation
optional int32 plateRanking = 4; // Stock's valuation ranking within the sector
optional int32 plateStockItemCount = 5; // Total stocks in the sector
repeated PlateStockItem stockItems = 6; // Sector constituent stock valuation details
}
// Earnings / revenue growth rate
message ProfitGrowthRate
{
message ProfitGrowthItem
{
optional uint32 financialYear = 1; // Financial report year
optional uint32 financialQuarter = 2; // Financial report quarter (1=Q1, 2=Q2, 3=Q3, 4=FY)
optional string periodStr = 3; // Financial report period, e.g. "2024/Q3", "2024/FY"
optional int64 reportDate = 4; // Report date timestamp (seconds)
optional string reportDateStr = 5; // Report date string, format YYYY-MM-DD, in market timezone
optional double marketCapMultiple = 6; // Market cap multiple on report date (base period = 1)
optional double financeDataMultiple = 7; // Earnings / revenue multiple (base period = 1, depends on valuationType)
}
optional double financialTtmMultiple = 1; // TTM growth multiple
optional double marketCapMultiple = 2; // Market cap growth multiple
optional int32 yearCount = 3; // Number of years used to calculate growth multiple
repeated ProfitGrowthItem profitData = 4; // Per-period data
optional string conclusionDetailed = 5; // Valuation conclusion description (multi-language translated)
}
message S2C
{
optional Qot_Common.ValuationType valuationType = 1; // Actual returned valuation type, refer to Qot_Common.ValuationType
optional uint64 lastUpdateTime = 2; // Last update timestamp (seconds)
optional string lastUpdateTimeStr = 3; // Last update time string, format YYYY-MM-DD HH:MM:SS, in market timezone
optional ValuationTrend trend = 4; // Valuation trend (stocks + indexes)
optional MarketDistribution marketDistribution = 5; // Market distribution / constituent stock distribution (stocks + indexes)
optional PlateDistribution plateDistribution = 6; // Sector distribution (stocks only)
optional ProfitGrowthRate profitGrowthRate = 7; // Earnings / revenue growth rate (stocks only, not available for PB)
}
message Response
{
required int32 retType = 1 [default = -400]; // Return result, refer to Common.RetType
optional string retMsg = 2; // Return result description
optional int32 errCode = 3; // Error code
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
- API call result, refer to 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_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: 1778414867
lastUpdateTimeStr: "2026-05-10 20:07:47"
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);
Description
Get stock / index valuation detail
Parameters
message C2S
{
required Qot_Common.Security security = 1; // Stock
optional Qot_Common.ValuationType valuationType = 2; // Valuation type, refer to Qot_Common.ValuationType, default 0 (Unknown, use recommended type)
optional Qot_Common.ValuationIntervalType intervalType = 3; // Historical data time interval, refer to Qot_Common.ValuationIntervalType
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- Security structure, refer to Security
- Return
// Valuation trend
message ValuationTrend
{
message ValuationHistoricalItem
{
optional double value = 1; // Valuation
optional uint64 time = 2; // Timestamp (seconds)
optional string timeStr = 3; // Time string, format YYYY-MM-DD, in market timezone
optional double plateValue = 4; // Sector average valuation
}
optional double currentValue = 1; // Current valuation
optional double averageValue = 2; // Historical average valuation
optional double avgMinus1Stddev = 3; // Historical average - 1σ
optional double avgPlus1Stddev = 4; // Historical average + 1σ
optional double valuationPercentile = 5; // Historical percentile, value before %, e.g. 12.34 means 12.34%
optional double forwardValue = 6; // Forward valuation, PE / PS only
repeated ValuationHistoricalItem historicalItems = 7; // Historical data
}
// Market distribution
message MarketDistribution
{
message DistributionSection
{
optional double start = 1; // Section start value
optional double end = 2; // Section end value (0 means no upper limit)
optional int32 number = 3; // Number of stocks in this section
}
repeated DistributionSection sections = 1; // Distribution sections (descending)
optional int32 total = 2; // Total market count / constituent stock count
optional int32 ranking = 3; // Stock's valuation ranking in the market (not available for indexes)
optional double averageValue = 4; // Market average valuation (not available for indexes)
optional double medianValue = 5; // Market median valuation (not available for indexes)
}
// Sector distribution
message PlateDistribution
{
message PlateStockItem
{
optional Qot_Common.Security security = 1; // Stock
optional string name = 2; // Stock name
optional double value = 3; // Valuation
optional double marketCap = 4; // Market cap
}
optional Qot_Common.Security plate = 1; // Sector
optional string plateName = 2; // Sector name
optional double plateAverageValue = 3; // Sector average valuation
optional int32 plateRanking = 4; // Stock's valuation ranking within the sector
optional int32 plateStockItemCount = 5; // Total stocks in the sector
repeated PlateStockItem stockItems = 6; // Sector constituent stock valuation details
}
// Earnings / revenue growth rate
message ProfitGrowthRate
{
message ProfitGrowthItem
{
optional uint32 financialYear = 1; // Financial report year
optional uint32 financialQuarter = 2; // Financial report quarter (1=Q1, 2=Q2, 3=Q3, 4=FY)
optional string periodStr = 3; // Financial report period, e.g. "2024/Q3", "2024/FY"
optional int64 reportDate = 4; // Report date timestamp (seconds)
optional string reportDateStr = 5; // Report date string, format YYYY-MM-DD, in market timezone
optional double marketCapMultiple = 6; // Market cap multiple on report date (base period = 1)
optional double financeDataMultiple = 7; // Earnings / revenue multiple (base period = 1, depends on valuationType)
}
optional double financialTtmMultiple = 1; // TTM growth multiple
optional double marketCapMultiple = 2; // Market cap growth multiple
optional int32 yearCount = 3; // Number of years used to calculate growth multiple
repeated ProfitGrowthItem profitData = 4; // Per-period data
optional string conclusionDetailed = 5; // Valuation conclusion description (multi-language translated)
}
message S2C
{
optional Qot_Common.ValuationType valuationType = 1; // Actual returned valuation type, refer to Qot_Common.ValuationType
optional uint64 lastUpdateTime = 2; // Last update timestamp (seconds)
optional string lastUpdateTimeStr = 3; // Last update time string, format YYYY-MM-DD HH:MM:SS, in market timezone
optional ValuationTrend trend = 4; // Valuation trend (stocks + indexes)
optional MarketDistribution marketDistribution = 5; // Market distribution / constituent stock distribution (stocks + indexes)
optional PlateDistribution plateDistribution = 6; // Sector distribution (stocks only)
optional ProfitGrowthRate profitGrowthRate = 7; // Earnings / revenue growth rate (stocks only, not available for PB)
}
message Response
{
required int32 retType = 1 [default = -400]; // Return result, refer to Common.RetType
optional string retMsg = 2; // Return result description
optional int32 errCode = 3; // Error code
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
- Security structure, refer to Security
- Valuation type refer to ValuationType
- Valuation history interval type refer to ValuationIntervalType
- Return
message S2C
{
optional Qot_Common.ValuationType valuationType = 1; // Actual returned valuation type
optional uint64 lastUpdateTime = 2; // Last update timestamp (seconds)
optional string lastUpdateTimeStr = 3; // Last update time string
optional ValuationTrend trend = 4; // Valuation trend
optional MarketDistribution marketDistribution = 5; // Market distribution
optional PlateDistribution plateDistribution = 6; // Sector distribution
optional ProfitGrowthRate profitGrowthRate = 7; // Earnings/revenue growth rate
}
message Response
{
required int32 retType = 1 [default = -400]; // Return result, refer to 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
- API call result, refer to RetType
- 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": "1778428927",
"lastUpdateTimeStr": "2026-05-11 00:02:07",
"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
Restrictions
- Maximum 30 requests per 30 seconds.
- Supports common stocks, funds, and indexes.
- PB valuation type does not include earnings/revenue growth rate module.
- Indexes do not include ranking, average value, or median value.
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_valuation_detail(code, valuation_type=None, interval_type=None)
Description
Get valuation detail for the specified stock or index, including valuation trend, market distribution, sector distribution (stocks only), and earnings/revenue growth rate (stocks only, not available for PB)
Parameters
Parameter Type Description code str Stock code valuation_type ValuationType Valuation type 0=Unknown (use recommended type), 1=PE (Price-to-Earnings), 2=PB (Price-to-Book), 3=PS (Price-to-Sales); default None (use recommended type)interval_type ValuationIntervalType Historical data time interval 0=Unknown, 1=Month3, 2=Month6, 3=Year1, 4=Year3, 5=Since2019, 6=Year5, 7=Year10, 8=Year2, 9=Year20, 10=Year30; default NoneReturn
Parameter Type Description ret RET_CODE API call result data dict If ret == RET_OK, returns valuation detail data dict str If ret != RET_OK, returns error description The returned dict contains the following fields:
Field Type Description valuation_type ValuationType Actual valuation type 0=Unknown, 1=PE, 2=PB, 3=PSlast_update_time int Last update timestamp Seconds, in market timezonelast_update_time_str str Last update time Format YYYY-MM-DD HH:MM:SS, in market timezonetrend dict Valuation trend data, see trend field table market_distribution dict Market distribution data, see market_distribution field table plate_distribution dict Sector distribution data, see plate_distribution field table Stocks onlyprofit_growth_rate dict Earnings/revenue growth rate data, see profit_growth_rate field table Stocks only; not available for PB valuation typetrend fields (valuation trend summary):
Field Type Description current_value float Current valuation average_value float Historical average valuation avg_minus_1_stddev float Historical average - 1σ avg_plus_1_stddev float Historical average + 1σ valuation_percentile float Historical percentile Value before %, e.g. 12.34 means 12.34%forward_value float Forward valuation PE / PS onlyhistorical_items list Historical valuation list, each item see historical_items field table historical_items fields (historical valuation entry):
Field Type Description value float Valuation time int Timestamp Seconds, in market timezonetime_str str Date Format YYYY-MM-DD, in market timezoneplate_value float Sector average valuation market_distribution fields (market / constituent stock distribution):
Field Type Description sections list Distribution sections list (descending), each item see sections field table total int Total market count / constituent stock count ranking int Stock's valuation ranking in the market Not available for indexesaverage_value float Market average valuation Not available for indexesmedian_value float Market median valuation Not available for indexessections fields (distribution section entry):
Field Type Description start float Section start value end float Section end value 0 means no upper limitnumber int Number of stocks in this section plate_distribution fields (sector distribution, stocks only):
Field Type Description plate str Sector code plate_name str Sector name plate_average_value float Sector average valuation plate_ranking int Stock's valuation ranking within the sector plate_stock_item_count int Total stocks in the sector stock_items list Sector constituent stock valuation details, each item see stock_items field table stock_items fields (sector constituent stock entry):
Field Type Description security str Stock code name str Stock name value float Valuation market_cap float Market cap profit_growth_rate fields (earnings/revenue growth rate, stocks only, not PB):
Field Type Description financial_ttm_multiple float TTM growth multiple market_cap_multiple float Market cap growth multiple year_count int Number of years used to calculate growth multiple profit_data list Per-period data list, each item see profit_data field table conclusion_detailed str Valuation conclusion description profit_data fields (per-period earnings/revenue entry):
Field Type Description financial_year int Financial report year financial_quarter int Financial report quarter 1=Q1, 2=Q2, 3=Q3, 4=FYperiod_str str Financial report period e.g. "2024/Q3", "2024/FY"report_date int Report date timestamp Seconds, in market timezonereport_date_str str Report date Format YYYY-MM-DD, in market timezonemarket_cap_multiple float Market cap multiple on report date Base period = 1finance_data_multiple float Earnings/revenue multiple Base period = 1; depends on 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
Description
Get stock / index valuation detail
Parameters
message C2S
{
required Qot_Common.Security security = 1; // Stock
optional Qot_Common.ValuationType valuationType = 2; // Valuation type, refer to Qot_Common.ValuationType, default 0 (Unknown, use recommended type)
optional Qot_Common.ValuationIntervalType intervalType = 3; // Historical data time interval, refer to Qot_Common.ValuationIntervalType
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- Security structure, refer to 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
- Return
// Valuation trend
message ValuationTrend
{
message ValuationHistoricalItem
{
optional double value = 1; // Valuation
optional uint64 time = 2; // Timestamp (seconds)
optional string timeStr = 3; // Time string, format YYYY-MM-DD, in market timezone
optional double plateValue = 4; // Sector average valuation
}
optional double currentValue = 1; // Current valuation
optional double averageValue = 2; // Historical average valuation
optional double avgMinus1Stddev = 3; // Historical average - 1σ
optional double avgPlus1Stddev = 4; // Historical average + 1σ
optional double valuationPercentile = 5; // Historical percentile, value before %, e.g. 12.34 means 12.34%
optional double forwardValue = 6; // Forward valuation, PE / PS only
repeated ValuationHistoricalItem historicalItems = 7; // Historical data
}
// Market distribution
message MarketDistribution
{
message DistributionSection
{
optional double start = 1; // Section start value
optional double end = 2; // Section end value (0 means no upper limit)
optional int32 number = 3; // Number of stocks in this section
}
repeated DistributionSection sections = 1; // Distribution sections (descending)
optional int32 total = 2; // Total market count / constituent stock count
optional int32 ranking = 3; // Stock's valuation ranking in the market (not available for indexes)
optional double averageValue = 4; // Market average valuation (not available for indexes)
optional double medianValue = 5; // Market median valuation (not available for indexes)
}
// Sector distribution
message PlateDistribution
{
message PlateStockItem
{
optional Qot_Common.Security security = 1; // Stock
optional string name = 2; // Stock name
optional double value = 3; // Valuation
optional double marketCap = 4; // Market cap
}
optional Qot_Common.Security plate = 1; // Sector
optional string plateName = 2; // Sector name
optional double plateAverageValue = 3; // Sector average valuation
optional int32 plateRanking = 4; // Stock's valuation ranking within the sector
optional int32 plateStockItemCount = 5; // Total stocks in the sector
repeated PlateStockItem stockItems = 6; // Sector constituent stock valuation details
}
// Earnings / revenue growth rate
message ProfitGrowthRate
{
message ProfitGrowthItem
{
optional uint32 financialYear = 1; // Financial report year
optional uint32 financialQuarter = 2; // Financial report quarter (1=Q1, 2=Q2, 3=Q3, 4=FY)
optional string periodStr = 3; // Financial report period, e.g. "2024/Q3", "2024/FY"
optional int64 reportDate = 4; // Report date timestamp (seconds)
optional string reportDateStr = 5; // Report date string, format YYYY-MM-DD, in market timezone
optional double marketCapMultiple = 6; // Market cap multiple on report date (base period = 1)
optional double financeDataMultiple = 7; // Earnings / revenue multiple (base period = 1, depends on valuationType)
}
optional double financialTtmMultiple = 1; // TTM growth multiple
optional double marketCapMultiple = 2; // Market cap growth multiple
optional int32 yearCount = 3; // Number of years used to calculate growth multiple
repeated ProfitGrowthItem profitData = 4; // Per-period data
optional string conclusionDetailed = 5; // Valuation conclusion description (multi-language translated)
}
message S2C
{
optional Qot_Common.ValuationType valuationType = 1; // Actual returned valuation type, refer to Qot_Common.ValuationType
optional uint64 lastUpdateTime = 2; // Last update timestamp (seconds)
optional string lastUpdateTimeStr = 3; // Last update time string, format YYYY-MM-DD HH:MM:SS, in market timezone
optional ValuationTrend trend = 4; // Valuation trend (stocks + indexes)
optional MarketDistribution marketDistribution = 5; // Market distribution / constituent stock distribution (stocks + indexes)
optional PlateDistribution plateDistribution = 6; // Sector distribution (stocks only)
optional ProfitGrowthRate profitGrowthRate = 7; // Earnings / revenue growth rate (stocks only, not available for PB)
}
message Response
{
required int32 retType = 1 [default = -400]; // Return result, refer to Common.RetType
optional string retMsg = 2; // Return result description
optional int32 errCode = 3; // Error code
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
- API call result, refer to RetType
Protocol ID
3232
uint GetValuationDetail(QotGetValuationDetail.Request req);
virtual void OnReply_GetValuationDetail(MMAPI_Conn client, uint nSerialNo, QotGetValuationDetail.Response rsp);
Description
Get stock / index valuation detail
Parameters
message C2S
{
required Qot_Common.Security security = 1; // Stock
optional Qot_Common.ValuationType valuationType = 2; // Valuation type, refer to Qot_Common.ValuationType, default 0 (Unknown, use recommended type)
optional Qot_Common.ValuationIntervalType intervalType = 3; // Historical data time interval, refer to Qot_Common.ValuationIntervalType
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- Security structure, refer to Security
- Return
// Valuation trend
message ValuationTrend
{
message ValuationHistoricalItem
{
optional double value = 1; // Valuation
optional uint64 time = 2; // Timestamp (seconds)
optional string timeStr = 3; // Time string, format YYYY-MM-DD, in market timezone
optional double plateValue = 4; // Sector average valuation
}
optional double currentValue = 1; // Current valuation
optional double averageValue = 2; // Historical average valuation
optional double avgMinus1Stddev = 3; // Historical average - 1σ
optional double avgPlus1Stddev = 4; // Historical average + 1σ
optional double valuationPercentile = 5; // Historical percentile, value before %, e.g. 12.34 means 12.34%
optional double forwardValue = 6; // Forward valuation, PE / PS only
repeated ValuationHistoricalItem historicalItems = 7; // Historical data
}
// Market distribution
message MarketDistribution
{
message DistributionSection
{
optional double start = 1; // Section start value
optional double end = 2; // Section end value (0 means no upper limit)
optional int32 number = 3; // Number of stocks in this section
}
repeated DistributionSection sections = 1; // Distribution sections (descending)
optional int32 total = 2; // Total market count / constituent stock count
optional int32 ranking = 3; // Stock's valuation ranking in the market (not available for indexes)
optional double averageValue = 4; // Market average valuation (not available for indexes)
optional double medianValue = 5; // Market median valuation (not available for indexes)
}
// Sector distribution
message PlateDistribution
{
message PlateStockItem
{
optional Qot_Common.Security security = 1; // Stock
optional string name = 2; // Stock name
optional double value = 3; // Valuation
optional double marketCap = 4; // Market cap
}
optional Qot_Common.Security plate = 1; // Sector
optional string plateName = 2; // Sector name
optional double plateAverageValue = 3; // Sector average valuation
optional int32 plateRanking = 4; // Stock's valuation ranking within the sector
optional int32 plateStockItemCount = 5; // Total stocks in the sector
repeated PlateStockItem stockItems = 6; // Sector constituent stock valuation details
}
// Earnings / revenue growth rate
message ProfitGrowthRate
{
message ProfitGrowthItem
{
optional uint32 financialYear = 1; // Financial report year
optional uint32 financialQuarter = 2; // Financial report quarter (1=Q1, 2=Q2, 3=Q3, 4=FY)
optional string periodStr = 3; // Financial report period, e.g. "2024/Q3", "2024/FY"
optional int64 reportDate = 4; // Report date timestamp (seconds)
optional string reportDateStr = 5; // Report date string, format YYYY-MM-DD, in market timezone
optional double marketCapMultiple = 6; // Market cap multiple on report date (base period = 1)
optional double financeDataMultiple = 7; // Earnings / revenue multiple (base period = 1, depends on valuationType)
}
optional double financialTtmMultiple = 1; // TTM growth multiple
optional double marketCapMultiple = 2; // Market cap growth multiple
optional int32 yearCount = 3; // Number of years used to calculate growth multiple
repeated ProfitGrowthItem profitData = 4; // Per-period data
optional string conclusionDetailed = 5; // Valuation conclusion description (multi-language translated)
}
message S2C
{
optional Qot_Common.ValuationType valuationType = 1; // Actual returned valuation type, refer to Qot_Common.ValuationType
optional uint64 lastUpdateTime = 2; // Last update timestamp (seconds)
optional string lastUpdateTimeStr = 3; // Last update time string, format YYYY-MM-DD HH:MM:SS, in market timezone
optional ValuationTrend trend = 4; // Valuation trend (stocks + indexes)
optional MarketDistribution marketDistribution = 5; // Market distribution / constituent stock distribution (stocks + indexes)
optional PlateDistribution plateDistribution = 6; // Sector distribution (stocks only)
optional ProfitGrowthRate profitGrowthRate = 7; // Earnings / revenue growth rate (stocks only, not available for PB)
}
message Response
{
required int32 retType = 1 [default = -400]; // Return result, refer to Common.RetType
optional string retMsg = 2; // Return result description
optional int32 errCode = 3; // Error code
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
- API call result, refer to 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("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: 1778414867
lastUpdateTimeStr: "2026-05-10 20:07:47"
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);
Description
Get stock / index valuation detail
Parameters
message C2S
{
required Qot_Common.Security security = 1; // Stock
optional Qot_Common.ValuationType valuationType = 2; // Valuation type, refer to Qot_Common.ValuationType, default 0 (Unknown, use recommended type)
optional Qot_Common.ValuationIntervalType intervalType = 3; // Historical data time interval, refer to Qot_Common.ValuationIntervalType
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- Security structure, refer to Security
- Return
// Valuation trend
message ValuationTrend
{
message ValuationHistoricalItem
{
optional double value = 1; // Valuation
optional uint64 time = 2; // Timestamp (seconds)
optional string timeStr = 3; // Time string, format YYYY-MM-DD, in market timezone
optional double plateValue = 4; // Sector average valuation
}
optional double currentValue = 1; // Current valuation
optional double averageValue = 2; // Historical average valuation
optional double avgMinus1Stddev = 3; // Historical average - 1σ
optional double avgPlus1Stddev = 4; // Historical average + 1σ
optional double valuationPercentile = 5; // Historical percentile, value before %, e.g. 12.34 means 12.34%
optional double forwardValue = 6; // Forward valuation, PE / PS only
repeated ValuationHistoricalItem historicalItems = 7; // Historical data
}
// Market distribution
message MarketDistribution
{
message DistributionSection
{
optional double start = 1; // Section start value
optional double end = 2; // Section end value (0 means no upper limit)
optional int32 number = 3; // Number of stocks in this section
}
repeated DistributionSection sections = 1; // Distribution sections (descending)
optional int32 total = 2; // Total market count / constituent stock count
optional int32 ranking = 3; // Stock's valuation ranking in the market (not available for indexes)
optional double averageValue = 4; // Market average valuation (not available for indexes)
optional double medianValue = 5; // Market median valuation (not available for indexes)
}
// Sector distribution
message PlateDistribution
{
message PlateStockItem
{
optional Qot_Common.Security security = 1; // Stock
optional string name = 2; // Stock name
optional double value = 3; // Valuation
optional double marketCap = 4; // Market cap
}
optional Qot_Common.Security plate = 1; // Sector
optional string plateName = 2; // Sector name
optional double plateAverageValue = 3; // Sector average valuation
optional int32 plateRanking = 4; // Stock's valuation ranking within the sector
optional int32 plateStockItemCount = 5; // Total stocks in the sector
repeated PlateStockItem stockItems = 6; // Sector constituent stock valuation details
}
// Earnings / revenue growth rate
message ProfitGrowthRate
{
message ProfitGrowthItem
{
optional uint32 financialYear = 1; // Financial report year
optional uint32 financialQuarter = 2; // Financial report quarter (1=Q1, 2=Q2, 3=Q3, 4=FY)
optional string periodStr = 3; // Financial report period, e.g. "2024/Q3", "2024/FY"
optional int64 reportDate = 4; // Report date timestamp (seconds)
optional string reportDateStr = 5; // Report date string, format YYYY-MM-DD, in market timezone
optional double marketCapMultiple = 6; // Market cap multiple on report date (base period = 1)
optional double financeDataMultiple = 7; // Earnings / revenue multiple (base period = 1, depends on valuationType)
}
optional double financialTtmMultiple = 1; // TTM growth multiple
optional double marketCapMultiple = 2; // Market cap growth multiple
optional int32 yearCount = 3; // Number of years used to calculate growth multiple
repeated ProfitGrowthItem profitData = 4; // Per-period data
optional string conclusionDetailed = 5; // Valuation conclusion description (multi-language translated)
}
message S2C
{
optional Qot_Common.ValuationType valuationType = 1; // Actual returned valuation type, refer to Qot_Common.ValuationType
optional uint64 lastUpdateTime = 2; // Last update timestamp (seconds)
optional string lastUpdateTimeStr = 3; // Last update time string, format YYYY-MM-DD HH:MM:SS, in market timezone
optional ValuationTrend trend = 4; // Valuation trend (stocks + indexes)
optional MarketDistribution marketDistribution = 5; // Market distribution / constituent stock distribution (stocks + indexes)
optional PlateDistribution plateDistribution = 6; // Sector distribution (stocks only)
optional ProfitGrowthRate profitGrowthRate = 7; // Earnings / revenue growth rate (stocks only, not available for PB)
}
message Response
{
required int32 retType = 1 [default = -400]; // Return result, refer to Common.RetType
optional string retMsg = 2; // Return result description
optional int32 errCode = 3; // Error code
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
- API call result, refer to 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("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=7459212597324116291
Send Qot_GetValuationDetail: 2
Receive Qot_GetValuationDetail: retType: 0
retMsg: ""
errCode: 0
s2c {
valuationType: ValuationType_PE
lastUpdateTime: 1778414869
lastUpdateTimeStr: "2026-05-10 20:07:49"
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;
Description
Get stock / index valuation detail
Parameters
message C2S
{
required Qot_Common.Security security = 1; // Stock
optional Qot_Common.ValuationType valuationType = 2; // Valuation type, refer to Qot_Common.ValuationType, default 0 (Unknown, use recommended type)
optional Qot_Common.ValuationIntervalType intervalType = 3; // Historical data time interval, refer to Qot_Common.ValuationIntervalType
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- Security structure, refer to Security
- Return
// Valuation trend
message ValuationTrend
{
message ValuationHistoricalItem
{
optional double value = 1; // Valuation
optional uint64 time = 2; // Timestamp (seconds)
optional string timeStr = 3; // Time string, format YYYY-MM-DD, in market timezone
optional double plateValue = 4; // Sector average valuation
}
optional double currentValue = 1; // Current valuation
optional double averageValue = 2; // Historical average valuation
optional double avgMinus1Stddev = 3; // Historical average - 1σ
optional double avgPlus1Stddev = 4; // Historical average + 1σ
optional double valuationPercentile = 5; // Historical percentile, value before %, e.g. 12.34 means 12.34%
optional double forwardValue = 6; // Forward valuation, PE / PS only
repeated ValuationHistoricalItem historicalItems = 7; // Historical data
}
// Market distribution
message MarketDistribution
{
message DistributionSection
{
optional double start = 1; // Section start value
optional double end = 2; // Section end value (0 means no upper limit)
optional int32 number = 3; // Number of stocks in this section
}
repeated DistributionSection sections = 1; // Distribution sections (descending)
optional int32 total = 2; // Total market count / constituent stock count
optional int32 ranking = 3; // Stock's valuation ranking in the market (not available for indexes)
optional double averageValue = 4; // Market average valuation (not available for indexes)
optional double medianValue = 5; // Market median valuation (not available for indexes)
}
// Sector distribution
message PlateDistribution
{
message PlateStockItem
{
optional Qot_Common.Security security = 1; // Stock
optional string name = 2; // Stock name
optional double value = 3; // Valuation
optional double marketCap = 4; // Market cap
}
optional Qot_Common.Security plate = 1; // Sector
optional string plateName = 2; // Sector name
optional double plateAverageValue = 3; // Sector average valuation
optional int32 plateRanking = 4; // Stock's valuation ranking within the sector
optional int32 plateStockItemCount = 5; // Total stocks in the sector
repeated PlateStockItem stockItems = 6; // Sector constituent stock valuation details
}
// Earnings / revenue growth rate
message ProfitGrowthRate
{
message ProfitGrowthItem
{
optional uint32 financialYear = 1; // Financial report year
optional uint32 financialQuarter = 2; // Financial report quarter (1=Q1, 2=Q2, 3=Q3, 4=FY)
optional string periodStr = 3; // Financial report period, e.g. "2024/Q3", "2024/FY"
optional int64 reportDate = 4; // Report date timestamp (seconds)
optional string reportDateStr = 5; // Report date string, format YYYY-MM-DD, in market timezone
optional double marketCapMultiple = 6; // Market cap multiple on report date (base period = 1)
optional double financeDataMultiple = 7; // Earnings / revenue multiple (base period = 1, depends on valuationType)
}
optional double financialTtmMultiple = 1; // TTM growth multiple
optional double marketCapMultiple = 2; // Market cap growth multiple
optional int32 yearCount = 3; // Number of years used to calculate growth multiple
repeated ProfitGrowthItem profitData = 4; // Per-period data
optional string conclusionDetailed = 5; // Valuation conclusion description (multi-language translated)
}
message S2C
{
optional Qot_Common.ValuationType valuationType = 1; // Actual returned valuation type, refer to Qot_Common.ValuationType
optional uint64 lastUpdateTime = 2; // Last update timestamp (seconds)
optional string lastUpdateTimeStr = 3; // Last update time string, format YYYY-MM-DD HH:MM:SS, in market timezone
optional ValuationTrend trend = 4; // Valuation trend (stocks + indexes)
optional MarketDistribution marketDistribution = 5; // Market distribution / constituent stock distribution (stocks + indexes)
optional PlateDistribution plateDistribution = 6; // Sector distribution (stocks only)
optional ProfitGrowthRate profitGrowthRate = 7; // Earnings / revenue growth rate (stocks only, not available for PB)
}
message Response
{
required int32 retType = 1 [default = -400]; // Return result, refer to Common.RetType
optional string retMsg = 2; // Return result description
optional int32 errCode = 3; // Error code
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
- API call result, refer to 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_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: 1778414867
lastUpdateTimeStr: "2026-05-10 20:07:47"
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);
Description
Get stock / index valuation detail
Parameters
message C2S
{
required Qot_Common.Security security = 1; // Stock
optional Qot_Common.ValuationType valuationType = 2; // Valuation type, refer to Qot_Common.ValuationType, default 0 (Unknown, use recommended type)
optional Qot_Common.ValuationIntervalType intervalType = 3; // Historical data time interval, refer to Qot_Common.ValuationIntervalType
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- Security structure, refer to Security
- Return
// Valuation trend
message ValuationTrend
{
message ValuationHistoricalItem
{
optional double value = 1; // Valuation
optional uint64 time = 2; // Timestamp (seconds)
optional string timeStr = 3; // Time string, format YYYY-MM-DD, in market timezone
optional double plateValue = 4; // Sector average valuation
}
optional double currentValue = 1; // Current valuation
optional double averageValue = 2; // Historical average valuation
optional double avgMinus1Stddev = 3; // Historical average - 1σ
optional double avgPlus1Stddev = 4; // Historical average + 1σ
optional double valuationPercentile = 5; // Historical percentile, value before %, e.g. 12.34 means 12.34%
optional double forwardValue = 6; // Forward valuation, PE / PS only
repeated ValuationHistoricalItem historicalItems = 7; // Historical data
}
// Market distribution
message MarketDistribution
{
message DistributionSection
{
optional double start = 1; // Section start value
optional double end = 2; // Section end value (0 means no upper limit)
optional int32 number = 3; // Number of stocks in this section
}
repeated DistributionSection sections = 1; // Distribution sections (descending)
optional int32 total = 2; // Total market count / constituent stock count
optional int32 ranking = 3; // Stock's valuation ranking in the market (not available for indexes)
optional double averageValue = 4; // Market average valuation (not available for indexes)
optional double medianValue = 5; // Market median valuation (not available for indexes)
}
// Sector distribution
message PlateDistribution
{
message PlateStockItem
{
optional Qot_Common.Security security = 1; // Stock
optional string name = 2; // Stock name
optional double value = 3; // Valuation
optional double marketCap = 4; // Market cap
}
optional Qot_Common.Security plate = 1; // Sector
optional string plateName = 2; // Sector name
optional double plateAverageValue = 3; // Sector average valuation
optional int32 plateRanking = 4; // Stock's valuation ranking within the sector
optional int32 plateStockItemCount = 5; // Total stocks in the sector
repeated PlateStockItem stockItems = 6; // Sector constituent stock valuation details
}
// Earnings / revenue growth rate
message ProfitGrowthRate
{
message ProfitGrowthItem
{
optional uint32 financialYear = 1; // Financial report year
optional uint32 financialQuarter = 2; // Financial report quarter (1=Q1, 2=Q2, 3=Q3, 4=FY)
optional string periodStr = 3; // Financial report period, e.g. "2024/Q3", "2024/FY"
optional int64 reportDate = 4; // Report date timestamp (seconds)
optional string reportDateStr = 5; // Report date string, format YYYY-MM-DD, in market timezone
optional double marketCapMultiple = 6; // Market cap multiple on report date (base period = 1)
optional double financeDataMultiple = 7; // Earnings / revenue multiple (base period = 1, depends on valuationType)
}
optional double financialTtmMultiple = 1; // TTM growth multiple
optional double marketCapMultiple = 2; // Market cap growth multiple
optional int32 yearCount = 3; // Number of years used to calculate growth multiple
repeated ProfitGrowthItem profitData = 4; // Per-period data
optional string conclusionDetailed = 5; // Valuation conclusion description (multi-language translated)
}
message S2C
{
optional Qot_Common.ValuationType valuationType = 1; // Actual returned valuation type, refer to Qot_Common.ValuationType
optional uint64 lastUpdateTime = 2; // Last update timestamp (seconds)
optional string lastUpdateTimeStr = 3; // Last update time string, format YYYY-MM-DD HH:MM:SS, in market timezone
optional ValuationTrend trend = 4; // Valuation trend (stocks + indexes)
optional MarketDistribution marketDistribution = 5; // Market distribution / constituent stock distribution (stocks + indexes)
optional PlateDistribution plateDistribution = 6; // Sector distribution (stocks only)
optional ProfitGrowthRate profitGrowthRate = 7; // Earnings / revenue growth rate (stocks only, not available for PB)
}
message Response
{
required int32 retType = 1 [default = -400]; // Return result, refer to Common.RetType
optional string retMsg = 2; // Return result description
optional int32 errCode = 3; // Error code
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
- API call result, refer to RetType
- 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": "1778428927",
"lastUpdateTimeStr": "2026-05-11 00:02:07",
"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
Restrictions
- Maximum 30 requests per 30 seconds.
- Supports common stocks, funds, and indexes.
- PB valuation type does not include earnings/revenue growth rate module.
- Indexes do not include ranking, average value, or median value.