# 獲取盈利超預期排名
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_earnings_beat_rank(market, beat_type, count=None, term=None, filter_list=None, sort_field=None)
介紹
獲取盈利超預期排名,返回指定市場中財報實際值超出預期值的股票排行列表,包含超預期比率、財報後首日漲幅、同比增長率等維度數據。
參數
參數 類型 說明 market Market 市場類型(支持 HK/US/SG/JP)(必填) beat_type BeatType 超預期類型(必填) count int 返回數量 [1, 300],默認 30 term BeatTerm 財報週期,默認 ALL filter_list list[ EarningsBeatRankFilter]篩選條件列表(多條件爲 AND 關係) sort_field EarningsBeatSortField 排序字段(固定降序),默認按市值 輸入限制
filter_list篩選條件(EarningsBeatRankFilter):通過
EarningsBeatRankFilter構造篩選條件,僅支持範圍篩選:構造參數 說明 indicator_type篩選因子類型( EarningsBeatIndicatorType,必填)interval_min範圍最小值(閉區間) interval_max範圍最大值(閉區間) 不傳
filter_list時使用默認篩選:超預期比率 > 0,發佈時間爲最近 30 天。
返回
參數 類型 說明 ret RET_CODE 接口調用結果 data pd.DataFrame 當 ret == RET_OK,返回 (all_count, DataFrame) 元組 str 當 ret != RET_OK,返回錯誤描述 - 數據格式如下:
字段 類型 說明 security str 股票代碼(如 'US.AAPL')name str 股票名稱 industry str 所屬行業 cur_price float 最新價 last_close_price float 昨收價 change_rate float 今日漲跌幅(%) market_cap float 市值 pe_ttm float 市盈率 TTM dividends_ttm float 股息率 TTM(%) released_date str 財報發佈日期(如 '2024-01-15')beat_ratio float 超預期比率(%) actual float 實際值 estimate float 預測值 yoy float 去年同期 yoy_growth float 同比增長率(%) earning_day_chg float 財報後首日漲幅(%) term str 財報週期(如 '2024/Q1')detail_post_period str 發佈時段(BEFORE=盤前 / AFTER=盤後 / REGULAR=當天 / INTRADAY_TRADING=盤中)
- 數據格式如下:
Example
from futu import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data = quote_ctx.get_earnings_beat_rank(market=Market.US, beat_type=BeatType.EPS, count=2)
if ret == RET_OK:
all_count, df = data
print(f'總數據量: {all_count}')
print(df)
else:
print('error:', data)
quote_ctx.close()
2
3
4
5
6
7
8
9
10
11
12
13
- Output
總數據量: 1276
security name industry cur_price last_close_price change_rate market_cap pe_ttm dividends_ttm released_date beat_ratio actual estimate yoy yoy_growth earning_day_chg term detail_post_period
0 US.NVDA 英偉達 半導體 200.04 208.65 -4.126 4.840968e+12 30.63399 0.019 2026-05-20 37.253 2.3900 1.7413 0.76 214.473 -1.772 2027/Q1 AFTER
1 US.AAPL 蘋果 消費電子產品 294.30 297.01 -0.912 4.322489e+12 35.62953 0.353 2026-04-30 3.373 2.0099 1.9444 1.65 21.818 3.239 2026/Q2 AFTER
2
3
4
# Qot_GetEarningsBeatRank.proto
介紹
獲取盈利超預期排名,返回指定市場中財報實際值超出預期值的股票排行列表,包含超預期比率、財報後首日漲幅、同比增長率等維度數據。
參數
// 盈利超預期類型
enum BeatType {
BeatType_Unknown = 0;
BeatType_EPS = 1; // 每股收益
BeatType_REVENUE = 2; // 營收
BeatType_EBIT = 3; // 息稅前利潤
}
// 財報週期
enum BeatTerm {
BeatTerm_Latest = 0; // 最近一期 (默認)
BeatTerm_LatestQuarter = 1; // 最近一期季報
BeatTerm_LatestHalf = 2; // 最近一期半年報
BeatTerm_LatestAnnual = 3; // 最近一期年報
BeatTerm_All = 4; // 全部(時間一樣季報優先,時間不同最近一期)
}
// 篩選條件類型
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_BeatRatio = 1; //【範圍】超預期比率
IndicatorType_ReleasedDate = 2; //【範圍】發佈時間(時間戳秒)
IndicatorType_MarketCap = 3; //【範圍】市值
IndicatorType_Price = 4; //【範圍】最新價
IndicatorType_PeTTM = 5; //【範圍】市盈率TTM
}
// 排序字段 (固定降序)
enum SortField {
SortField_Unknown = 0; // 默認按市值排序
SortField_BeatRatio = 1; // 超預期比率
SortField_EarningDayChg = 2; // 財報後首日漲幅
SortField_ReleasedDate = 3; // 發佈時間
SortField_Actual = 4; // 實際值
SortField_Estimate = 5; // 預測值
SortField_Yoy = 6; // 去年同期
SortField_YoyGrowth = 7; // 同比增長率
SortField_PeTTM = 8; // 市盈率TTM
SortField_DividendsTTM = 9; // 股息率TTM
SortField_Price = 10; // 價格
SortField_ChangeRate = 11; // 今日漲跌幅
}
// 財報發佈時段
enum PostPeriodType {
PostPeriodType_Regular = 0; // 當天(未識別出時段)
PostPeriodType_Before = 1; // 盤前
PostPeriodType_After = 2; // 盤後
PostPeriodType_IntradayTrading = 3; // 盤中
}
// 篩選條件
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.Interval indicatorValue = 2; // 篩選區間
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket (僅支持 HK=1, US=11, SG=31, JP=41)
required int32 beatType = 2; // BeatType
optional int32 count = 3; // 返回數量 [1,300], 默認30
optional int32 term = 4; // BeatTerm, 默認 All
repeated Indicator filterList = 5; // 可選篩選條件(AND關係), 不傳則使用默認值(超預期>0, 時間=最近30天)
optional int32 sortField = 6; // SortField, 排序字段(固定降序), 默認按市值
}
// 盈利超預期排行數據項
message EarningsBeatItem {
required Qot_Common.Security security = 1; // 股票
optional string name = 2; // 名稱
optional string industry = 3; // 行業
// 行情
optional double curPrice = 10; // 最新價
optional double lastClosePrice = 11; // 昨收價
optional double changeRate = 12; // 今日漲跌幅 (%)
optional double marketCap = 13; // 市值
optional double peTTM = 14; // 市盈率TTM
optional double dividendsTTM = 15; // 股息率TTM (%)
// 盈利超預期
optional string releasedDate = 20; // 發佈日期 (如 "2024-01-15")
optional double beatRatio = 21; // 超預期比率 (%)
optional double actual = 22; // 實際值
optional double estimate = 23; // 預測值
optional double yoy = 24; // 去年同期
optional double yoyGrowth = 25; // 同比增長率 (%)
optional double earningDayChg = 26; // 財報後首日漲幅 (%)
optional string term = 27; // 財報週期 (如 "2024/Q1")
optional int32 detailPostPeriod = 28; // PostPeriodType, 發佈具體時段
}
message S2C {
repeated EarningsBeatItem dataList = 1; // 數據列表
optional int32 allCount = 2; // 數據總量
}
message Request {
required C2S c2s = 1;
}
message Response {
required int32 retType = 1 [default = -400]; // 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
協議 ID
3406
uint GetEarningsBeatRank(Qot_GetEarningsBeatRank.Request req);
virtual void OnReply_GetEarningsBeatRank(FTAPI_Conn client, uint nSerialNo, Qot_GetEarningsBeatRank.Response rsp);
介紹
獲取盈利超預期排名,返回指定市場中財報實際值超出預期值的股票排行列表,包含超預期比率、財報後首日漲幅、同比增長率等維度數據。
參數
// 盈利超預期類型
enum BeatType {
BeatType_Unknown = 0;
BeatType_EPS = 1; // 每股收益
BeatType_REVENUE = 2; // 營收
BeatType_EBIT = 3; // 息稅前利潤
}
// 財報週期
enum BeatTerm {
BeatTerm_Latest = 0; // 最近一期 (默認)
BeatTerm_LatestQuarter = 1; // 最近一期季報
BeatTerm_LatestHalf = 2; // 最近一期半年報
BeatTerm_LatestAnnual = 3; // 最近一期年報
BeatTerm_All = 4; // 全部(時間一樣季報優先,時間不同最近一期)
}
// 篩選條件類型
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_BeatRatio = 1; //【範圍】超預期比率
IndicatorType_ReleasedDate = 2; //【範圍】發佈時間(時間戳秒)
IndicatorType_MarketCap = 3; //【範圍】市值
IndicatorType_Price = 4; //【範圍】最新價
IndicatorType_PeTTM = 5; //【範圍】市盈率TTM
}
// 排序字段 (固定降序)
enum SortField {
SortField_Unknown = 0; // 默認按市值排序
SortField_BeatRatio = 1; // 超預期比率
SortField_EarningDayChg = 2; // 財報後首日漲幅
SortField_ReleasedDate = 3; // 發佈時間
SortField_Actual = 4; // 實際值
SortField_Estimate = 5; // 預測值
SortField_Yoy = 6; // 去年同期
SortField_YoyGrowth = 7; // 同比增長率
SortField_PeTTM = 8; // 市盈率TTM
SortField_DividendsTTM = 9; // 股息率TTM
SortField_Price = 10; // 價格
SortField_ChangeRate = 11; // 今日漲跌幅
}
// 財報發佈時段
enum PostPeriodType {
PostPeriodType_Regular = 0; // 當天(未識別出時段)
PostPeriodType_Before = 1; // 盤前
PostPeriodType_After = 2; // 盤後
PostPeriodType_IntradayTrading = 3; // 盤中
}
// 篩選條件
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.Interval indicatorValue = 2; // 篩選區間
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket (僅支持 HK=1, US=11, SG=31, JP=41)
required int32 beatType = 2; // BeatType
optional int32 count = 3; // 返回數量 [1,300], 默認30
optional int32 term = 4; // BeatTerm, 默認 All
repeated Indicator filterList = 5; // 可選篩選條件(AND關係), 不傳則使用默認值(超預期>0, 時間=最近30天)
optional int32 sortField = 6; // SortField, 排序字段(固定降序), 默認按市值
}
// 盈利超預期排行數據項
message EarningsBeatItem {
required Qot_Common.Security security = 1; // 股票
optional string name = 2; // 名稱
optional string industry = 3; // 行業
// 行情
optional double curPrice = 10; // 最新價
optional double lastClosePrice = 11; // 昨收價
optional double changeRate = 12; // 今日漲跌幅 (%)
optional double marketCap = 13; // 市值
optional double peTTM = 14; // 市盈率TTM
optional double dividendsTTM = 15; // 股息率TTM (%)
// 盈利超預期
optional string releasedDate = 20; // 發佈日期 (如 "2024-01-15")
optional double beatRatio = 21; // 超預期比率 (%)
optional double actual = 22; // 實際值
optional double estimate = 23; // 預測值
optional double yoy = 24; // 去年同期
optional double yoyGrowth = 25; // 同比增長率 (%)
optional double earningDayChg = 26; // 財報後首日漲幅 (%)
optional string term = 27; // 財報週期 (如 "2024/Q1")
optional int32 detailPostPeriod = 28; // PostPeriodType, 發佈具體時段
}
message S2C {
repeated EarningsBeatItem dataList = 1; // 數據列表
optional int32 allCount = 2; // 數據總量
}
message Request {
required C2S c2s = 1;
}
message Response {
required int32 retType = 1 [default = -400]; // 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
- 接口調用結果,結構參見 RetType
協議 ID
3406
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}
", errCode, desc, client.GetConnectID());
if (errCode != 0)
return;
QotGetEarningsBeatRank.C2S c2s = QotGetEarningsBeatRank.C2S.CreateBuilder()
.SetMarket(11)
.SetBeatType(1)
.SetCount(3)
.Build();
QotGetEarningsBeatRank.Request req = QotGetEarningsBeatRank.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetEarningsBeatRank(req);
Console.Write("Send QotGetEarningsBeatRank: {0}
", seqNo);
}
public void OnDisconnect(FTAPI_Conn client, long errCode) {
Console.Write("Qot onDisConnect: {0}
", errCode);
}
public void OnReply_GetEarningsBeatRank(FTAPI_Conn client, uint nSerialNo, QotGetEarningsBeatRank.Response rsp)
{
Console.Write("Reply: QotGetEarningsBeatRank: {0}
", nSerialNo);
if (rsp.RetType == 0 && rsp.HasS2C)
Console.Write("{0}
", rsp.ToString());
}
public static void Main(String[] args) {
FTAPI.Init();
Program program = new Program();
program.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
- Output
Send QotGetEarningsBeatRank: 3
Reply: QotGetEarningsBeatRank: 3
GetEarningsBeatRank: errCode 0, retMsg , retType 0
{
"allCount": 1282,
"dataList": [
{ "security": { "market": 11, "code": "NVDA" }, "name": "英偉達", "beatRatio": 37.253, "earningDayChg": -1.772 },
{ "security": { "market": 11, "code": "GOOGL" }, "name": "谷歌-A", "beatRatio": 91.593, "earningDayChg": 9.961 },
{ "security": { "market": 11, "code": "GOOG" }, "name": "谷歌-C", "beatRatio": 91.593, "earningDayChg": 9.970 }
]
}
2
3
4
5
6
7
8
9
10
11
int getEarningsBeatRank(Qot_GetEarningsBeatRank.Request req);
onReply_GetEarningsBeatRank(FTAPI_Conn client, int nSerialNo, Qot_GetEarningsBeatRank.Response rsp)
介紹
獲取盈利超預期排名,返回指定市場中財報實際值超出預期值的股票排行列表,包含超預期比率、財報後首日漲幅、同比增長率等維度數據。
參數
// 盈利超預期類型
enum BeatType {
BeatType_Unknown = 0;
BeatType_EPS = 1; // 每股收益
BeatType_REVENUE = 2; // 營收
BeatType_EBIT = 3; // 息稅前利潤
}
// 財報週期
enum BeatTerm {
BeatTerm_Latest = 0; // 最近一期 (默認)
BeatTerm_LatestQuarter = 1; // 最近一期季報
BeatTerm_LatestHalf = 2; // 最近一期半年報
BeatTerm_LatestAnnual = 3; // 最近一期年報
BeatTerm_All = 4; // 全部(時間一樣季報優先,時間不同最近一期)
}
// 篩選條件類型
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_BeatRatio = 1; //【範圍】超預期比率
IndicatorType_ReleasedDate = 2; //【範圍】發佈時間(時間戳秒)
IndicatorType_MarketCap = 3; //【範圍】市值
IndicatorType_Price = 4; //【範圍】最新價
IndicatorType_PeTTM = 5; //【範圍】市盈率TTM
}
// 排序字段 (固定降序)
enum SortField {
SortField_Unknown = 0; // 默認按市值排序
SortField_BeatRatio = 1; // 超預期比率
SortField_EarningDayChg = 2; // 財報後首日漲幅
SortField_ReleasedDate = 3; // 發佈時間
SortField_Actual = 4; // 實際值
SortField_Estimate = 5; // 預測值
SortField_Yoy = 6; // 去年同期
SortField_YoyGrowth = 7; // 同比增長率
SortField_PeTTM = 8; // 市盈率TTM
SortField_DividendsTTM = 9; // 股息率TTM
SortField_Price = 10; // 價格
SortField_ChangeRate = 11; // 今日漲跌幅
}
// 財報發佈時段
enum PostPeriodType {
PostPeriodType_Regular = 0; // 當天(未識別出時段)
PostPeriodType_Before = 1; // 盤前
PostPeriodType_After = 2; // 盤後
PostPeriodType_IntradayTrading = 3; // 盤中
}
// 篩選條件
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.Interval indicatorValue = 2; // 篩選區間
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket (僅支持 HK=1, US=11, SG=31, JP=41)
required int32 beatType = 2; // BeatType
optional int32 count = 3; // 返回數量 [1,300], 默認30
optional int32 term = 4; // BeatTerm, 默認 All
repeated Indicator filterList = 5; // 可選篩選條件(AND關係), 不傳則使用默認值(超預期>0, 時間=最近30天)
optional int32 sortField = 6; // SortField, 排序字段(固定降序), 默認按市值
}
// 盈利超預期排行數據項
message EarningsBeatItem {
required Qot_Common.Security security = 1; // 股票
optional string name = 2; // 名稱
optional string industry = 3; // 行業
// 行情
optional double curPrice = 10; // 最新價
optional double lastClosePrice = 11; // 昨收價
optional double changeRate = 12; // 今日漲跌幅 (%)
optional double marketCap = 13; // 市值
optional double peTTM = 14; // 市盈率TTM
optional double dividendsTTM = 15; // 股息率TTM (%)
// 盈利超預期
optional string releasedDate = 20; // 發佈日期 (如 "2024-01-15")
optional double beatRatio = 21; // 超預期比率 (%)
optional double actual = 22; // 實際值
optional double estimate = 23; // 預測值
optional double yoy = 24; // 去年同期
optional double yoyGrowth = 25; // 同比增長率 (%)
optional double earningDayChg = 26; // 財報後首日漲幅 (%)
optional string term = 27; // 財報週期 (如 "2024/Q1")
optional int32 detailPostPeriod = 28; // PostPeriodType, 發佈具體時段
}
message S2C {
repeated EarningsBeatItem dataList = 1; // 數據列表
optional int32 allCount = 2; // 數據總量
}
message Request {
required C2S c2s = 1;
}
message Response {
required int32 retType = 1 [default = -400]; // 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
- 接口調用結果,結構參見 RetType
協議 ID
3406
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=%d desc=%s connID=%d
", errCode, desc, client.getConnectID());
if (errCode != 0)
return;
QotGetEarningsBeatRank.C2S c2s = QotGetEarningsBeatRank.C2S.newBuilder()
.setMarket(11)
.setBeatType(1)
.setCount(3)
.build();
QotGetEarningsBeatRank.Request req = QotGetEarningsBeatRank.Request.newBuilder().setC2S(c2s).build();
int seqNo = qot.getEarningsBeatRank(req);
System.out.printf("Send QotGetEarningsBeatRank: %d
", seqNo);
}
@Override
public void onDisconnect(FTAPI_Conn client, long errCode) {
System.out.printf("Qot onDisConnect: %d
", errCode);
}
@Override
public void onReply_GetEarningsBeatRank(FTAPI_Conn client, int nSerialNo, QotGetEarningsBeatRank.Response rsp) {
if (rsp.getRetType() != 0) {
System.out.printf("QotGetEarningsBeatRank failed: %s
", rsp.getRetMsg());
} else {
try {
String json = JsonFormat.printer().print(rsp);
System.out.printf("Receive QotGetEarningsBeatRank: %s
", 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
67
68
- Output
Send QotGetEarningsBeatRank: 3
Receive QotGetEarningsBeatRank: {
"allCount": 1282,
"dataList": [
{ "security": { "market": 11, "code": "NVDA" }, "name": "英偉達", "beatRatio": 37.253, "earningDayChg": -1.772 },
{ "security": { "market": 11, "code": "GOOGL" }, "name": "谷歌-A", "beatRatio": 91.593, "earningDayChg": 9.961 },
{ "security": { "market": 11, "code": "GOOG" }, "name": "谷歌-C", "beatRatio": 91.593, "earningDayChg": 9.970 }
]
}
2
3
4
5
6
7
8
9
Futu::u32_t GetEarningsBeatRank(const Qot_GetEarningsBeatRank::Request &stReq);
virtual void OnReply_GetEarningsBeatRank(Futu::u32_t nSerialNo, const Qot_GetEarningsBeatRank::Response &stRsp) = 0;
介紹
協議請求及回應定義
參數
// 盈利超預期類型
enum BeatType {
BeatType_Unknown = 0;
BeatType_EPS = 1; // 每股收益
BeatType_REVENUE = 2; // 營收
BeatType_EBIT = 3; // 息稅前利潤
}
// 財報週期
enum BeatTerm {
BeatTerm_Latest = 0; // 最近一期 (默認)
BeatTerm_LatestQuarter = 1; // 最近一期季報
BeatTerm_LatestHalf = 2; // 最近一期半年報
BeatTerm_LatestAnnual = 3; // 最近一期年報
BeatTerm_All = 4; // 全部(時間一樣季報優先,時間不同最近一期)
}
// 篩選條件類型
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_BeatRatio = 1; //【範圍】超預期比率
IndicatorType_ReleasedDate = 2; //【範圍】發佈時間(時間戳秒)
IndicatorType_MarketCap = 3; //【範圍】市值
IndicatorType_Price = 4; //【範圍】最新價
IndicatorType_PeTTM = 5; //【範圍】市盈率TTM
}
// 排序字段 (固定降序)
enum SortField {
SortField_Unknown = 0; // 默認按市值排序
SortField_BeatRatio = 1; // 超預期比率
SortField_EarningDayChg = 2; // 財報後首日漲幅
SortField_ReleasedDate = 3; // 發佈時間
SortField_Actual = 4; // 實際值
SortField_Estimate = 5; // 預測值
SortField_Yoy = 6; // 去年同期
SortField_YoyGrowth = 7; // 同比增長率
SortField_PeTTM = 8; // 市盈率TTM
SortField_DividendsTTM = 9; // 股息率TTM
SortField_Price = 10; // 價格
SortField_ChangeRate = 11; // 今日漲跌幅
}
// 財報發佈時段
enum PostPeriodType {
PostPeriodType_Regular = 0; // 當天(未識別出時段)
PostPeriodType_Before = 1; // 盤前
PostPeriodType_After = 2; // 盤後
PostPeriodType_IntradayTrading = 3; // 盤中
}
// 篩選條件
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.Interval indicatorValue = 2; // 篩選區間
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket (僅支持 HK=1, US=11, SG=31, JP=41)
required int32 beatType = 2; // BeatType
optional int32 count = 3; // 返回數量 [1,300], 默認30
optional int32 term = 4; // BeatTerm, 默認 All
repeated Indicator filterList = 5; // 可選篩選條件(AND關係), 不傳則使用默認值(超預期>0, 時間=最近30天)
optional int32 sortField = 6; // SortField, 排序字段(固定降序), 默認按市值
}
// 盈利超預期排行數據項
message EarningsBeatItem {
required Qot_Common.Security security = 1; // 股票
optional string name = 2; // 名稱
optional string industry = 3; // 行業
// 行情
optional double curPrice = 10; // 最新價
optional double lastClosePrice = 11; // 昨收價
optional double changeRate = 12; // 今日漲跌幅 (%)
optional double marketCap = 13; // 市值
optional double peTTM = 14; // 市盈率TTM
optional double dividendsTTM = 15; // 股息率TTM (%)
// 盈利超預期
optional string releasedDate = 20; // 發佈日期 (如 "2024-01-15")
optional double beatRatio = 21; // 超預期比率 (%)
optional double actual = 22; // 實際值
optional double estimate = 23; // 預測值
optional double yoy = 24; // 去年同期
optional double yoyGrowth = 25; // 同比增長率 (%)
optional double earningDayChg = 26; // 財報後首日漲幅 (%)
optional string term = 27; // 財報週期 (如 "2024/Q1")
optional int32 detailPostPeriod = 28; // PostPeriodType, 發佈具體時段
}
message S2C {
repeated EarningsBeatItem dataList = 1; // 數據列表
optional int32 allCount = 2; // 數據總量
}
message Request {
required C2S c2s = 1;
}
message Response {
required int32 retType = 1 [default = -400]; // 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
- 介面呼叫結果,結構參見 RetType
協議 ID
3406
Example
class Program : public FTSPI_Qot, 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) {
Qot_GetEarningsBeatRank::Request req;
Qot_GetEarningsBeatRank::C2S *c2s = req.mutable_c2s();
c2s->set_market(Qot_Common::QotMarket::QotMarket_US_Security);
c2s->set_beattype(1); // BeatType_EPS
c2s->set_count(30);
m_GetEarningsBeatRankSerialNo = m_pQotApi->GetEarningsBeatRank(req);
}
virtual void OnReply_GetEarningsBeatRank(Futu::u32_t nSerialNo, const Qot_GetEarningsBeatRank::Response &stRsp) {
if (nSerialNo != m_GetEarningsBeatRankSerialNo) return;
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
FTAPI_Qot *m_pQotApi;
Futu::u32_t m_GetEarningsBeatRankSerialNo = 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
- Output
{
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"dataList": [
{
"security": {
"market": 11,
"code": "NVDA"
},
"name": "NVIDIA",
"industry": "Semiconductor",
"curPrice": 875.4,
"changeRate": 9.32,
"marketCap": 2150000000000.0,
"peTTM": 65.2
}
],
"allCount": 30
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
getEarningsBeatRank(qotGetEarningsBeatRank)
介紹
獲取盈利超預期排名,返回指定市場中財報實際值超出預期值的股票排行列表,包含超預期比率、財報後首日漲幅、同比增長率等維度數據。
參數
// 盈利超預期類型
enum BeatType {
BeatType_Unknown = 0;
BeatType_EPS = 1; // 每股收益
BeatType_REVENUE = 2; // 營收
BeatType_EBIT = 3; // 息稅前利潤
}
// 財報週期
enum BeatTerm {
BeatTerm_Latest = 0; // 最近一期 (默認)
BeatTerm_LatestQuarter = 1; // 最近一期季報
BeatTerm_LatestHalf = 2; // 最近一期半年報
BeatTerm_LatestAnnual = 3; // 最近一期年報
BeatTerm_All = 4; // 全部(時間一樣季報優先,時間不同最近一期)
}
// 篩選條件類型
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_BeatRatio = 1; //【範圍】超預期比率
IndicatorType_ReleasedDate = 2; //【範圍】發佈時間(時間戳秒)
IndicatorType_MarketCap = 3; //【範圍】市值
IndicatorType_Price = 4; //【範圍】最新價
IndicatorType_PeTTM = 5; //【範圍】市盈率TTM
}
// 排序字段 (固定降序)
enum SortField {
SortField_Unknown = 0; // 默認按市值排序
SortField_BeatRatio = 1; // 超預期比率
SortField_EarningDayChg = 2; // 財報後首日漲幅
SortField_ReleasedDate = 3; // 發佈時間
SortField_Actual = 4; // 實際值
SortField_Estimate = 5; // 預測值
SortField_Yoy = 6; // 去年同期
SortField_YoyGrowth = 7; // 同比增長率
SortField_PeTTM = 8; // 市盈率TTM
SortField_DividendsTTM = 9; // 股息率TTM
SortField_Price = 10; // 價格
SortField_ChangeRate = 11; // 今日漲跌幅
}
// 財報發佈時段
enum PostPeriodType {
PostPeriodType_Regular = 0; // 當天(未識別出時段)
PostPeriodType_Before = 1; // 盤前
PostPeriodType_After = 2; // 盤後
PostPeriodType_IntradayTrading = 3; // 盤中
}
// 篩選條件
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.Interval indicatorValue = 2; // 篩選區間
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket (僅支持 HK=1, US=11, SG=31, JP=41)
required int32 beatType = 2; // BeatType
optional int32 count = 3; // 返回數量 [1,300], 默認30
optional int32 term = 4; // BeatTerm, 默認 All
repeated Indicator filterList = 5; // 可選篩選條件(AND關係), 不傳則使用默認值(超預期>0, 時間=最近30天)
optional int32 sortField = 6; // SortField, 排序字段(固定降序), 默認按市值
}
// 盈利超預期排行數據項
message EarningsBeatItem {
required Qot_Common.Security security = 1; // 股票
optional string name = 2; // 名稱
optional string industry = 3; // 行業
// 行情
optional double curPrice = 10; // 最新價
optional double lastClosePrice = 11; // 昨收價
optional double changeRate = 12; // 今日漲跌幅 (%)
optional double marketCap = 13; // 市值
optional double peTTM = 14; // 市盈率TTM
optional double dividendsTTM = 15; // 股息率TTM (%)
// 盈利超預期
optional string releasedDate = 20; // 發佈日期 (如 "2024-01-15")
optional double beatRatio = 21; // 超預期比率 (%)
optional double actual = 22; // 實際值
optional double estimate = 23; // 預測值
optional double yoy = 24; // 去年同期
optional double yoyGrowth = 25; // 同比增長率 (%)
optional double earningDayChg = 26; // 財報後首日漲幅 (%)
optional string term = 27; // 財報週期 (如 "2024/Q1")
optional int32 detailPostPeriod = 28; // PostPeriodType, 發佈具體時段
}
message S2C {
repeated EarningsBeatItem dataList = 1; // 數據列表
optional int32 allCount = 2; // 數據總量
}
message Request {
required C2S c2s = 1;
}
message Response {
required int32 retType = 1 [default = -400]; // 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
- 接口調用結果,結構參見 RetType
協議 ID
3406
Example
import ftWebsocket from "futu-api";
import { Common, Qot_Common } from "futu-api/proto";
import beautify from "js-beautify";
function QotGetEarningsBeatRank(){
const { RetType } = Common
let [addr, port, enable_ssl, key] = ["127.0.0.1", 11111, false, "xxxxxx"];
let websocket = new ftWebsocket();
websocket.onlogin = (ret, msg)=>{
if (ret) {
const req = {
c2s: { market: 11, beatType: 1, count: 3 },
};
websocket.GetEarningsBeatRank(req)
.then((res)=>{
let { errCode, retMsg, retType, s2c } = res
console.log("GetEarningsBeatRank: 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("start error", msg);
}
};
websocket.start(addr, port, enable_ssl, key);
setTimeout(()=>{ websocket.stop(); process.exit(); }, 5000);
}
QotGetEarningsBeatRank()
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
- Output
GetEarningsBeatRank: errCode 0, retMsg , retType 0
{
"allCount": 1282,
"dataList": [
{ "security": { "market": 11, "code": "NVDA" }, "name": "英偉達", "beatRatio": 37.253, "earningDayChg": -1.772 },
{ "security": { "market": 11, "code": "GOOGL" }, "name": "谷歌-A", "beatRatio": 91.593, "earningDayChg": 9.961 },
{ "security": { "market": 11, "code": "GOOG" }, "name": "谷歌-C", "beatRatio": 91.593, "earningDayChg": 9.970 }
]
}
2
3
4
5
6
7
8
9
接口限制
- 30 秒內最多 60 次請求
- 分頁請求僅首頁計入限頻統計
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_earnings_beat_rank(market, beat_type, count=None, term=None, filter_list=None, sort_field=None)
介紹
獲取盈利超預期排名,返回指定市場中財報實際值超出預期值的股票排行列表,包含超預期比率、財報後首日漲幅、同比增長率等維度數據。
參數
參數 類型 說明 market Market 市場類型(支持 HK/US/SG/JP)(必填) beat_type BeatType 超預期類型(必填) count int 返回數量 [1, 300],默認 30 term BeatTerm 財報週期,默認 ALL filter_list list[ EarningsBeatRankFilter]篩選條件列表(多條件爲 AND 關係) sort_field EarningsBeatSortField 排序字段(固定降序),默認按市值 輸入限制
filter_list篩選條件(EarningsBeatRankFilter):通過
EarningsBeatRankFilter構造篩選條件,僅支持範圍篩選:構造參數 說明 indicator_type篩選因子類型( EarningsBeatIndicatorType,必填)interval_min範圍最小值(閉區間) interval_max範圍最大值(閉區間) 不傳
filter_list時使用默認篩選:超預期比率 > 0,發佈時間爲最近 30 天。
返回
參數 類型 說明 ret RET_CODE 接口調用結果 data pd.DataFrame 當 ret == RET_OK,返回 (all_count, DataFrame) 元組 str 當 ret != RET_OK,返回錯誤描述 - 數據格式如下:
字段 類型 說明 security str 股票代碼(如 'US.AAPL')name str 股票名稱 industry str 所屬行業 cur_price float 最新價 last_close_price float 昨收價 change_rate float 今日漲跌幅(%) market_cap float 市值 pe_ttm float 市盈率 TTM dividends_ttm float 股息率 TTM(%) released_date str 財報發佈日期(如 '2024-01-15')beat_ratio float 超預期比率(%) actual float 實際值 estimate float 預測值 yoy float 去年同期 yoy_growth float 同比增長率(%) earning_day_chg float 財報後首日漲幅(%) term str 財報週期(如 '2024/Q1')detail_post_period str 發佈時段(BEFORE=盤前 / AFTER=盤後 / REGULAR=當天 / INTRADAY_TRADING=盤中)
- 數據格式如下:
Example
from futu import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data = quote_ctx.get_earnings_beat_rank(market=Market.US, beat_type=BeatType.EPS, count=2)
if ret == RET_OK:
all_count, df = data
print(f'總數據量: {all_count}')
print(df)
else:
print('error:', data)
quote_ctx.close()
2
3
4
5
6
7
8
9
10
11
12
13
- Output
總數據量: 1276
security name industry cur_price last_close_price change_rate market_cap pe_ttm dividends_ttm released_date beat_ratio actual estimate yoy yoy_growth earning_day_chg term detail_post_period
0 US.NVDA 英偉達 半導體 200.04 208.65 -4.126 4.840968e+12 30.63399 0.019 2026-05-20 37.253 2.3900 1.7413 0.76 214.473 -1.772 2027/Q1 AFTER
1 US.AAPL 蘋果 消費電子產品 294.30 297.01 -0.912 4.322489e+12 35.62953 0.353 2026-04-30 3.373 2.0099 1.9444 1.65 21.818 3.239 2026/Q2 AFTER
2
3
4
# Qot_GetEarningsBeatRank.proto
介紹
獲取盈利超預期排名,返回指定市場中財報實際值超出預期值的股票排行列表,包含超預期比率、財報後首日漲幅、同比增長率等維度數據。
參數
// 盈利超預期類型
enum BeatType {
BeatType_Unknown = 0;
BeatType_EPS = 1; // 每股收益
BeatType_REVENUE = 2; // 營收
BeatType_EBIT = 3; // 息稅前利潤
}
// 財報週期
enum BeatTerm {
BeatTerm_Latest = 0; // 最近一期 (默認)
BeatTerm_LatestQuarter = 1; // 最近一期季報
BeatTerm_LatestHalf = 2; // 最近一期半年報
BeatTerm_LatestAnnual = 3; // 最近一期年報
BeatTerm_All = 4; // 全部(時間一樣季報優先,時間不同最近一期)
}
// 篩選條件類型
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_BeatRatio = 1; //【範圍】超預期比率
IndicatorType_ReleasedDate = 2; //【範圍】發佈時間(時間戳秒)
IndicatorType_MarketCap = 3; //【範圍】市值
IndicatorType_Price = 4; //【範圍】最新價
IndicatorType_PeTTM = 5; //【範圍】市盈率TTM
}
// 排序字段 (固定降序)
enum SortField {
SortField_Unknown = 0; // 默認按市值排序
SortField_BeatRatio = 1; // 超預期比率
SortField_EarningDayChg = 2; // 財報後首日漲幅
SortField_ReleasedDate = 3; // 發佈時間
SortField_Actual = 4; // 實際值
SortField_Estimate = 5; // 預測值
SortField_Yoy = 6; // 去年同期
SortField_YoyGrowth = 7; // 同比增長率
SortField_PeTTM = 8; // 市盈率TTM
SortField_DividendsTTM = 9; // 股息率TTM
SortField_Price = 10; // 價格
SortField_ChangeRate = 11; // 今日漲跌幅
}
// 財報發佈時段
enum PostPeriodType {
PostPeriodType_Regular = 0; // 當天(未識別出時段)
PostPeriodType_Before = 1; // 盤前
PostPeriodType_After = 2; // 盤後
PostPeriodType_IntradayTrading = 3; // 盤中
}
// 篩選條件
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.Interval indicatorValue = 2; // 篩選區間
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket (僅支持 HK=1, US=11, SG=31, JP=41)
required int32 beatType = 2; // BeatType
optional int32 count = 3; // 返回數量 [1,300], 默認30
optional int32 term = 4; // BeatTerm, 默認 All
repeated Indicator filterList = 5; // 可選篩選條件(AND關係), 不傳則使用默認值(超預期>0, 時間=最近30天)
optional int32 sortField = 6; // SortField, 排序字段(固定降序), 默認按市值
}
// 盈利超預期排行數據項
message EarningsBeatItem {
required Qot_Common.Security security = 1; // 股票
optional string name = 2; // 名稱
optional string industry = 3; // 行業
// 行情
optional double curPrice = 10; // 最新價
optional double lastClosePrice = 11; // 昨收價
optional double changeRate = 12; // 今日漲跌幅 (%)
optional double marketCap = 13; // 市值
optional double peTTM = 14; // 市盈率TTM
optional double dividendsTTM = 15; // 股息率TTM (%)
// 盈利超預期
optional string releasedDate = 20; // 發佈日期 (如 "2024-01-15")
optional double beatRatio = 21; // 超預期比率 (%)
optional double actual = 22; // 實際值
optional double estimate = 23; // 預測值
optional double yoy = 24; // 去年同期
optional double yoyGrowth = 25; // 同比增長率 (%)
optional double earningDayChg = 26; // 財報後首日漲幅 (%)
optional string term = 27; // 財報週期 (如 "2024/Q1")
optional int32 detailPostPeriod = 28; // PostPeriodType, 發佈具體時段
}
message S2C {
repeated EarningsBeatItem dataList = 1; // 數據列表
optional int32 allCount = 2; // 數據總量
}
message Request {
required C2S c2s = 1;
}
message Response {
required int32 retType = 1 [default = -400]; // 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
協議 ID
3406
uint GetEarningsBeatRank(Qot_GetEarningsBeatRank.Request req);
virtual void OnReply_GetEarningsBeatRank(FTAPI_Conn client, uint nSerialNo, Qot_GetEarningsBeatRank.Response rsp);
介紹
獲取盈利超預期排名,返回指定市場中財報實際值超出預期值的股票排行列表,包含超預期比率、財報後首日漲幅、同比增長率等維度數據。
參數
// 盈利超預期類型
enum BeatType {
BeatType_Unknown = 0;
BeatType_EPS = 1; // 每股收益
BeatType_REVENUE = 2; // 營收
BeatType_EBIT = 3; // 息稅前利潤
}
// 財報週期
enum BeatTerm {
BeatTerm_Latest = 0; // 最近一期 (默認)
BeatTerm_LatestQuarter = 1; // 最近一期季報
BeatTerm_LatestHalf = 2; // 最近一期半年報
BeatTerm_LatestAnnual = 3; // 最近一期年報
BeatTerm_All = 4; // 全部(時間一樣季報優先,時間不同最近一期)
}
// 篩選條件類型
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_BeatRatio = 1; //【範圍】超預期比率
IndicatorType_ReleasedDate = 2; //【範圍】發佈時間(時間戳秒)
IndicatorType_MarketCap = 3; //【範圍】市值
IndicatorType_Price = 4; //【範圍】最新價
IndicatorType_PeTTM = 5; //【範圍】市盈率TTM
}
// 排序字段 (固定降序)
enum SortField {
SortField_Unknown = 0; // 默認按市值排序
SortField_BeatRatio = 1; // 超預期比率
SortField_EarningDayChg = 2; // 財報後首日漲幅
SortField_ReleasedDate = 3; // 發佈時間
SortField_Actual = 4; // 實際值
SortField_Estimate = 5; // 預測值
SortField_Yoy = 6; // 去年同期
SortField_YoyGrowth = 7; // 同比增長率
SortField_PeTTM = 8; // 市盈率TTM
SortField_DividendsTTM = 9; // 股息率TTM
SortField_Price = 10; // 價格
SortField_ChangeRate = 11; // 今日漲跌幅
}
// 財報發佈時段
enum PostPeriodType {
PostPeriodType_Regular = 0; // 當天(未識別出時段)
PostPeriodType_Before = 1; // 盤前
PostPeriodType_After = 2; // 盤後
PostPeriodType_IntradayTrading = 3; // 盤中
}
// 篩選條件
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.Interval indicatorValue = 2; // 篩選區間
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket (僅支持 HK=1, US=11, SG=31, JP=41)
required int32 beatType = 2; // BeatType
optional int32 count = 3; // 返回數量 [1,300], 默認30
optional int32 term = 4; // BeatTerm, 默認 All
repeated Indicator filterList = 5; // 可選篩選條件(AND關係), 不傳則使用默認值(超預期>0, 時間=最近30天)
optional int32 sortField = 6; // SortField, 排序字段(固定降序), 默認按市值
}
// 盈利超預期排行數據項
message EarningsBeatItem {
required Qot_Common.Security security = 1; // 股票
optional string name = 2; // 名稱
optional string industry = 3; // 行業
// 行情
optional double curPrice = 10; // 最新價
optional double lastClosePrice = 11; // 昨收價
optional double changeRate = 12; // 今日漲跌幅 (%)
optional double marketCap = 13; // 市值
optional double peTTM = 14; // 市盈率TTM
optional double dividendsTTM = 15; // 股息率TTM (%)
// 盈利超預期
optional string releasedDate = 20; // 發佈日期 (如 "2024-01-15")
optional double beatRatio = 21; // 超預期比率 (%)
optional double actual = 22; // 實際值
optional double estimate = 23; // 預測值
optional double yoy = 24; // 去年同期
optional double yoyGrowth = 25; // 同比增長率 (%)
optional double earningDayChg = 26; // 財報後首日漲幅 (%)
optional string term = 27; // 財報週期 (如 "2024/Q1")
optional int32 detailPostPeriod = 28; // PostPeriodType, 發佈具體時段
}
message S2C {
repeated EarningsBeatItem dataList = 1; // 數據列表
optional int32 allCount = 2; // 數據總量
}
message Request {
required C2S c2s = 1;
}
message Response {
required int32 retType = 1 [default = -400]; // 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
- 接口調用結果,結構參見 RetType
協議 ID
3406
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}
", errCode, desc, client.GetConnectID());
if (errCode != 0)
return;
QotGetEarningsBeatRank.C2S c2s = QotGetEarningsBeatRank.C2S.CreateBuilder()
.SetMarket(11)
.SetBeatType(1)
.SetCount(3)
.Build();
QotGetEarningsBeatRank.Request req = QotGetEarningsBeatRank.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetEarningsBeatRank(req);
Console.Write("Send QotGetEarningsBeatRank: {0}
", seqNo);
}
public void OnDisconnect(MMAPI_Conn client, long errCode) {
Console.Write("Qot onDisConnect: {0}
", errCode);
}
public void OnReply_GetEarningsBeatRank(MMAPI_Conn client, uint nSerialNo, QotGetEarningsBeatRank.Response rsp)
{
Console.Write("Reply: QotGetEarningsBeatRank: {0}
", nSerialNo);
if (rsp.RetType == 0 && rsp.HasS2C)
Console.Write("{0}
", rsp.ToString());
}
public static void Main(String[] args) {
MMAPI.Init();
Program program = new Program();
program.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
- Output
Send QotGetEarningsBeatRank: 3
Reply: QotGetEarningsBeatRank: 3
GetEarningsBeatRank: errCode 0, retMsg , retType 0
{
"allCount": 1282,
"dataList": [
{ "security": { "market": 11, "code": "NVDA" }, "name": "英偉達", "beatRatio": 37.253, "earningDayChg": -1.772 },
{ "security": { "market": 11, "code": "GOOGL" }, "name": "谷歌-A", "beatRatio": 91.593, "earningDayChg": 9.961 },
{ "security": { "market": 11, "code": "GOOG" }, "name": "谷歌-C", "beatRatio": 91.593, "earningDayChg": 9.970 }
]
}
2
3
4
5
6
7
8
9
10
11
int getEarningsBeatRank(Qot_GetEarningsBeatRank.Request req);
onReply_GetEarningsBeatRank(FTAPI_Conn client, int nSerialNo, Qot_GetEarningsBeatRank.Response rsp)
介紹
獲取盈利超預期排名,返回指定市場中財報實際值超出預期值的股票排行列表,包含超預期比率、財報後首日漲幅、同比增長率等維度數據。
參數
// 盈利超預期類型
enum BeatType {
BeatType_Unknown = 0;
BeatType_EPS = 1; // 每股收益
BeatType_REVENUE = 2; // 營收
BeatType_EBIT = 3; // 息稅前利潤
}
// 財報週期
enum BeatTerm {
BeatTerm_Latest = 0; // 最近一期 (默認)
BeatTerm_LatestQuarter = 1; // 最近一期季報
BeatTerm_LatestHalf = 2; // 最近一期半年報
BeatTerm_LatestAnnual = 3; // 最近一期年報
BeatTerm_All = 4; // 全部(時間一樣季報優先,時間不同最近一期)
}
// 篩選條件類型
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_BeatRatio = 1; //【範圍】超預期比率
IndicatorType_ReleasedDate = 2; //【範圍】發佈時間(時間戳秒)
IndicatorType_MarketCap = 3; //【範圍】市值
IndicatorType_Price = 4; //【範圍】最新價
IndicatorType_PeTTM = 5; //【範圍】市盈率TTM
}
// 排序字段 (固定降序)
enum SortField {
SortField_Unknown = 0; // 默認按市值排序
SortField_BeatRatio = 1; // 超預期比率
SortField_EarningDayChg = 2; // 財報後首日漲幅
SortField_ReleasedDate = 3; // 發佈時間
SortField_Actual = 4; // 實際值
SortField_Estimate = 5; // 預測值
SortField_Yoy = 6; // 去年同期
SortField_YoyGrowth = 7; // 同比增長率
SortField_PeTTM = 8; // 市盈率TTM
SortField_DividendsTTM = 9; // 股息率TTM
SortField_Price = 10; // 價格
SortField_ChangeRate = 11; // 今日漲跌幅
}
// 財報發佈時段
enum PostPeriodType {
PostPeriodType_Regular = 0; // 當天(未識別出時段)
PostPeriodType_Before = 1; // 盤前
PostPeriodType_After = 2; // 盤後
PostPeriodType_IntradayTrading = 3; // 盤中
}
// 篩選條件
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.Interval indicatorValue = 2; // 篩選區間
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket (僅支持 HK=1, US=11, SG=31, JP=41)
required int32 beatType = 2; // BeatType
optional int32 count = 3; // 返回數量 [1,300], 默認30
optional int32 term = 4; // BeatTerm, 默認 All
repeated Indicator filterList = 5; // 可選篩選條件(AND關係), 不傳則使用默認值(超預期>0, 時間=最近30天)
optional int32 sortField = 6; // SortField, 排序字段(固定降序), 默認按市值
}
// 盈利超預期排行數據項
message EarningsBeatItem {
required Qot_Common.Security security = 1; // 股票
optional string name = 2; // 名稱
optional string industry = 3; // 行業
// 行情
optional double curPrice = 10; // 最新價
optional double lastClosePrice = 11; // 昨收價
optional double changeRate = 12; // 今日漲跌幅 (%)
optional double marketCap = 13; // 市值
optional double peTTM = 14; // 市盈率TTM
optional double dividendsTTM = 15; // 股息率TTM (%)
// 盈利超預期
optional string releasedDate = 20; // 發佈日期 (如 "2024-01-15")
optional double beatRatio = 21; // 超預期比率 (%)
optional double actual = 22; // 實際值
optional double estimate = 23; // 預測值
optional double yoy = 24; // 去年同期
optional double yoyGrowth = 25; // 同比增長率 (%)
optional double earningDayChg = 26; // 財報後首日漲幅 (%)
optional string term = 27; // 財報週期 (如 "2024/Q1")
optional int32 detailPostPeriod = 28; // PostPeriodType, 發佈具體時段
}
message S2C {
repeated EarningsBeatItem dataList = 1; // 數據列表
optional int32 allCount = 2; // 數據總量
}
message Request {
required C2S c2s = 1;
}
message Response {
required int32 retType = 1 [default = -400]; // 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
- 接口調用結果,結構參見 RetType
協議 ID
3406
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=%d desc=%s connID=%d
", errCode, desc, client.getConnectID());
if (errCode != 0)
return;
QotGetEarningsBeatRank.C2S c2s = QotGetEarningsBeatRank.C2S.newBuilder()
.setMarket(11)
.setBeatType(1)
.setCount(3)
.build();
QotGetEarningsBeatRank.Request req = QotGetEarningsBeatRank.Request.newBuilder().setC2S(c2s).build();
int seqNo = qot.getEarningsBeatRank(req);
System.out.printf("Send QotGetEarningsBeatRank: %d
", seqNo);
}
@Override
public void onDisconnect(MMAPI_Conn client, long errCode) {
System.out.printf("Qot onDisConnect: %d
", errCode);
}
@Override
public void onReply_GetEarningsBeatRank(MMAPI_Conn client, int nSerialNo, QotGetEarningsBeatRank.Response rsp) {
if (rsp.getRetType() != 0) {
System.out.printf("QotGetEarningsBeatRank failed: %s
", rsp.getRetMsg());
} else {
try {
String json = JsonFormat.printer().print(rsp);
System.out.printf("Receive QotGetEarningsBeatRank: %s
", 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
67
68
- Output
Send QotGetEarningsBeatRank: 3
Receive QotGetEarningsBeatRank: {
"allCount": 1282,
"dataList": [
{ "security": { "market": 11, "code": "NVDA" }, "name": "英偉達", "beatRatio": 37.253, "earningDayChg": -1.772 },
{ "security": { "market": 11, "code": "GOOGL" }, "name": "谷歌-A", "beatRatio": 91.593, "earningDayChg": 9.961 },
{ "security": { "market": 11, "code": "GOOG" }, "name": "谷歌-C", "beatRatio": 91.593, "earningDayChg": 9.970 }
]
}
2
3
4
5
6
7
8
9
moomoo::u32_t GetEarningsBeatRank(const Qot_GetEarningsBeatRank::Request &stReq);
virtual void OnReply_GetEarningsBeatRank(moomoo::u32_t nSerialNo, const Qot_GetEarningsBeatRank::Response &stRsp) = 0;
介紹
協議請求及回應定義
參數
// 盈利超預期類型
enum BeatType {
BeatType_Unknown = 0;
BeatType_EPS = 1; // 每股收益
BeatType_REVENUE = 2; // 營收
BeatType_EBIT = 3; // 息稅前利潤
}
// 財報週期
enum BeatTerm {
BeatTerm_Latest = 0; // 最近一期 (默認)
BeatTerm_LatestQuarter = 1; // 最近一期季報
BeatTerm_LatestHalf = 2; // 最近一期半年報
BeatTerm_LatestAnnual = 3; // 最近一期年報
BeatTerm_All = 4; // 全部(時間一樣季報優先,時間不同最近一期)
}
// 篩選條件類型
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_BeatRatio = 1; //【範圍】超預期比率
IndicatorType_ReleasedDate = 2; //【範圍】發佈時間(時間戳秒)
IndicatorType_MarketCap = 3; //【範圍】市值
IndicatorType_Price = 4; //【範圍】最新價
IndicatorType_PeTTM = 5; //【範圍】市盈率TTM
}
// 排序字段 (固定降序)
enum SortField {
SortField_Unknown = 0; // 默認按市值排序
SortField_BeatRatio = 1; // 超預期比率
SortField_EarningDayChg = 2; // 財報後首日漲幅
SortField_ReleasedDate = 3; // 發佈時間
SortField_Actual = 4; // 實際值
SortField_Estimate = 5; // 預測值
SortField_Yoy = 6; // 去年同期
SortField_YoyGrowth = 7; // 同比增長率
SortField_PeTTM = 8; // 市盈率TTM
SortField_DividendsTTM = 9; // 股息率TTM
SortField_Price = 10; // 價格
SortField_ChangeRate = 11; // 今日漲跌幅
}
// 財報發佈時段
enum PostPeriodType {
PostPeriodType_Regular = 0; // 當天(未識別出時段)
PostPeriodType_Before = 1; // 盤前
PostPeriodType_After = 2; // 盤後
PostPeriodType_IntradayTrading = 3; // 盤中
}
// 篩選條件
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.Interval indicatorValue = 2; // 篩選區間
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket (僅支持 HK=1, US=11, SG=31, JP=41)
required int32 beatType = 2; // BeatType
optional int32 count = 3; // 返回數量 [1,300], 默認30
optional int32 term = 4; // BeatTerm, 默認 All
repeated Indicator filterList = 5; // 可選篩選條件(AND關係), 不傳則使用默認值(超預期>0, 時間=最近30天)
optional int32 sortField = 6; // SortField, 排序字段(固定降序), 默認按市值
}
// 盈利超預期排行數據項
message EarningsBeatItem {
required Qot_Common.Security security = 1; // 股票
optional string name = 2; // 名稱
optional string industry = 3; // 行業
// 行情
optional double curPrice = 10; // 最新價
optional double lastClosePrice = 11; // 昨收價
optional double changeRate = 12; // 今日漲跌幅 (%)
optional double marketCap = 13; // 市值
optional double peTTM = 14; // 市盈率TTM
optional double dividendsTTM = 15; // 股息率TTM (%)
// 盈利超預期
optional string releasedDate = 20; // 發佈日期 (如 "2024-01-15")
optional double beatRatio = 21; // 超預期比率 (%)
optional double actual = 22; // 實際值
optional double estimate = 23; // 預測值
optional double yoy = 24; // 去年同期
optional double yoyGrowth = 25; // 同比增長率 (%)
optional double earningDayChg = 26; // 財報後首日漲幅 (%)
optional string term = 27; // 財報週期 (如 "2024/Q1")
optional int32 detailPostPeriod = 28; // PostPeriodType, 發佈具體時段
}
message S2C {
repeated EarningsBeatItem dataList = 1; // 數據列表
optional int32 allCount = 2; // 數據總量
}
message Request {
required C2S c2s = 1;
}
message Response {
required int32 retType = 1 [default = -400]; // 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
- 介面呼叫結果,結構參見 RetType
協議 ID
3406
Example
class Program : public MMSPI_Qot, 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) {
Qot_GetEarningsBeatRank::Request req;
Qot_GetEarningsBeatRank::C2S *c2s = req.mutable_c2s();
c2s->set_market(Qot_Common::QotMarket::QotMarket_US_Security);
c2s->set_beattype(1); // BeatType_EPS
c2s->set_count(30);
m_GetEarningsBeatRankSerialNo = m_pQotApi->GetEarningsBeatRank(req);
}
virtual void OnReply_GetEarningsBeatRank(moomoo::u32_t nSerialNo, const Qot_GetEarningsBeatRank::Response &stRsp) {
if (nSerialNo != m_GetEarningsBeatRankSerialNo) return;
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
MMAPI_Qot *m_pQotApi;
moomoo::u32_t m_GetEarningsBeatRankSerialNo = 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
- Output
{
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"dataList": [
{
"security": {
"market": 11,
"code": "NVDA"
},
"name": "NVIDIA",
"industry": "Semiconductor",
"curPrice": 875.4,
"changeRate": 9.32,
"marketCap": 2150000000000.0,
"peTTM": 65.2
}
],
"allCount": 30
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
getEarningsBeatRank(qotGetEarningsBeatRank)
介紹
獲取盈利超預期排名,返回指定市場中財報實際值超出預期值的股票排行列表,包含超預期比率、財報後首日漲幅、同比增長率等維度數據。
參數
// 盈利超預期類型
enum BeatType {
BeatType_Unknown = 0;
BeatType_EPS = 1; // 每股收益
BeatType_REVENUE = 2; // 營收
BeatType_EBIT = 3; // 息稅前利潤
}
// 財報週期
enum BeatTerm {
BeatTerm_Latest = 0; // 最近一期 (默認)
BeatTerm_LatestQuarter = 1; // 最近一期季報
BeatTerm_LatestHalf = 2; // 最近一期半年報
BeatTerm_LatestAnnual = 3; // 最近一期年報
BeatTerm_All = 4; // 全部(時間一樣季報優先,時間不同最近一期)
}
// 篩選條件類型
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_BeatRatio = 1; //【範圍】超預期比率
IndicatorType_ReleasedDate = 2; //【範圍】發佈時間(時間戳秒)
IndicatorType_MarketCap = 3; //【範圍】市值
IndicatorType_Price = 4; //【範圍】最新價
IndicatorType_PeTTM = 5; //【範圍】市盈率TTM
}
// 排序字段 (固定降序)
enum SortField {
SortField_Unknown = 0; // 默認按市值排序
SortField_BeatRatio = 1; // 超預期比率
SortField_EarningDayChg = 2; // 財報後首日漲幅
SortField_ReleasedDate = 3; // 發佈時間
SortField_Actual = 4; // 實際值
SortField_Estimate = 5; // 預測值
SortField_Yoy = 6; // 去年同期
SortField_YoyGrowth = 7; // 同比增長率
SortField_PeTTM = 8; // 市盈率TTM
SortField_DividendsTTM = 9; // 股息率TTM
SortField_Price = 10; // 價格
SortField_ChangeRate = 11; // 今日漲跌幅
}
// 財報發佈時段
enum PostPeriodType {
PostPeriodType_Regular = 0; // 當天(未識別出時段)
PostPeriodType_Before = 1; // 盤前
PostPeriodType_After = 2; // 盤後
PostPeriodType_IntradayTrading = 3; // 盤中
}
// 篩選條件
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.Interval indicatorValue = 2; // 篩選區間
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket (僅支持 HK=1, US=11, SG=31, JP=41)
required int32 beatType = 2; // BeatType
optional int32 count = 3; // 返回數量 [1,300], 默認30
optional int32 term = 4; // BeatTerm, 默認 All
repeated Indicator filterList = 5; // 可選篩選條件(AND關係), 不傳則使用默認值(超預期>0, 時間=最近30天)
optional int32 sortField = 6; // SortField, 排序字段(固定降序), 默認按市值
}
// 盈利超預期排行數據項
message EarningsBeatItem {
required Qot_Common.Security security = 1; // 股票
optional string name = 2; // 名稱
optional string industry = 3; // 行業
// 行情
optional double curPrice = 10; // 最新價
optional double lastClosePrice = 11; // 昨收價
optional double changeRate = 12; // 今日漲跌幅 (%)
optional double marketCap = 13; // 市值
optional double peTTM = 14; // 市盈率TTM
optional double dividendsTTM = 15; // 股息率TTM (%)
// 盈利超預期
optional string releasedDate = 20; // 發佈日期 (如 "2024-01-15")
optional double beatRatio = 21; // 超預期比率 (%)
optional double actual = 22; // 實際值
optional double estimate = 23; // 預測值
optional double yoy = 24; // 去年同期
optional double yoyGrowth = 25; // 同比增長率 (%)
optional double earningDayChg = 26; // 財報後首日漲幅 (%)
optional string term = 27; // 財報週期 (如 "2024/Q1")
optional int32 detailPostPeriod = 28; // PostPeriodType, 發佈具體時段
}
message S2C {
repeated EarningsBeatItem dataList = 1; // 數據列表
optional int32 allCount = 2; // 數據總量
}
message Request {
required C2S c2s = 1;
}
message Response {
required int32 retType = 1 [default = -400]; // 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
- 接口調用結果,結構參見 RetType
協議 ID
3406
Example
import mmWebsocket from "moomoo-api";
import { Common, Qot_Common } from "moomoo-api/proto";
import beautify from "js-beautify";
function QotGetEarningsBeatRank(){
const { RetType } = Common
let [addr, port, enable_ssl, key] = ["127.0.0.1", 11111, false, "xxxxxx"];
let websocket = new mmWebsocket();
websocket.onlogin = (ret, msg)=>{
if (ret) {
const req = {
c2s: { market: 11, beatType: 1, count: 3 },
};
websocket.GetEarningsBeatRank(req)
.then((res)=>{
let { errCode, retMsg, retType, s2c } = res
console.log("GetEarningsBeatRank: 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("start error", msg);
}
};
websocket.start(addr, port, enable_ssl, key);
setTimeout(()=>{ websocket.stop(); process.exit(); }, 5000);
}
QotGetEarningsBeatRank()
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
- Output
GetEarningsBeatRank: errCode 0, retMsg , retType 0
{
"allCount": 1282,
"dataList": [
{ "security": { "market": 11, "code": "NVDA" }, "name": "英偉達", "beatRatio": 37.253, "earningDayChg": -1.772 },
{ "security": { "market": 11, "code": "GOOGL" }, "name": "谷歌-A", "beatRatio": 91.593, "earningDayChg": 9.961 },
{ "security": { "market": 11, "code": "GOOG" }, "name": "谷歌-C", "beatRatio": 91.593, "earningDayChg": 9.970 }
]
}
2
3
4
5
6
7
8
9
接口限制
- 30 秒內最多 60 次請求
- 分頁請求僅首頁計入限頻統計
← 獲取FedWatch點陣圖 獲取股息排行 →