# 獲取個股/指數估值詳情
- 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
協議 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
- 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);
介紹
獲取個股/指數估值詳情
參數
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
- 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;
介紹
獲取個股/指數估值詳情
參數
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
- 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);
介紹
獲取個股/指數估值詳情
參數
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
- 返回
// 走勢
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
- 股票結構參見 Security
- 估值類型參見 ValuationType
- 估值歷史區間類型參見 ValuationIntervalType
- 返回
message S2C
{
optional Qot_Common.ValuationType valuationType = 1; // 實際返回的估值類型
optional uint64 lastUpdateTime = 2; // 最後更新時間戳(秒)
optional string lastUpdateTimeStr = 3; // 最後更新時間字串
optional ValuationTrend trend = 4; // 走勢
optional MarketDistribution marketDistribution = 5; // 市場分佈
optional PlateDistribution plateDistribution = 6; // 行業分佈
optional ProfitGrowthRate profitGrowthRate = 7; // 盈利/營收增速
}
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
- 介面調用結果,結構參見 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
介面限制
- 每 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
協議 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
- 返回
// 走勢
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
- 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);
介紹
獲取個股/指數估值詳情
參數
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
- 返回
// 走勢
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
- 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;
介紹
獲取個股/指數估值詳情
參數
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
- 返回
// 走勢
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
- 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);
介紹
獲取個股/指數估值詳情
參數
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
- 返回
// 走勢
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
- 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
介面限制
- 每 30 秒內最多請求 30 次。
- 支援正股、基金及指數。
- PB 估值無盈利/營收增速模組。
- 指數無排名、均值、中位數。