# バリュエーション詳細の取得
- 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 API 呼び出し結果 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
- API 呼び出し結果については 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 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
- API 呼び出し結果については 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 参照
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 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
- API 呼び出し結果については 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 参照
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 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
- API 呼び出し結果については 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 参照
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 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
- 銘柄構造については 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
- API 呼び出し結果については 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 API 呼び出し結果 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 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
- API 呼び出し結果については 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 参照
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 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
- API 呼び出し結果については 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 参照
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 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
- API 呼び出し結果については 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 参照
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 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
- API 呼び出し結果については 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 参照
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 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
- API 呼び出し結果については 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 バリュエーション種別では利益/収益成長率モジュールは含まれません。
- 指数では順位、平均値、中央値は含まれません。