# 獲取股息排行
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_dividend_rank(market, rank_type, count=None, filter_list=None, sort_field=None)
介紹
獲取股息排行,返回指定市場中高股息率或股息持續增長的股票排行列表,包含股息率、派息頻率、連續增長年數等維度數據。
參數
參數 類型 說明 market Market 市場類型(支持 HK/US/MY/SG/JP)(必填) rank_type DividendRankType 排行類型(必填) count int 返回數量 [1, 300],默認 10 filter_list list[ DividendRankFilter]篩選條件列表(多條件爲 AND 關係,支持範圍型和枚舉型) sort_field DividendRankSortField 排序字段(固定降序),默認由 rankType 決定 輸入限制
filter_list篩選條件(DividendRankFilter):通過
DividendRankFilter構造篩選條件,支持範圍型和枚舉型兩種篩選:構造參數 說明 indicator_type篩選因子類型( DividendRankIndicatorType,必填)value_list枚舉值列表(用於枚舉型篩選,如派息頻率) interval_min範圍最小值(閉區間,用於範圍型篩選) interval_max範圍最大值(閉區間,用於範圍型篩選) 注意:
value_list和interval_min/interval_max至少提供一種。
返回
參數 類型 說明 ret RET_CODE 接口調用結果 data pd.DataFrame 當 ret == RET_OK,返回數據 str 當 ret != RET_OK,返回錯誤描述 - 數據格式如下:
字段 類型 說明 security str 股票代碼(如 'HK.00005')name str 股票名稱 industry str 所屬行業 cur_price float 最新價 change_rate float 今日漲跌幅(%) change_amount float 今日漲跌額 market_cap float 市值 dividend_yield_ttm float 股息率 TTM(%) avg_dividend_yield_5y float 5年平均股息率(%) distribution_frequency str 派息頻率(ANNUAL/SEMI_ANNUAL/QUARTERLY/MONTHLY),不支持HK市場 dividend_grow_year int 股息連續增長年數 dividends_ttm float 股息 TTM(金額) payout_ratio_lfy float 股息支付率 LFY(%) next_payable_date str 下次派息日(如 '2025-09-15')
- 數據格式如下:
Example
from futu import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data = quote_ctx.get_dividend_rank(market=Market.HK, rank_type=DividendRankType.HIGH_YIELD, count=2)
if ret == RET_OK:
print(data)
else:
print('error:', data)
quote_ctx.close()
2
3
4
5
6
7
8
9
10
11
- Output
security name industry cur_price change_rate change_amount market_cap dividend_yield_ttm avg_dividend_yield_5y distribution_frequency dividend_grow_year dividends_ttm payout_ratio_lfy next_payable_date
0 HK.00288 萬洲國際 包裝食品 8.54 -0.582 -0.05 1.095701e+11 10.655 10.855 SEMI_ANNUAL 2 0.910 116.44 N/A
1 HK.01919 中遠海控 航運及港口 13.20 -1.123 -0.15 2.021314e+11 8.522 38.168 SEMI_ANNUAL 0 1.125 49.67 N/A
2
3
# Qot_GetDividendRank.proto
介紹
獲取股息排行,返回指定市場中高股息率或股息持續增長的股票排行列表,包含股息率、派息頻率、連續增長年數等維度數據。
參數
// 股息排行類型
enum DividendRankType {
DividendRankType_Unknown = 0;
DividendRankType_HighYield = 1; // 高股息率
DividendRankType_DividendGrowth = 2; // 股息保持增長
}
// 篩選條件類型
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_DividendYieldTTM = 1; //【範圍】股息率TTM (%)
IndicatorType_AvgDividendYield5Y = 2; //【範圍】5年平均股息率 (%)
IndicatorType_DistributionFrequency = 3; //【枚舉】派息頻率 (1:年派, 2:半年派, 3:季派, 4:月派)
IndicatorType_DividendGrowYear = 4; //【範圍】股息連續增長年數
IndicatorType_DividendsTTM = 5; //【範圍】股息TTM (金額)
IndicatorType_PayoutRatioLFY = 6; //【範圍】股息支付率LFY (%)
IndicatorType_NextPayableDate = 7; //【範圍】下次派息日 (相對天數)
IndicatorType_Price = 8; //【範圍】最新價
IndicatorType_MarketCap = 9; //【範圍】市值
}
// 排序字段 (固定降序)
enum SortField {
SortField_Unknown = 0; // 默認: HighYield→股息率TTM, DividendGrowth→連續增長年數
SortField_DividendYieldTTM = 1; // 股息率TTM
SortField_AvgDividendYield5Y = 2; // 5年平均股息率
SortField_DistributionFrequency = 3; // 派息頻率
SortField_DividendGrowYear = 4; // 股息連續增長年數
SortField_DividendsTTM = 5; // 股息TTM
SortField_PayoutRatioLFY = 6; // 股息支付率LFY
SortField_Price = 7; // 價格
SortField_MarketCap = 8; // 市值
SortField_ChangeRate = 9; // 今日漲跌幅
SortField_ChangeAmount = 10; // 今日漲跌額
}
// 篩選條件
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.IndicatorValue indicatorValue = 2; // 篩選值(枚舉型用valueList, 範圍型用valueInterval)
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket (僅支持 HK=1, US=11, MY=61, SG=31, JP=41)
required int32 rankType = 2; // DividendRankType
optional int32 count = 3; // 返回數量 [1,300], 默認10
repeated Indicator filterList = 4; // 可選篩選條件(AND關係)
optional int32 sortField = 5; // SortField, 排序字段(固定降序), 默認由rankType決定
}
// 股息排行數據項
message DividendRankItem {
required Qot_Common.Security security = 1; // 股票
optional string name = 2; // 名稱
optional string industry = 3; // 行業
// 行情
optional double curPrice = 10; // 最新價
optional double changeRate = 11; // 今日漲跌幅 (%)
optional double changeAmount = 12; // 今日漲跌額
optional double marketCap = 13; // 市值
// 股息
optional double dividendYieldTTM = 20; // 股息率TTM (%)
optional double avgDividendYield5Y = 21; // 5年平均股息率 (%)
optional int32 distributionFrequency = 22; // 派息頻率 (1:年派, 2:半年派, 3:季派, 4:月派),不支持HK市場
optional int32 dividendGrowYear = 23; // 股息連續增長年數
optional double dividendsTTM = 24; // 股息TTM (金額)
optional double payoutRatioLFY = 25; // 股息支付率LFY (%)
optional string nextPayableDate = 26; // 下次派息日 ("YYYY-MM-DD")
}
message S2C {
repeated DividendRankItem dataList = 1; // 數據列表
}
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
協議 ID
3407
uint GetDividendRank(Qot_GetDividendRank.Request req);
virtual void OnReply_GetDividendRank(FTAPI_Conn client, uint nSerialNo, Qot_GetDividendRank.Response rsp);
介紹
獲取股息排行,返回指定市場中高股息率或股息持續增長的股票排行列表,包含股息率、派息頻率、連續增長年數等維度數據。
參數
// 股息排行類型
enum DividendRankType {
DividendRankType_Unknown = 0;
DividendRankType_HighYield = 1; // 高股息率
DividendRankType_DividendGrowth = 2; // 股息保持增長
}
// 篩選條件類型
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_DividendYieldTTM = 1; //【範圍】股息率TTM (%)
IndicatorType_AvgDividendYield5Y = 2; //【範圍】5年平均股息率 (%)
IndicatorType_DistributionFrequency = 3; //【枚舉】派息頻率 (1:年派, 2:半年派, 3:季派, 4:月派)
IndicatorType_DividendGrowYear = 4; //【範圍】股息連續增長年數
IndicatorType_DividendsTTM = 5; //【範圍】股息TTM (金額)
IndicatorType_PayoutRatioLFY = 6; //【範圍】股息支付率LFY (%)
IndicatorType_NextPayableDate = 7; //【範圍】下次派息日 (相對天數)
IndicatorType_Price = 8; //【範圍】最新價
IndicatorType_MarketCap = 9; //【範圍】市值
}
// 排序字段 (固定降序)
enum SortField {
SortField_Unknown = 0; // 默認: HighYield→股息率TTM, DividendGrowth→連續增長年數
SortField_DividendYieldTTM = 1; // 股息率TTM
SortField_AvgDividendYield5Y = 2; // 5年平均股息率
SortField_DistributionFrequency = 3; // 派息頻率
SortField_DividendGrowYear = 4; // 股息連續增長年數
SortField_DividendsTTM = 5; // 股息TTM
SortField_PayoutRatioLFY = 6; // 股息支付率LFY
SortField_Price = 7; // 價格
SortField_MarketCap = 8; // 市值
SortField_ChangeRate = 9; // 今日漲跌幅
SortField_ChangeAmount = 10; // 今日漲跌額
}
// 篩選條件
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.IndicatorValue indicatorValue = 2; // 篩選值(枚舉型用valueList, 範圍型用valueInterval)
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket (僅支持 HK=1, US=11, MY=61, SG=31, JP=41)
required int32 rankType = 2; // DividendRankType
optional int32 count = 3; // 返回數量 [1,300], 默認10
repeated Indicator filterList = 4; // 可選篩選條件(AND關係)
optional int32 sortField = 5; // SortField, 排序字段(固定降序), 默認由rankType決定
}
// 股息排行數據項
message DividendRankItem {
required Qot_Common.Security security = 1; // 股票
optional string name = 2; // 名稱
optional string industry = 3; // 行業
// 行情
optional double curPrice = 10; // 最新價
optional double changeRate = 11; // 今日漲跌幅 (%)
optional double changeAmount = 12; // 今日漲跌額
optional double marketCap = 13; // 市值
// 股息
optional double dividendYieldTTM = 20; // 股息率TTM (%)
optional double avgDividendYield5Y = 21; // 5年平均股息率 (%)
optional int32 distributionFrequency = 22; // 派息頻率 (1:年派, 2:半年派, 3:季派, 4:月派),不支持HK市場
optional int32 dividendGrowYear = 23; // 股息連續增長年數
optional double dividendsTTM = 24; // 股息TTM (金額)
optional double payoutRatioLFY = 25; // 股息支付率LFY (%)
optional string nextPayableDate = 26; // 下次派息日 ("YYYY-MM-DD")
}
message S2C {
repeated DividendRankItem dataList = 1; // 數據列表
}
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
- 接口調用結果,結構參見 RetType
協議 ID
3407
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;
QotGetDividendRank.C2S c2s = QotGetDividendRank.C2S.CreateBuilder()
.SetMarket(1)
.SetRankType(1)
.SetCount(3)
.Build();
QotGetDividendRank.Request req = QotGetDividendRank.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetDividendRank(req);
Console.Write("Send QotGetDividendRank: {0}
", seqNo);
}
public void OnDisconnect(FTAPI_Conn client, long errCode) {
Console.Write("Qot onDisConnect: {0}
", errCode);
}
public void OnReply_GetDividendRank(FTAPI_Conn client, uint nSerialNo, QotGetDividendRank.Response rsp)
{
Console.Write("Reply: QotGetDividendRank: {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 QotGetDividendRank: 3
Reply: QotGetDividendRank: 3
GetDividendRank: errCode 0, retMsg , retType 0
{
"dataList": [
{ "security": { "market": 1, "code": "00288" }, "name": "萬洲國際", "dividendYieldTtm": 10.569, "dividendsTtm": 0.910 },
{ "security": { "market": 1, "code": "01919" }, "name": "中遠海控", "dividendYieldTtm": 8.302, "dividendsTtm": 1.125 },
{ "security": { "market": 1, "code": "01088" }, "name": "中國神華", "dividendYieldTtm": 7.578, "dividendsTtm": 3.227 }
]
}
2
3
4
5
6
7
8
9
10
int getDividendRank(Qot_GetDividendRank.Request req);
onReply_GetDividendRank(FTAPI_Conn client, int nSerialNo, Qot_GetDividendRank.Response rsp)
介紹
獲取股息排行,返回指定市場中高股息率或股息持續增長的股票排行列表,包含股息率、派息頻率、連續增長年數等維度數據。
參數
// 股息排行類型
enum DividendRankType {
DividendRankType_Unknown = 0;
DividendRankType_HighYield = 1; // 高股息率
DividendRankType_DividendGrowth = 2; // 股息保持增長
}
// 篩選條件類型
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_DividendYieldTTM = 1; //【範圍】股息率TTM (%)
IndicatorType_AvgDividendYield5Y = 2; //【範圍】5年平均股息率 (%)
IndicatorType_DistributionFrequency = 3; //【枚舉】派息頻率 (1:年派, 2:半年派, 3:季派, 4:月派)
IndicatorType_DividendGrowYear = 4; //【範圍】股息連續增長年數
IndicatorType_DividendsTTM = 5; //【範圍】股息TTM (金額)
IndicatorType_PayoutRatioLFY = 6; //【範圍】股息支付率LFY (%)
IndicatorType_NextPayableDate = 7; //【範圍】下次派息日 (相對天數)
IndicatorType_Price = 8; //【範圍】最新價
IndicatorType_MarketCap = 9; //【範圍】市值
}
// 排序字段 (固定降序)
enum SortField {
SortField_Unknown = 0; // 默認: HighYield→股息率TTM, DividendGrowth→連續增長年數
SortField_DividendYieldTTM = 1; // 股息率TTM
SortField_AvgDividendYield5Y = 2; // 5年平均股息率
SortField_DistributionFrequency = 3; // 派息頻率
SortField_DividendGrowYear = 4; // 股息連續增長年數
SortField_DividendsTTM = 5; // 股息TTM
SortField_PayoutRatioLFY = 6; // 股息支付率LFY
SortField_Price = 7; // 價格
SortField_MarketCap = 8; // 市值
SortField_ChangeRate = 9; // 今日漲跌幅
SortField_ChangeAmount = 10; // 今日漲跌額
}
// 篩選條件
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.IndicatorValue indicatorValue = 2; // 篩選值(枚舉型用valueList, 範圍型用valueInterval)
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket (僅支持 HK=1, US=11, MY=61, SG=31, JP=41)
required int32 rankType = 2; // DividendRankType
optional int32 count = 3; // 返回數量 [1,300], 默認10
repeated Indicator filterList = 4; // 可選篩選條件(AND關係)
optional int32 sortField = 5; // SortField, 排序字段(固定降序), 默認由rankType決定
}
// 股息排行數據項
message DividendRankItem {
required Qot_Common.Security security = 1; // 股票
optional string name = 2; // 名稱
optional string industry = 3; // 行業
// 行情
optional double curPrice = 10; // 最新價
optional double changeRate = 11; // 今日漲跌幅 (%)
optional double changeAmount = 12; // 今日漲跌額
optional double marketCap = 13; // 市值
// 股息
optional double dividendYieldTTM = 20; // 股息率TTM (%)
optional double avgDividendYield5Y = 21; // 5年平均股息率 (%)
optional int32 distributionFrequency = 22; // 派息頻率 (1:年派, 2:半年派, 3:季派, 4:月派),不支持HK市場
optional int32 dividendGrowYear = 23; // 股息連續增長年數
optional double dividendsTTM = 24; // 股息TTM (金額)
optional double payoutRatioLFY = 25; // 股息支付率LFY (%)
optional string nextPayableDate = 26; // 下次派息日 ("YYYY-MM-DD")
}
message S2C {
repeated DividendRankItem dataList = 1; // 數據列表
}
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
- 接口調用結果,結構參見 RetType
協議 ID
3407
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;
QotGetDividendRank.C2S c2s = QotGetDividendRank.C2S.newBuilder()
.setMarket(1)
.setRankType(1)
.setCount(3)
.build();
QotGetDividendRank.Request req = QotGetDividendRank.Request.newBuilder().setC2S(c2s).build();
int seqNo = qot.getDividendRank(req);
System.out.printf("Send QotGetDividendRank: %d
", seqNo);
}
@Override
public void onDisconnect(FTAPI_Conn client, long errCode) {
System.out.printf("Qot onDisConnect: %d
", errCode);
}
@Override
public void onReply_GetDividendRank(FTAPI_Conn client, int nSerialNo, QotGetDividendRank.Response rsp) {
if (rsp.getRetType() != 0) {
System.out.printf("QotGetDividendRank failed: %s
", rsp.getRetMsg());
} else {
try {
String json = JsonFormat.printer().print(rsp);
System.out.printf("Receive QotGetDividendRank: %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 QotGetDividendRank: 3
Receive QotGetDividendRank: {
"dataList": [
{ "security": { "market": 1, "code": "00288" }, "name": "萬洲國際", "dividendYieldTtm": 10.569, "dividendsTtm": 0.910 },
{ "security": { "market": 1, "code": "01919" }, "name": "中遠海控", "dividendYieldTtm": 8.302, "dividendsTtm": 1.125 },
{ "security": { "market": 1, "code": "01088" }, "name": "中國神華", "dividendYieldTtm": 7.578, "dividendsTtm": 3.227 }
]
}
2
3
4
5
6
7
8
Futu::u32_t GetDividendRank(const Qot_GetDividendRank::Request &stReq);
virtual void OnReply_GetDividendRank(Futu::u32_t nSerialNo, const Qot_GetDividendRank::Response &stRsp) = 0;
介紹
協議請求及回應定義
參數
// 股息排行類型
enum DividendRankType {
DividendRankType_Unknown = 0;
DividendRankType_HighYield = 1; // 高股息率
DividendRankType_DividendGrowth = 2; // 股息保持增長
}
// 篩選條件類型
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_DividendYieldTTM = 1; //【範圍】股息率TTM (%)
IndicatorType_AvgDividendYield5Y = 2; //【範圍】5年平均股息率 (%)
IndicatorType_DistributionFrequency = 3; //【枚舉】派息頻率 (1:年派, 2:半年派, 3:季派, 4:月派)
IndicatorType_DividendGrowYear = 4; //【範圍】股息連續增長年數
IndicatorType_DividendsTTM = 5; //【範圍】股息TTM (金額)
IndicatorType_PayoutRatioLFY = 6; //【範圍】股息支付率LFY (%)
IndicatorType_NextPayableDate = 7; //【範圍】下次派息日 (相對天數)
IndicatorType_Price = 8; //【範圍】最新價
IndicatorType_MarketCap = 9; //【範圍】市值
}
// 排序字段 (固定降序)
enum SortField {
SortField_Unknown = 0; // 默認: HighYield→股息率TTM, DividendGrowth→連續增長年數
SortField_DividendYieldTTM = 1; // 股息率TTM
SortField_AvgDividendYield5Y = 2; // 5年平均股息率
SortField_DistributionFrequency = 3; // 派息頻率
SortField_DividendGrowYear = 4; // 股息連續增長年數
SortField_DividendsTTM = 5; // 股息TTM
SortField_PayoutRatioLFY = 6; // 股息支付率LFY
SortField_Price = 7; // 價格
SortField_MarketCap = 8; // 市值
SortField_ChangeRate = 9; // 今日漲跌幅
SortField_ChangeAmount = 10; // 今日漲跌額
}
// 篩選條件
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.IndicatorValue indicatorValue = 2; // 篩選值(枚舉型用valueList, 範圍型用valueInterval)
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket (僅支持 HK=1, US=11, MY=61, SG=31, JP=41)
required int32 rankType = 2; // DividendRankType
optional int32 count = 3; // 返回數量 [1,300], 默認10
repeated Indicator filterList = 4; // 可選篩選條件(AND關係)
optional int32 sortField = 5; // SortField, 排序字段(固定降序), 默認由rankType決定
}
// 股息排行數據項
message DividendRankItem {
required Qot_Common.Security security = 1; // 股票
optional string name = 2; // 名稱
optional string industry = 3; // 行業
// 行情
optional double curPrice = 10; // 最新價
optional double changeRate = 11; // 今日漲跌幅 (%)
optional double changeAmount = 12; // 今日漲跌額
optional double marketCap = 13; // 市值
// 股息
optional double dividendYieldTTM = 20; // 股息率TTM (%)
optional double avgDividendYield5Y = 21; // 5年平均股息率 (%)
optional int32 distributionFrequency = 22; // 派息頻率 (1:年派, 2:半年派, 3:季派, 4:月派),不支持HK市場
optional int32 dividendGrowYear = 23; // 股息連續增長年數
optional double dividendsTTM = 24; // 股息TTM (金額)
optional double payoutRatioLFY = 25; // 股息支付率LFY (%)
optional string nextPayableDate = 26; // 下次派息日 ("YYYY-MM-DD")
}
message S2C {
repeated DividendRankItem dataList = 1; // 數據列表
}
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
- 介面呼叫結果,結構參見 RetType
協議 ID
3407
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_GetDividendRank::Request req;
Qot_GetDividendRank::C2S *c2s = req.mutable_c2s();
c2s->set_market(Qot_Common::QotMarket::QotMarket_US_Security);
c2s->set_ranktype(1); // DividendRankType_HighYield
c2s->set_count(10);
m_GetDividendRankSerialNo = m_pQotApi->GetDividendRank(req);
}
virtual void OnReply_GetDividendRank(Futu::u32_t nSerialNo, const Qot_GetDividendRank::Response &stRsp) {
if (nSerialNo != m_GetDividendRankSerialNo) return;
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
FTAPI_Qot *m_pQotApi;
Futu::u32_t m_GetDividendRankSerialNo = 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": "T"
},
"name": "AT&T",
"industry": "Communication",
"curPrice": 18.5,
"changeRate": 0.54,
"marketCap": 132500000000.0,
"dividendYieldTTM": 6.8
}
]
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
getDividendRank(qotGetDividendRank)
介紹
獲取股息排行,返回指定市場中高股息率或股息持續增長的股票排行列表,包含股息率、派息頻率、連續增長年數等維度數據。
參數
// 股息排行類型
enum DividendRankType {
DividendRankType_Unknown = 0;
DividendRankType_HighYield = 1; // 高股息率
DividendRankType_DividendGrowth = 2; // 股息保持增長
}
// 篩選條件類型
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_DividendYieldTTM = 1; //【範圍】股息率TTM (%)
IndicatorType_AvgDividendYield5Y = 2; //【範圍】5年平均股息率 (%)
IndicatorType_DistributionFrequency = 3; //【枚舉】派息頻率 (1:年派, 2:半年派, 3:季派, 4:月派)
IndicatorType_DividendGrowYear = 4; //【範圍】股息連續增長年數
IndicatorType_DividendsTTM = 5; //【範圍】股息TTM (金額)
IndicatorType_PayoutRatioLFY = 6; //【範圍】股息支付率LFY (%)
IndicatorType_NextPayableDate = 7; //【範圍】下次派息日 (相對天數)
IndicatorType_Price = 8; //【範圍】最新價
IndicatorType_MarketCap = 9; //【範圍】市值
}
// 排序字段 (固定降序)
enum SortField {
SortField_Unknown = 0; // 默認: HighYield→股息率TTM, DividendGrowth→連續增長年數
SortField_DividendYieldTTM = 1; // 股息率TTM
SortField_AvgDividendYield5Y = 2; // 5年平均股息率
SortField_DistributionFrequency = 3; // 派息頻率
SortField_DividendGrowYear = 4; // 股息連續增長年數
SortField_DividendsTTM = 5; // 股息TTM
SortField_PayoutRatioLFY = 6; // 股息支付率LFY
SortField_Price = 7; // 價格
SortField_MarketCap = 8; // 市值
SortField_ChangeRate = 9; // 今日漲跌幅
SortField_ChangeAmount = 10; // 今日漲跌額
}
// 篩選條件
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.IndicatorValue indicatorValue = 2; // 篩選值(枚舉型用valueList, 範圍型用valueInterval)
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket (僅支持 HK=1, US=11, MY=61, SG=31, JP=41)
required int32 rankType = 2; // DividendRankType
optional int32 count = 3; // 返回數量 [1,300], 默認10
repeated Indicator filterList = 4; // 可選篩選條件(AND關係)
optional int32 sortField = 5; // SortField, 排序字段(固定降序), 默認由rankType決定
}
// 股息排行數據項
message DividendRankItem {
required Qot_Common.Security security = 1; // 股票
optional string name = 2; // 名稱
optional string industry = 3; // 行業
// 行情
optional double curPrice = 10; // 最新價
optional double changeRate = 11; // 今日漲跌幅 (%)
optional double changeAmount = 12; // 今日漲跌額
optional double marketCap = 13; // 市值
// 股息
optional double dividendYieldTTM = 20; // 股息率TTM (%)
optional double avgDividendYield5Y = 21; // 5年平均股息率 (%)
optional int32 distributionFrequency = 22; // 派息頻率 (1:年派, 2:半年派, 3:季派, 4:月派),不支持HK市場
optional int32 dividendGrowYear = 23; // 股息連續增長年數
optional double dividendsTTM = 24; // 股息TTM (金額)
optional double payoutRatioLFY = 25; // 股息支付率LFY (%)
optional string nextPayableDate = 26; // 下次派息日 ("YYYY-MM-DD")
}
message S2C {
repeated DividendRankItem dataList = 1; // 數據列表
}
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
- 接口調用結果,結構參見 RetType
協議 ID
3407
Example
import ftWebsocket from "futu-api";
import { Common, Qot_Common } from "futu-api/proto";
import beautify from "js-beautify";
function QotGetDividendRank(){
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: 1, rankType: 1, count: 3 },
};
websocket.GetDividendRank(req)
.then((res)=>{
let { errCode, retMsg, retType, s2c } = res
console.log("GetDividendRank: 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);
}
QotGetDividendRank()
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
GetDividendRank: errCode 0, retMsg , retType 0
{
"dataList": [
{ "security": { "market": 1, "code": "00288" }, "name": "萬洲國際", "dividendYieldTtm": 10.569, "dividendsTtm": 0.910 },
{ "security": { "market": 1, "code": "01919" }, "name": "中遠海控", "dividendYieldTtm": 8.302, "dividendsTtm": 1.125 },
{ "security": { "market": 1, "code": "01088" }, "name": "中國神華", "dividendYieldTtm": 7.578, "dividendsTtm": 3.227 }
]
}
2
3
4
5
6
7
8
接口限制
- 30 秒內最多 60 次請求
- 分頁請求僅首頁計入限頻統計
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_dividend_rank(market, rank_type, count=None, filter_list=None, sort_field=None)
介紹
獲取股息排行,返回指定市場中高股息率或股息持續增長的股票排行列表,包含股息率、派息頻率、連續增長年數等維度數據。
參數
參數 類型 說明 market Market 市場類型(支持 HK/US/MY/SG/JP)(必填) rank_type DividendRankType 排行類型(必填) count int 返回數量 [1, 300],默認 10 filter_list list[ DividendRankFilter]篩選條件列表(多條件爲 AND 關係,支持範圍型和枚舉型) sort_field DividendRankSortField 排序字段(固定降序),默認由 rankType 決定 輸入限制
filter_list篩選條件(DividendRankFilter):通過
DividendRankFilter構造篩選條件,支持範圍型和枚舉型兩種篩選:構造參數 說明 indicator_type篩選因子類型( DividendRankIndicatorType,必填)value_list枚舉值列表(用於枚舉型篩選,如派息頻率) interval_min範圍最小值(閉區間,用於範圍型篩選) interval_max範圍最大值(閉區間,用於範圍型篩選) 注意:
value_list和interval_min/interval_max至少提供一種。
返回
參數 類型 說明 ret RET_CODE 接口調用結果 data pd.DataFrame 當 ret == RET_OK,返回數據 str 當 ret != RET_OK,返回錯誤描述 - 數據格式如下:
字段 類型 說明 security str 股票代碼(如 'HK.00005')name str 股票名稱 industry str 所屬行業 cur_price float 最新價 change_rate float 今日漲跌幅(%) change_amount float 今日漲跌額 market_cap float 市值 dividend_yield_ttm float 股息率 TTM(%) avg_dividend_yield_5y float 5年平均股息率(%) distribution_frequency str 派息頻率(ANNUAL/SEMI_ANNUAL/QUARTERLY/MONTHLY),不支持HK市場 dividend_grow_year int 股息連續增長年數 dividends_ttm float 股息 TTM(金額) payout_ratio_lfy float 股息支付率 LFY(%) next_payable_date str 下次派息日(如 '2025-09-15')
- 數據格式如下:
Example
from futu import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data = quote_ctx.get_dividend_rank(market=Market.HK, rank_type=DividendRankType.HIGH_YIELD, count=2)
if ret == RET_OK:
print(data)
else:
print('error:', data)
quote_ctx.close()
2
3
4
5
6
7
8
9
10
11
- Output
security name industry cur_price change_rate change_amount market_cap dividend_yield_ttm avg_dividend_yield_5y distribution_frequency dividend_grow_year dividends_ttm payout_ratio_lfy next_payable_date
0 HK.00288 萬洲國際 包裝食品 8.54 -0.582 -0.05 1.095701e+11 10.655 10.855 SEMI_ANNUAL 2 0.910 116.44 N/A
1 HK.01919 中遠海控 航運及港口 13.20 -1.123 -0.15 2.021314e+11 8.522 38.168 SEMI_ANNUAL 0 1.125 49.67 N/A
2
3
# Qot_GetDividendRank.proto
介紹
獲取股息排行,返回指定市場中高股息率或股息持續增長的股票排行列表,包含股息率、派息頻率、連續增長年數等維度數據。
參數
// 股息排行類型
enum DividendRankType {
DividendRankType_Unknown = 0;
DividendRankType_HighYield = 1; // 高股息率
DividendRankType_DividendGrowth = 2; // 股息保持增長
}
// 篩選條件類型
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_DividendYieldTTM = 1; //【範圍】股息率TTM (%)
IndicatorType_AvgDividendYield5Y = 2; //【範圍】5年平均股息率 (%)
IndicatorType_DistributionFrequency = 3; //【枚舉】派息頻率 (1:年派, 2:半年派, 3:季派, 4:月派)
IndicatorType_DividendGrowYear = 4; //【範圍】股息連續增長年數
IndicatorType_DividendsTTM = 5; //【範圍】股息TTM (金額)
IndicatorType_PayoutRatioLFY = 6; //【範圍】股息支付率LFY (%)
IndicatorType_NextPayableDate = 7; //【範圍】下次派息日 (相對天數)
IndicatorType_Price = 8; //【範圍】最新價
IndicatorType_MarketCap = 9; //【範圍】市值
}
// 排序字段 (固定降序)
enum SortField {
SortField_Unknown = 0; // 默認: HighYield→股息率TTM, DividendGrowth→連續增長年數
SortField_DividendYieldTTM = 1; // 股息率TTM
SortField_AvgDividendYield5Y = 2; // 5年平均股息率
SortField_DistributionFrequency = 3; // 派息頻率
SortField_DividendGrowYear = 4; // 股息連續增長年數
SortField_DividendsTTM = 5; // 股息TTM
SortField_PayoutRatioLFY = 6; // 股息支付率LFY
SortField_Price = 7; // 價格
SortField_MarketCap = 8; // 市值
SortField_ChangeRate = 9; // 今日漲跌幅
SortField_ChangeAmount = 10; // 今日漲跌額
}
// 篩選條件
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.IndicatorValue indicatorValue = 2; // 篩選值(枚舉型用valueList, 範圍型用valueInterval)
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket (僅支持 HK=1, US=11, MY=61, SG=31, JP=41)
required int32 rankType = 2; // DividendRankType
optional int32 count = 3; // 返回數量 [1,300], 默認10
repeated Indicator filterList = 4; // 可選篩選條件(AND關係)
optional int32 sortField = 5; // SortField, 排序字段(固定降序), 默認由rankType決定
}
// 股息排行數據項
message DividendRankItem {
required Qot_Common.Security security = 1; // 股票
optional string name = 2; // 名稱
optional string industry = 3; // 行業
// 行情
optional double curPrice = 10; // 最新價
optional double changeRate = 11; // 今日漲跌幅 (%)
optional double changeAmount = 12; // 今日漲跌額
optional double marketCap = 13; // 市值
// 股息
optional double dividendYieldTTM = 20; // 股息率TTM (%)
optional double avgDividendYield5Y = 21; // 5年平均股息率 (%)
optional int32 distributionFrequency = 22; // 派息頻率 (1:年派, 2:半年派, 3:季派, 4:月派),不支持HK市場
optional int32 dividendGrowYear = 23; // 股息連續增長年數
optional double dividendsTTM = 24; // 股息TTM (金額)
optional double payoutRatioLFY = 25; // 股息支付率LFY (%)
optional string nextPayableDate = 26; // 下次派息日 ("YYYY-MM-DD")
}
message S2C {
repeated DividendRankItem dataList = 1; // 數據列表
}
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
協議 ID
3407
uint GetDividendRank(Qot_GetDividendRank.Request req);
virtual void OnReply_GetDividendRank(FTAPI_Conn client, uint nSerialNo, Qot_GetDividendRank.Response rsp);
介紹
獲取股息排行,返回指定市場中高股息率或股息持續增長的股票排行列表,包含股息率、派息頻率、連續增長年數等維度數據。
參數
// 股息排行類型
enum DividendRankType {
DividendRankType_Unknown = 0;
DividendRankType_HighYield = 1; // 高股息率
DividendRankType_DividendGrowth = 2; // 股息保持增長
}
// 篩選條件類型
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_DividendYieldTTM = 1; //【範圍】股息率TTM (%)
IndicatorType_AvgDividendYield5Y = 2; //【範圍】5年平均股息率 (%)
IndicatorType_DistributionFrequency = 3; //【枚舉】派息頻率 (1:年派, 2:半年派, 3:季派, 4:月派)
IndicatorType_DividendGrowYear = 4; //【範圍】股息連續增長年數
IndicatorType_DividendsTTM = 5; //【範圍】股息TTM (金額)
IndicatorType_PayoutRatioLFY = 6; //【範圍】股息支付率LFY (%)
IndicatorType_NextPayableDate = 7; //【範圍】下次派息日 (相對天數)
IndicatorType_Price = 8; //【範圍】最新價
IndicatorType_MarketCap = 9; //【範圍】市值
}
// 排序字段 (固定降序)
enum SortField {
SortField_Unknown = 0; // 默認: HighYield→股息率TTM, DividendGrowth→連續增長年數
SortField_DividendYieldTTM = 1; // 股息率TTM
SortField_AvgDividendYield5Y = 2; // 5年平均股息率
SortField_DistributionFrequency = 3; // 派息頻率
SortField_DividendGrowYear = 4; // 股息連續增長年數
SortField_DividendsTTM = 5; // 股息TTM
SortField_PayoutRatioLFY = 6; // 股息支付率LFY
SortField_Price = 7; // 價格
SortField_MarketCap = 8; // 市值
SortField_ChangeRate = 9; // 今日漲跌幅
SortField_ChangeAmount = 10; // 今日漲跌額
}
// 篩選條件
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.IndicatorValue indicatorValue = 2; // 篩選值(枚舉型用valueList, 範圍型用valueInterval)
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket (僅支持 HK=1, US=11, MY=61, SG=31, JP=41)
required int32 rankType = 2; // DividendRankType
optional int32 count = 3; // 返回數量 [1,300], 默認10
repeated Indicator filterList = 4; // 可選篩選條件(AND關係)
optional int32 sortField = 5; // SortField, 排序字段(固定降序), 默認由rankType決定
}
// 股息排行數據項
message DividendRankItem {
required Qot_Common.Security security = 1; // 股票
optional string name = 2; // 名稱
optional string industry = 3; // 行業
// 行情
optional double curPrice = 10; // 最新價
optional double changeRate = 11; // 今日漲跌幅 (%)
optional double changeAmount = 12; // 今日漲跌額
optional double marketCap = 13; // 市值
// 股息
optional double dividendYieldTTM = 20; // 股息率TTM (%)
optional double avgDividendYield5Y = 21; // 5年平均股息率 (%)
optional int32 distributionFrequency = 22; // 派息頻率 (1:年派, 2:半年派, 3:季派, 4:月派),不支持HK市場
optional int32 dividendGrowYear = 23; // 股息連續增長年數
optional double dividendsTTM = 24; // 股息TTM (金額)
optional double payoutRatioLFY = 25; // 股息支付率LFY (%)
optional string nextPayableDate = 26; // 下次派息日 ("YYYY-MM-DD")
}
message S2C {
repeated DividendRankItem dataList = 1; // 數據列表
}
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
- 接口調用結果,結構參見 RetType
協議 ID
3407
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;
QotGetDividendRank.C2S c2s = QotGetDividendRank.C2S.CreateBuilder()
.SetMarket(1)
.SetRankType(1)
.SetCount(3)
.Build();
QotGetDividendRank.Request req = QotGetDividendRank.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetDividendRank(req);
Console.Write("Send QotGetDividendRank: {0}
", seqNo);
}
public void OnDisconnect(MMAPI_Conn client, long errCode) {
Console.Write("Qot onDisConnect: {0}
", errCode);
}
public void OnReply_GetDividendRank(MMAPI_Conn client, uint nSerialNo, QotGetDividendRank.Response rsp)
{
Console.Write("Reply: QotGetDividendRank: {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 QotGetDividendRank: 3
Reply: QotGetDividendRank: 3
GetDividendRank: errCode 0, retMsg , retType 0
{
"dataList": [
{ "security": { "market": 1, "code": "00288" }, "name": "萬洲國際", "dividendYieldTtm": 10.569, "dividendsTtm": 0.910 },
{ "security": { "market": 1, "code": "01919" }, "name": "中遠海控", "dividendYieldTtm": 8.302, "dividendsTtm": 1.125 },
{ "security": { "market": 1, "code": "01088" }, "name": "中國神華", "dividendYieldTtm": 7.578, "dividendsTtm": 3.227 }
]
}
2
3
4
5
6
7
8
9
10
int getDividendRank(Qot_GetDividendRank.Request req);
onReply_GetDividendRank(FTAPI_Conn client, int nSerialNo, Qot_GetDividendRank.Response rsp)
介紹
獲取股息排行,返回指定市場中高股息率或股息持續增長的股票排行列表,包含股息率、派息頻率、連續增長年數等維度數據。
參數
// 股息排行類型
enum DividendRankType {
DividendRankType_Unknown = 0;
DividendRankType_HighYield = 1; // 高股息率
DividendRankType_DividendGrowth = 2; // 股息保持增長
}
// 篩選條件類型
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_DividendYieldTTM = 1; //【範圍】股息率TTM (%)
IndicatorType_AvgDividendYield5Y = 2; //【範圍】5年平均股息率 (%)
IndicatorType_DistributionFrequency = 3; //【枚舉】派息頻率 (1:年派, 2:半年派, 3:季派, 4:月派)
IndicatorType_DividendGrowYear = 4; //【範圍】股息連續增長年數
IndicatorType_DividendsTTM = 5; //【範圍】股息TTM (金額)
IndicatorType_PayoutRatioLFY = 6; //【範圍】股息支付率LFY (%)
IndicatorType_NextPayableDate = 7; //【範圍】下次派息日 (相對天數)
IndicatorType_Price = 8; //【範圍】最新價
IndicatorType_MarketCap = 9; //【範圍】市值
}
// 排序字段 (固定降序)
enum SortField {
SortField_Unknown = 0; // 默認: HighYield→股息率TTM, DividendGrowth→連續增長年數
SortField_DividendYieldTTM = 1; // 股息率TTM
SortField_AvgDividendYield5Y = 2; // 5年平均股息率
SortField_DistributionFrequency = 3; // 派息頻率
SortField_DividendGrowYear = 4; // 股息連續增長年數
SortField_DividendsTTM = 5; // 股息TTM
SortField_PayoutRatioLFY = 6; // 股息支付率LFY
SortField_Price = 7; // 價格
SortField_MarketCap = 8; // 市值
SortField_ChangeRate = 9; // 今日漲跌幅
SortField_ChangeAmount = 10; // 今日漲跌額
}
// 篩選條件
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.IndicatorValue indicatorValue = 2; // 篩選值(枚舉型用valueList, 範圍型用valueInterval)
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket (僅支持 HK=1, US=11, MY=61, SG=31, JP=41)
required int32 rankType = 2; // DividendRankType
optional int32 count = 3; // 返回數量 [1,300], 默認10
repeated Indicator filterList = 4; // 可選篩選條件(AND關係)
optional int32 sortField = 5; // SortField, 排序字段(固定降序), 默認由rankType決定
}
// 股息排行數據項
message DividendRankItem {
required Qot_Common.Security security = 1; // 股票
optional string name = 2; // 名稱
optional string industry = 3; // 行業
// 行情
optional double curPrice = 10; // 最新價
optional double changeRate = 11; // 今日漲跌幅 (%)
optional double changeAmount = 12; // 今日漲跌額
optional double marketCap = 13; // 市值
// 股息
optional double dividendYieldTTM = 20; // 股息率TTM (%)
optional double avgDividendYield5Y = 21; // 5年平均股息率 (%)
optional int32 distributionFrequency = 22; // 派息頻率 (1:年派, 2:半年派, 3:季派, 4:月派),不支持HK市場
optional int32 dividendGrowYear = 23; // 股息連續增長年數
optional double dividendsTTM = 24; // 股息TTM (金額)
optional double payoutRatioLFY = 25; // 股息支付率LFY (%)
optional string nextPayableDate = 26; // 下次派息日 ("YYYY-MM-DD")
}
message S2C {
repeated DividendRankItem dataList = 1; // 數據列表
}
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
- 接口調用結果,結構參見 RetType
協議 ID
3407
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;
QotGetDividendRank.C2S c2s = QotGetDividendRank.C2S.newBuilder()
.setMarket(1)
.setRankType(1)
.setCount(3)
.build();
QotGetDividendRank.Request req = QotGetDividendRank.Request.newBuilder().setC2S(c2s).build();
int seqNo = qot.getDividendRank(req);
System.out.printf("Send QotGetDividendRank: %d
", seqNo);
}
@Override
public void onDisconnect(MMAPI_Conn client, long errCode) {
System.out.printf("Qot onDisConnect: %d
", errCode);
}
@Override
public void onReply_GetDividendRank(MMAPI_Conn client, int nSerialNo, QotGetDividendRank.Response rsp) {
if (rsp.getRetType() != 0) {
System.out.printf("QotGetDividendRank failed: %s
", rsp.getRetMsg());
} else {
try {
String json = JsonFormat.printer().print(rsp);
System.out.printf("Receive QotGetDividendRank: %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 QotGetDividendRank: 3
Receive QotGetDividendRank: {
"dataList": [
{ "security": { "market": 1, "code": "00288" }, "name": "萬洲國際", "dividendYieldTtm": 10.569, "dividendsTtm": 0.910 },
{ "security": { "market": 1, "code": "01919" }, "name": "中遠海控", "dividendYieldTtm": 8.302, "dividendsTtm": 1.125 },
{ "security": { "market": 1, "code": "01088" }, "name": "中國神華", "dividendYieldTtm": 7.578, "dividendsTtm": 3.227 }
]
}
2
3
4
5
6
7
8
moomoo::u32_t GetDividendRank(const Qot_GetDividendRank::Request &stReq);
virtual void OnReply_GetDividendRank(moomoo::u32_t nSerialNo, const Qot_GetDividendRank::Response &stRsp) = 0;
介紹
協議請求及回應定義
參數
// 股息排行類型
enum DividendRankType {
DividendRankType_Unknown = 0;
DividendRankType_HighYield = 1; // 高股息率
DividendRankType_DividendGrowth = 2; // 股息保持增長
}
// 篩選條件類型
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_DividendYieldTTM = 1; //【範圍】股息率TTM (%)
IndicatorType_AvgDividendYield5Y = 2; //【範圍】5年平均股息率 (%)
IndicatorType_DistributionFrequency = 3; //【枚舉】派息頻率 (1:年派, 2:半年派, 3:季派, 4:月派)
IndicatorType_DividendGrowYear = 4; //【範圍】股息連續增長年數
IndicatorType_DividendsTTM = 5; //【範圍】股息TTM (金額)
IndicatorType_PayoutRatioLFY = 6; //【範圍】股息支付率LFY (%)
IndicatorType_NextPayableDate = 7; //【範圍】下次派息日 (相對天數)
IndicatorType_Price = 8; //【範圍】最新價
IndicatorType_MarketCap = 9; //【範圍】市值
}
// 排序字段 (固定降序)
enum SortField {
SortField_Unknown = 0; // 默認: HighYield→股息率TTM, DividendGrowth→連續增長年數
SortField_DividendYieldTTM = 1; // 股息率TTM
SortField_AvgDividendYield5Y = 2; // 5年平均股息率
SortField_DistributionFrequency = 3; // 派息頻率
SortField_DividendGrowYear = 4; // 股息連續增長年數
SortField_DividendsTTM = 5; // 股息TTM
SortField_PayoutRatioLFY = 6; // 股息支付率LFY
SortField_Price = 7; // 價格
SortField_MarketCap = 8; // 市值
SortField_ChangeRate = 9; // 今日漲跌幅
SortField_ChangeAmount = 10; // 今日漲跌額
}
// 篩選條件
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.IndicatorValue indicatorValue = 2; // 篩選值(枚舉型用valueList, 範圍型用valueInterval)
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket (僅支持 HK=1, US=11, MY=61, SG=31, JP=41)
required int32 rankType = 2; // DividendRankType
optional int32 count = 3; // 返回數量 [1,300], 默認10
repeated Indicator filterList = 4; // 可選篩選條件(AND關係)
optional int32 sortField = 5; // SortField, 排序字段(固定降序), 默認由rankType決定
}
// 股息排行數據項
message DividendRankItem {
required Qot_Common.Security security = 1; // 股票
optional string name = 2; // 名稱
optional string industry = 3; // 行業
// 行情
optional double curPrice = 10; // 最新價
optional double changeRate = 11; // 今日漲跌幅 (%)
optional double changeAmount = 12; // 今日漲跌額
optional double marketCap = 13; // 市值
// 股息
optional double dividendYieldTTM = 20; // 股息率TTM (%)
optional double avgDividendYield5Y = 21; // 5年平均股息率 (%)
optional int32 distributionFrequency = 22; // 派息頻率 (1:年派, 2:半年派, 3:季派, 4:月派),不支持HK市場
optional int32 dividendGrowYear = 23; // 股息連續增長年數
optional double dividendsTTM = 24; // 股息TTM (金額)
optional double payoutRatioLFY = 25; // 股息支付率LFY (%)
optional string nextPayableDate = 26; // 下次派息日 ("YYYY-MM-DD")
}
message S2C {
repeated DividendRankItem dataList = 1; // 數據列表
}
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
- 介面呼叫結果,結構參見 RetType
協議 ID
3407
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_GetDividendRank::Request req;
Qot_GetDividendRank::C2S *c2s = req.mutable_c2s();
c2s->set_market(Qot_Common::QotMarket::QotMarket_US_Security);
c2s->set_ranktype(1); // DividendRankType_HighYield
c2s->set_count(10);
m_GetDividendRankSerialNo = m_pQotApi->GetDividendRank(req);
}
virtual void OnReply_GetDividendRank(moomoo::u32_t nSerialNo, const Qot_GetDividendRank::Response &stRsp) {
if (nSerialNo != m_GetDividendRankSerialNo) return;
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
MMAPI_Qot *m_pQotApi;
moomoo::u32_t m_GetDividendRankSerialNo = 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": "T"
},
"name": "AT&T",
"industry": "Communication",
"curPrice": 18.5,
"changeRate": 0.54,
"marketCap": 132500000000.0,
"dividendYieldTTM": 6.8
}
]
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
getDividendRank(qotGetDividendRank)
介紹
獲取股息排行,返回指定市場中高股息率或股息持續增長的股票排行列表,包含股息率、派息頻率、連續增長年數等維度數據。
參數
// 股息排行類型
enum DividendRankType {
DividendRankType_Unknown = 0;
DividendRankType_HighYield = 1; // 高股息率
DividendRankType_DividendGrowth = 2; // 股息保持增長
}
// 篩選條件類型
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_DividendYieldTTM = 1; //【範圍】股息率TTM (%)
IndicatorType_AvgDividendYield5Y = 2; //【範圍】5年平均股息率 (%)
IndicatorType_DistributionFrequency = 3; //【枚舉】派息頻率 (1:年派, 2:半年派, 3:季派, 4:月派)
IndicatorType_DividendGrowYear = 4; //【範圍】股息連續增長年數
IndicatorType_DividendsTTM = 5; //【範圍】股息TTM (金額)
IndicatorType_PayoutRatioLFY = 6; //【範圍】股息支付率LFY (%)
IndicatorType_NextPayableDate = 7; //【範圍】下次派息日 (相對天數)
IndicatorType_Price = 8; //【範圍】最新價
IndicatorType_MarketCap = 9; //【範圍】市值
}
// 排序字段 (固定降序)
enum SortField {
SortField_Unknown = 0; // 默認: HighYield→股息率TTM, DividendGrowth→連續增長年數
SortField_DividendYieldTTM = 1; // 股息率TTM
SortField_AvgDividendYield5Y = 2; // 5年平均股息率
SortField_DistributionFrequency = 3; // 派息頻率
SortField_DividendGrowYear = 4; // 股息連續增長年數
SortField_DividendsTTM = 5; // 股息TTM
SortField_PayoutRatioLFY = 6; // 股息支付率LFY
SortField_Price = 7; // 價格
SortField_MarketCap = 8; // 市值
SortField_ChangeRate = 9; // 今日漲跌幅
SortField_ChangeAmount = 10; // 今日漲跌額
}
// 篩選條件
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.IndicatorValue indicatorValue = 2; // 篩選值(枚舉型用valueList, 範圍型用valueInterval)
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket (僅支持 HK=1, US=11, MY=61, SG=31, JP=41)
required int32 rankType = 2; // DividendRankType
optional int32 count = 3; // 返回數量 [1,300], 默認10
repeated Indicator filterList = 4; // 可選篩選條件(AND關係)
optional int32 sortField = 5; // SortField, 排序字段(固定降序), 默認由rankType決定
}
// 股息排行數據項
message DividendRankItem {
required Qot_Common.Security security = 1; // 股票
optional string name = 2; // 名稱
optional string industry = 3; // 行業
// 行情
optional double curPrice = 10; // 最新價
optional double changeRate = 11; // 今日漲跌幅 (%)
optional double changeAmount = 12; // 今日漲跌額
optional double marketCap = 13; // 市值
// 股息
optional double dividendYieldTTM = 20; // 股息率TTM (%)
optional double avgDividendYield5Y = 21; // 5年平均股息率 (%)
optional int32 distributionFrequency = 22; // 派息頻率 (1:年派, 2:半年派, 3:季派, 4:月派),不支持HK市場
optional int32 dividendGrowYear = 23; // 股息連續增長年數
optional double dividendsTTM = 24; // 股息TTM (金額)
optional double payoutRatioLFY = 25; // 股息支付率LFY (%)
optional string nextPayableDate = 26; // 下次派息日 ("YYYY-MM-DD")
}
message S2C {
repeated DividendRankItem dataList = 1; // 數據列表
}
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
- 接口調用結果,結構參見 RetType
協議 ID
3407
Example
import mmWebsocket from "moomoo-api";
import { Common, Qot_Common } from "moomoo-api/proto";
import beautify from "js-beautify";
function QotGetDividendRank(){
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: 1, rankType: 1, count: 3 },
};
websocket.GetDividendRank(req)
.then((res)=>{
let { errCode, retMsg, retType, s2c } = res
console.log("GetDividendRank: 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);
}
QotGetDividendRank()
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
GetDividendRank: errCode 0, retMsg , retType 0
{
"dataList": [
{ "security": { "market": 1, "code": "00288" }, "name": "萬洲國際", "dividendYieldTtm": 10.569, "dividendsTtm": 0.910 },
{ "security": { "market": 1, "code": "01919" }, "name": "中遠海控", "dividendYieldTtm": 8.302, "dividendsTtm": 1.125 },
{ "security": { "market": 1, "code": "01088" }, "name": "中國神華", "dividendYieldTtm": 7.578, "dividendsTtm": 3.227 }
]
}
2
3
4
5
6
7
8
接口限制
- 30 秒內最多 60 次請求
- 分頁請求僅首頁計入限頻統計