# 獲取破淨高股息國央企
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_high_dividend_soe_rank(sort_field=None, sort_dir=None, count=10, offset=None, filter_list=None)
介紹
獲取破淨高股息國央企排行(港股),返回滿足特估國企概念板塊、PB<=1、股息率TTM>=5%、PE>=0 默認條件的港股排行數據。用戶可通過篩選條件覆蓋默認閾值。
參數
參數 類型 說明 sort_field HighDividendSOESortField 排序字段,默認市值 sort_dir RankSortDir 排序方向,默認降序 count int 返回數量 [1, 200],默認 10 offset int 起始位置,默認 0 filter_list list[ HighDividendSOERankFilter]篩選條件列表(可覆蓋默認條件) 輸入限制
filter_list篩選條件(HighDividendSOERankFilter):構造參數 說明 indicator_type篩選因子類型( HighDividendSOEIndicatorType,必填)interval_min範圍最小值(閉區間) interval_max範圍最大值(閉區間) 服務端默認固定條件:
- 概念板塊 = 特估國企
- 市淨率 PB <= 1
- 股息率 TTM >= 5%
- 市盈率 PE >= 0
返回
參數 類型 說明 ret RET_CODE 接口調用結果 data pd.DataFrame 當 ret == RET_OK,返回 (all_count, DataFrame) 元組 str 當 ret != RET_OK,返回錯誤描述 - 數據格式如下:
字段 類型 說明 security str 股票代碼(如 'HK.00857')name str 股票名稱 industry str 所屬行業 cur_price float 最新價 change_ratio float 漲跌幅(%) turnover float 成交額 volume int 成交量 market_cap float 市值 pe_ttm float 市盈率 TTM pb float 市淨率 dividend_yield_ttm float 股息率 TTM(%) turnover_ratio float 換手率(%) change_rate_5d float 5日漲幅(%) change_rate_10d float 10日漲幅(%) change_rate_20d float 20日漲幅(%) change_rate_60d float 60日漲幅(%) change_rate_120d float 120日漲幅(%) change_rate_250d float 250日漲幅(%)
- 數據格式如下:
Example
from futu import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data = quote_ctx.get_high_dividend_soe_rank(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
總數據量: 98
security name industry cur_price change_ratio turnover volume market_cap pe_ttm pb dividend_yield_ttm turnover_ratio change_rate_5d change_rate_10d change_rate_20d change_rate_60d change_rate_120d change_rate_250d
0 HK.01398 工商銀行 銀行 6.9 -0.862 325569646.0 46871758 2.459203e+12 5.84745 0.55072 5.072 0.054 -3.894 -0.288 1.917 9.411 16.416 24.292
1 HK.00857 中國石油股份 油氣生產商 8.9 -0.447 154397506.0 17228406 1.628887e+12 9.09090 0.88539 5.932 0.081 -6.342 -10.216 -16.217 -14.691 14.209 36.468
2
3
4
# Qot_GetHighDividendSOERank.proto
介紹
獲取破淨高股息國央企排行(港股),返回滿足特估國企概念板塊、PB<=1、股息率TTM>=5%、PE>=0 默認條件的港股排行數據。用戶可通過篩選條件覆蓋默認閾值。
參數
// 排序方向
enum SortDir {
SortDir_Descending = 0; // 降序(默認)
SortDir_Ascending = 1; // 升序
}
// 排序字段
enum SortField {
SortField_Unknown = 0; // 默認(市值降序)
SortField_DividendYieldTTM = 1; // 股息率TTM
SortField_PB = 2; // 市淨率
SortField_PeTTM = 3; // 市盈率TTM
SortField_Price = 4; // 最新價
SortField_ChangeRatio = 5; // 今日漲跌幅
SortField_MarketCap = 6; // 市值
}
// 篩選條件類型
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_Price = 1; // 價格區間
IndicatorType_MarketCap = 2; // 市值區間
IndicatorType_PE = 3; // 市盈率TTM區間
IndicatorType_DividendYieldTTM = 4; // 股息率TTM區間
IndicatorType_ChangeRatio = 5; // 漲跌幅區間
}
// 篩選條件
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.Interval indicatorValue = 2; // 篩選區間
}
message C2S {
optional int32 sortField = 1; // SortField, 排序字段, 默認市值
optional int32 sortDir = 2; // SortDir, 排序方向, 默認降序
optional int32 offset = 3; // 起始位置, 默認0
optional int32 count = 4; // 返回數量 [1,200], 默認50
repeated Indicator filterList = 5; // 篩選條件(可覆蓋默認PB/股息率條件)
}
// 破淨高股息國央企數據項
// 默認固定條件(服務端硬編碼): 概念板塊=特估國企 + PB<=1 + 股息率TTM>=5% + PE>=0
message HighDividendSOERankItem {
required Qot_Common.Security security = 1; // 股票
optional string name = 2; // 名稱
optional string industry = 3; // 所屬行業
optional double curPrice = 10; // 最新價
optional double changeRatio = 11; // 漲跌幅(%)
optional double turnover = 12; // 成交額
optional int64 volume = 13; // 成交量
optional double marketCap = 14; // 市值
optional double peTTM = 20; // 市盈率TTM
optional double pb = 21; // 市淨率
optional double dividendYieldTTM = 22; // 股息率TTM(%)
optional double turnoverRatio = 23; // 換手率(%)
optional double changeRate5D = 30; // 5日漲幅(%)
optional double changeRate10D = 31; // 10日漲幅(%)
optional double changeRate20D = 32; // 20日漲幅(%)
optional double changeRate60D = 33; // 60日漲幅(%)
optional double changeRate120D = 34; // 120日漲幅(%)
optional double changeRate250D = 35; // 250日漲幅(%)
}
message S2C {
repeated HighDividendSOERankItem 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
協議 ID
3417
uint GetHighDividendSOERank(Qot_GetHighDividendSOERank.Request req);
virtual void OnReply_GetHighDividendSOERank(FTAPI_Conn client, uint nSerialNo, Qot_GetHighDividendSOERank.Response rsp);
介紹
獲取破淨高股息國央企排行(港股),返回滿足特估國企概念板塊、PB<=1、股息率TTM>=5%、PE>=0 默認條件的港股排行數據。用戶可通過篩選條件覆蓋默認閾值。
參數
// 排序方向
enum SortDir {
SortDir_Descending = 0; // 降序(默認)
SortDir_Ascending = 1; // 升序
}
// 排序字段
enum SortField {
SortField_Unknown = 0; // 默認(市值降序)
SortField_DividendYieldTTM = 1; // 股息率TTM
SortField_PB = 2; // 市淨率
SortField_PeTTM = 3; // 市盈率TTM
SortField_Price = 4; // 最新價
SortField_ChangeRatio = 5; // 今日漲跌幅
SortField_MarketCap = 6; // 市值
}
// 篩選條件類型
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_Price = 1; // 價格區間
IndicatorType_MarketCap = 2; // 市值區間
IndicatorType_PE = 3; // 市盈率TTM區間
IndicatorType_DividendYieldTTM = 4; // 股息率TTM區間
IndicatorType_ChangeRatio = 5; // 漲跌幅區間
}
// 篩選條件
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.Interval indicatorValue = 2; // 篩選區間
}
message C2S {
optional int32 sortField = 1; // SortField, 排序字段, 默認市值
optional int32 sortDir = 2; // SortDir, 排序方向, 默認降序
optional int32 offset = 3; // 起始位置, 默認0
optional int32 count = 4; // 返回數量 [1,200], 默認50
repeated Indicator filterList = 5; // 篩選條件(可覆蓋默認PB/股息率條件)
}
// 破淨高股息國央企數據項
// 默認固定條件(服務端硬編碼): 概念板塊=特估國企 + PB<=1 + 股息率TTM>=5% + PE>=0
message HighDividendSOERankItem {
required Qot_Common.Security security = 1; // 股票
optional string name = 2; // 名稱
optional string industry = 3; // 所屬行業
optional double curPrice = 10; // 最新價
optional double changeRatio = 11; // 漲跌幅(%)
optional double turnover = 12; // 成交額
optional int64 volume = 13; // 成交量
optional double marketCap = 14; // 市值
optional double peTTM = 20; // 市盈率TTM
optional double pb = 21; // 市淨率
optional double dividendYieldTTM = 22; // 股息率TTM(%)
optional double turnoverRatio = 23; // 換手率(%)
optional double changeRate5D = 30; // 5日漲幅(%)
optional double changeRate10D = 31; // 10日漲幅(%)
optional double changeRate20D = 32; // 20日漲幅(%)
optional double changeRate60D = 33; // 60日漲幅(%)
optional double changeRate120D = 34; // 120日漲幅(%)
optional double changeRate250D = 35; // 250日漲幅(%)
}
message S2C {
repeated HighDividendSOERankItem 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
- 接口調用結果,結構參見 RetType
協議 ID
3417
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;
QotGetHighDividendSOERank.C2S c2s = QotGetHighDividendSOERank.C2S.CreateBuilder()
.SetCount(3)
.Build();
QotGetHighDividendSOERank.Request req = QotGetHighDividendSOERank.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetHighDividendSOERank(req);
Console.Write("Send QotGetHighDividendSOERank: {0}
", seqNo);
}
public void OnDisconnect(FTAPI_Conn client, long errCode) {
Console.Write("Qot onDisConnect: {0}
", errCode);
}
public void OnReply_GetHighDividendSOERank(FTAPI_Conn client, uint nSerialNo, QotGetHighDividendSOERank.Response rsp)
{
Console.Write("Reply: QotGetHighDividendSOERank: {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
- Output
Send QotGetHighDividendSOERank: 3
Reply: QotGetHighDividendSOERank: 3
GetHighDividendSOERank: errCode 0, retMsg , retType 0
{
"allCount": 91,
"dataList": [
{ "security": { "market": 1, "code": "01398" }, "name": "工商銀行", "dividendYieldTtm": 5.087, "peTtm": 5.83050 },
{ "security": { "market": 1, "code": "00857" }, "name": "中國石油股份", "dividendYieldTtm": 5.764, "peTtm": 9.35648 },
{ "security": { "market": 1, "code": "00386" }, "name": "中國石油化工股份", "dividendYieldTtm": 5.432, "peTtm": 12.27138 }
]
}
2
3
4
5
6
7
8
9
10
11
int getHighDividendSOERank(Qot_GetHighDividendSOERank.Request req);
onReply_GetHighDividendSOERank(FTAPI_Conn client, int nSerialNo, Qot_GetHighDividendSOERank.Response rsp)
介紹
獲取破淨高股息國央企排行(港股),返回滿足特估國企概念板塊、PB<=1、股息率TTM>=5%、PE>=0 默認條件的港股排行數據。用戶可通過篩選條件覆蓋默認閾值。
參數
// 排序方向
enum SortDir {
SortDir_Descending = 0; // 降序(默認)
SortDir_Ascending = 1; // 升序
}
// 排序字段
enum SortField {
SortField_Unknown = 0; // 默認(市值降序)
SortField_DividendYieldTTM = 1; // 股息率TTM
SortField_PB = 2; // 市淨率
SortField_PeTTM = 3; // 市盈率TTM
SortField_Price = 4; // 最新價
SortField_ChangeRatio = 5; // 今日漲跌幅
SortField_MarketCap = 6; // 市值
}
// 篩選條件類型
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_Price = 1; // 價格區間
IndicatorType_MarketCap = 2; // 市值區間
IndicatorType_PE = 3; // 市盈率TTM區間
IndicatorType_DividendYieldTTM = 4; // 股息率TTM區間
IndicatorType_ChangeRatio = 5; // 漲跌幅區間
}
// 篩選條件
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.Interval indicatorValue = 2; // 篩選區間
}
message C2S {
optional int32 sortField = 1; // SortField, 排序字段, 默認市值
optional int32 sortDir = 2; // SortDir, 排序方向, 默認降序
optional int32 offset = 3; // 起始位置, 默認0
optional int32 count = 4; // 返回數量 [1,200], 默認50
repeated Indicator filterList = 5; // 篩選條件(可覆蓋默認PB/股息率條件)
}
// 破淨高股息國央企數據項
// 默認固定條件(服務端硬編碼): 概念板塊=特估國企 + PB<=1 + 股息率TTM>=5% + PE>=0
message HighDividendSOERankItem {
required Qot_Common.Security security = 1; // 股票
optional string name = 2; // 名稱
optional string industry = 3; // 所屬行業
optional double curPrice = 10; // 最新價
optional double changeRatio = 11; // 漲跌幅(%)
optional double turnover = 12; // 成交額
optional int64 volume = 13; // 成交量
optional double marketCap = 14; // 市值
optional double peTTM = 20; // 市盈率TTM
optional double pb = 21; // 市淨率
optional double dividendYieldTTM = 22; // 股息率TTM(%)
optional double turnoverRatio = 23; // 換手率(%)
optional double changeRate5D = 30; // 5日漲幅(%)
optional double changeRate10D = 31; // 10日漲幅(%)
optional double changeRate20D = 32; // 20日漲幅(%)
optional double changeRate60D = 33; // 60日漲幅(%)
optional double changeRate120D = 34; // 120日漲幅(%)
optional double changeRate250D = 35; // 250日漲幅(%)
}
message S2C {
repeated HighDividendSOERankItem 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
- 接口調用結果,結構參見 RetType
協議 ID
3417
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;
QotGetHighDividendSOERank.C2S c2s = QotGetHighDividendSOERank.C2S.newBuilder()
.setCount(3)
.build();
QotGetHighDividendSOERank.Request req = QotGetHighDividendSOERank.Request.newBuilder().setC2S(c2s).build();
int seqNo = qot.getHighDividendSOERank(req);
System.out.printf("Send QotGetHighDividendSOERank: %d
", seqNo);
}
@Override
public void onDisconnect(FTAPI_Conn client, long errCode) {
System.out.printf("Qot onDisConnect: %d
", errCode);
}
@Override
public void onReply_GetHighDividendSOERank(FTAPI_Conn client, int nSerialNo, QotGetHighDividendSOERank.Response rsp) {
if (rsp.getRetType() != 0) {
System.out.printf("QotGetHighDividendSOERank failed: %s
", rsp.getRetMsg());
} else {
try {
String json = JsonFormat.printer().print(rsp);
System.out.printf("Receive QotGetHighDividendSOERank: %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
- Output
Send QotGetHighDividendSOERank: 3
Receive QotGetHighDividendSOERank: {
"allCount": 91,
"dataList": [
{ "security": { "market": 1, "code": "01398" }, "name": "工商銀行", "dividendYieldTtm": 5.087, "peTtm": 5.83050 },
{ "security": { "market": 1, "code": "00857" }, "name": "中國石油股份", "dividendYieldTtm": 5.764, "peTtm": 9.35648 },
{ "security": { "market": 1, "code": "00386" }, "name": "中國石油化工股份", "dividendYieldTtm": 5.432, "peTtm": 12.27138 }
]
}
2
3
4
5
6
7
8
9
Futu::u32_t GetHighDividendSOERank(const Qot_GetHighDividendSOERank::Request &stReq);
virtual void OnReply_GetHighDividendSOERank(Futu::u32_t nSerialNo, const Qot_GetHighDividendSOERank::Response &stRsp) = 0;
介紹
協議請求及回應定義
參數
// 排序方向
enum SortDir {
SortDir_Descending = 0; // 降序(默認)
SortDir_Ascending = 1; // 升序
}
// 排序字段
enum SortField {
SortField_Unknown = 0; // 默認(市值降序)
SortField_DividendYieldTTM = 1; // 股息率TTM
SortField_PB = 2; // 市淨率
SortField_PeTTM = 3; // 市盈率TTM
SortField_Price = 4; // 最新價
SortField_ChangeRatio = 5; // 今日漲跌幅
SortField_MarketCap = 6; // 市值
}
// 篩選條件類型
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_Price = 1; // 價格區間
IndicatorType_MarketCap = 2; // 市值區間
IndicatorType_PE = 3; // 市盈率TTM區間
IndicatorType_DividendYieldTTM = 4; // 股息率TTM區間
IndicatorType_ChangeRatio = 5; // 漲跌幅區間
}
// 篩選條件
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.Interval indicatorValue = 2; // 篩選區間
}
message C2S {
optional int32 sortField = 1; // SortField, 排序字段, 默認市值
optional int32 sortDir = 2; // SortDir, 排序方向, 默認降序
optional int32 offset = 3; // 起始位置, 默認0
optional int32 count = 4; // 返回數量 [1,200], 默認50
repeated Indicator filterList = 5; // 篩選條件(可覆蓋默認PB/股息率條件)
}
// 破淨高股息國央企數據項
// 默認固定條件(服務端硬編碼): 概念板塊=特估國企 + PB<=1 + 股息率TTM>=5% + PE>=0
message HighDividendSOERankItem {
required Qot_Common.Security security = 1; // 股票
optional string name = 2; // 名稱
optional string industry = 3; // 所屬行業
optional double curPrice = 10; // 最新價
optional double changeRatio = 11; // 漲跌幅(%)
optional double turnover = 12; // 成交額
optional int64 volume = 13; // 成交量
optional double marketCap = 14; // 市值
optional double peTTM = 20; // 市盈率TTM
optional double pb = 21; // 市淨率
optional double dividendYieldTTM = 22; // 股息率TTM(%)
optional double turnoverRatio = 23; // 換手率(%)
optional double changeRate5D = 30; // 5日漲幅(%)
optional double changeRate10D = 31; // 10日漲幅(%)
optional double changeRate20D = 32; // 20日漲幅(%)
optional double changeRate60D = 33; // 60日漲幅(%)
optional double changeRate120D = 34; // 120日漲幅(%)
optional double changeRate250D = 35; // 250日漲幅(%)
}
message S2C {
repeated HighDividendSOERankItem 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
- 介面呼叫結果,結構參見 RetType
協議 ID
3417
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_GetHighDividendSOERank::Request req;
Qot_GetHighDividendSOERank::C2S *c2s = req.mutable_c2s();
c2s->set_count(50);
m_GetHighDividendSOERankSerialNo = m_pQotApi->GetHighDividendSOERank(req);
}
virtual void OnReply_GetHighDividendSOERank(Futu::u32_t nSerialNo, const Qot_GetHighDividendSOERank::Response &stRsp) {
if (nSerialNo != m_GetHighDividendSOERankSerialNo) return;
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
FTAPI_Qot *m_pQotApi;
Futu::u32_t m_GetHighDividendSOERankSerialNo = 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
- Output
{
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"dataList": [
{
"security": {
"market": 1,
"code": "00939"
},
"name": "CCB",
"industry": "Bank",
"curPrice": 6.58,
"changeRatio": 0.46,
"marketCap": 1643000000000.0
}
],
"allCount": 50
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
getHighDividendSOERank(qotGetHighDividendSOERank)
介紹
獲取破淨高股息國央企排行(港股),返回滿足特估國企概念板塊、PB<=1、股息率TTM>=5%、PE>=0 默認條件的港股排行數據。用戶可通過篩選條件覆蓋默認閾值。
參數
// 排序方向
enum SortDir {
SortDir_Descending = 0; // 降序(默認)
SortDir_Ascending = 1; // 升序
}
// 排序字段
enum SortField {
SortField_Unknown = 0; // 默認(市值降序)
SortField_DividendYieldTTM = 1; // 股息率TTM
SortField_PB = 2; // 市淨率
SortField_PeTTM = 3; // 市盈率TTM
SortField_Price = 4; // 最新價
SortField_ChangeRatio = 5; // 今日漲跌幅
SortField_MarketCap = 6; // 市值
}
// 篩選條件類型
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_Price = 1; // 價格區間
IndicatorType_MarketCap = 2; // 市值區間
IndicatorType_PE = 3; // 市盈率TTM區間
IndicatorType_DividendYieldTTM = 4; // 股息率TTM區間
IndicatorType_ChangeRatio = 5; // 漲跌幅區間
}
// 篩選條件
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.Interval indicatorValue = 2; // 篩選區間
}
message C2S {
optional int32 sortField = 1; // SortField, 排序字段, 默認市值
optional int32 sortDir = 2; // SortDir, 排序方向, 默認降序
optional int32 offset = 3; // 起始位置, 默認0
optional int32 count = 4; // 返回數量 [1,200], 默認50
repeated Indicator filterList = 5; // 篩選條件(可覆蓋默認PB/股息率條件)
}
// 破淨高股息國央企數據項
// 默認固定條件(服務端硬編碼): 概念板塊=特估國企 + PB<=1 + 股息率TTM>=5% + PE>=0
message HighDividendSOERankItem {
required Qot_Common.Security security = 1; // 股票
optional string name = 2; // 名稱
optional string industry = 3; // 所屬行業
optional double curPrice = 10; // 最新價
optional double changeRatio = 11; // 漲跌幅(%)
optional double turnover = 12; // 成交額
optional int64 volume = 13; // 成交量
optional double marketCap = 14; // 市值
optional double peTTM = 20; // 市盈率TTM
optional double pb = 21; // 市淨率
optional double dividendYieldTTM = 22; // 股息率TTM(%)
optional double turnoverRatio = 23; // 換手率(%)
optional double changeRate5D = 30; // 5日漲幅(%)
optional double changeRate10D = 31; // 10日漲幅(%)
optional double changeRate20D = 32; // 20日漲幅(%)
optional double changeRate60D = 33; // 60日漲幅(%)
optional double changeRate120D = 34; // 120日漲幅(%)
optional double changeRate250D = 35; // 250日漲幅(%)
}
message S2C {
repeated HighDividendSOERankItem 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
- 接口調用結果,結構參見 RetType
協議 ID
3417
Example
import ftWebsocket from "futu-api";
import { Common, Qot_Common } from "futu-api/proto";
import beautify from "js-beautify";
function QotGetHighDividendSOERank(){
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: { count: 3 },
};
websocket.GetHighDividendSOERank(req)
.then((res)=>{
let { errCode, retMsg, retType, s2c } = res
console.log("GetHighDividendSOERank: 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);
}
QotGetHighDividendSOERank()
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
GetHighDividendSOERank: errCode 0, retMsg , retType 0
{
"allCount": 91,
"dataList": [
{ "security": { "market": 1, "code": "01398" }, "name": "工商銀行", "dividendYieldTtm": 5.087, "peTtm": 5.83050 },
{ "security": { "market": 1, "code": "00857" }, "name": "中國石油股份", "dividendYieldTtm": 5.764, "peTtm": 9.35648 },
{ "security": { "market": 1, "code": "00386" }, "name": "中國石油化工股份", "dividendYieldTtm": 5.432, "peTtm": 12.27138 }
]
}
2
3
4
5
6
7
8
9
接口限制
- 30 秒內最多 60 次請求
- 分頁請求僅首頁計入限頻統計
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_high_dividend_soe_rank(sort_field=None, sort_dir=None, count=10, offset=None, filter_list=None)
介紹
獲取破淨高股息國央企排行(港股),返回滿足特估國企概念板塊、PB<=1、股息率TTM>=5%、PE>=0 默認條件的港股排行數據。用戶可通過篩選條件覆蓋默認閾值。
參數
參數 類型 說明 sort_field HighDividendSOESortField 排序字段,默認市值 sort_dir RankSortDir 排序方向,默認降序 count int 返回數量 [1, 200],默認 10 offset int 起始位置,默認 0 filter_list list[ HighDividendSOERankFilter]篩選條件列表(可覆蓋默認條件) 輸入限制
filter_list篩選條件(HighDividendSOERankFilter):構造參數 說明 indicator_type篩選因子類型( HighDividendSOEIndicatorType,必填)interval_min範圍最小值(閉區間) interval_max範圍最大值(閉區間) 服務端默認固定條件:
- 概念板塊 = 特估國企
- 市淨率 PB <= 1
- 股息率 TTM >= 5%
- 市盈率 PE >= 0
返回
參數 類型 說明 ret RET_CODE 接口調用結果 data pd.DataFrame 當 ret == RET_OK,返回 (all_count, DataFrame) 元組 str 當 ret != RET_OK,返回錯誤描述 - 數據格式如下:
字段 類型 說明 security str 股票代碼(如 'HK.00857')name str 股票名稱 industry str 所屬行業 cur_price float 最新價 change_ratio float 漲跌幅(%) turnover float 成交額 volume int 成交量 market_cap float 市值 pe_ttm float 市盈率 TTM pb float 市淨率 dividend_yield_ttm float 股息率 TTM(%) turnover_ratio float 換手率(%) change_rate_5d float 5日漲幅(%) change_rate_10d float 10日漲幅(%) change_rate_20d float 20日漲幅(%) change_rate_60d float 60日漲幅(%) change_rate_120d float 120日漲幅(%) change_rate_250d float 250日漲幅(%)
- 數據格式如下:
Example
from futu import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data = quote_ctx.get_high_dividend_soe_rank(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
總數據量: 98
security name industry cur_price change_ratio turnover volume market_cap pe_ttm pb dividend_yield_ttm turnover_ratio change_rate_5d change_rate_10d change_rate_20d change_rate_60d change_rate_120d change_rate_250d
0 HK.01398 工商銀行 銀行 6.9 -0.862 325569646.0 46871758 2.459203e+12 5.84745 0.55072 5.072 0.054 -3.894 -0.288 1.917 9.411 16.416 24.292
1 HK.00857 中國石油股份 油氣生產商 8.9 -0.447 154397506.0 17228406 1.628887e+12 9.09090 0.88539 5.932 0.081 -6.342 -10.216 -16.217 -14.691 14.209 36.468
2
3
4
# Qot_GetHighDividendSOERank.proto
介紹
獲取破淨高股息國央企排行(港股),返回滿足特估國企概念板塊、PB<=1、股息率TTM>=5%、PE>=0 默認條件的港股排行數據。用戶可通過篩選條件覆蓋默認閾值。
參數
// 排序方向
enum SortDir {
SortDir_Descending = 0; // 降序(默認)
SortDir_Ascending = 1; // 升序
}
// 排序字段
enum SortField {
SortField_Unknown = 0; // 默認(市值降序)
SortField_DividendYieldTTM = 1; // 股息率TTM
SortField_PB = 2; // 市淨率
SortField_PeTTM = 3; // 市盈率TTM
SortField_Price = 4; // 最新價
SortField_ChangeRatio = 5; // 今日漲跌幅
SortField_MarketCap = 6; // 市值
}
// 篩選條件類型
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_Price = 1; // 價格區間
IndicatorType_MarketCap = 2; // 市值區間
IndicatorType_PE = 3; // 市盈率TTM區間
IndicatorType_DividendYieldTTM = 4; // 股息率TTM區間
IndicatorType_ChangeRatio = 5; // 漲跌幅區間
}
// 篩選條件
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.Interval indicatorValue = 2; // 篩選區間
}
message C2S {
optional int32 sortField = 1; // SortField, 排序字段, 默認市值
optional int32 sortDir = 2; // SortDir, 排序方向, 默認降序
optional int32 offset = 3; // 起始位置, 默認0
optional int32 count = 4; // 返回數量 [1,200], 默認50
repeated Indicator filterList = 5; // 篩選條件(可覆蓋默認PB/股息率條件)
}
// 破淨高股息國央企數據項
// 默認固定條件(服務端硬編碼): 概念板塊=特估國企 + PB<=1 + 股息率TTM>=5% + PE>=0
message HighDividendSOERankItem {
required Qot_Common.Security security = 1; // 股票
optional string name = 2; // 名稱
optional string industry = 3; // 所屬行業
optional double curPrice = 10; // 最新價
optional double changeRatio = 11; // 漲跌幅(%)
optional double turnover = 12; // 成交額
optional int64 volume = 13; // 成交量
optional double marketCap = 14; // 市值
optional double peTTM = 20; // 市盈率TTM
optional double pb = 21; // 市淨率
optional double dividendYieldTTM = 22; // 股息率TTM(%)
optional double turnoverRatio = 23; // 換手率(%)
optional double changeRate5D = 30; // 5日漲幅(%)
optional double changeRate10D = 31; // 10日漲幅(%)
optional double changeRate20D = 32; // 20日漲幅(%)
optional double changeRate60D = 33; // 60日漲幅(%)
optional double changeRate120D = 34; // 120日漲幅(%)
optional double changeRate250D = 35; // 250日漲幅(%)
}
message S2C {
repeated HighDividendSOERankItem 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
協議 ID
3417
uint GetHighDividendSOERank(Qot_GetHighDividendSOERank.Request req);
virtual void OnReply_GetHighDividendSOERank(FTAPI_Conn client, uint nSerialNo, Qot_GetHighDividendSOERank.Response rsp);
介紹
獲取破淨高股息國央企排行(港股),返回滿足特估國企概念板塊、PB<=1、股息率TTM>=5%、PE>=0 默認條件的港股排行數據。用戶可通過篩選條件覆蓋默認閾值。
參數
// 排序方向
enum SortDir {
SortDir_Descending = 0; // 降序(默認)
SortDir_Ascending = 1; // 升序
}
// 排序字段
enum SortField {
SortField_Unknown = 0; // 默認(市值降序)
SortField_DividendYieldTTM = 1; // 股息率TTM
SortField_PB = 2; // 市淨率
SortField_PeTTM = 3; // 市盈率TTM
SortField_Price = 4; // 最新價
SortField_ChangeRatio = 5; // 今日漲跌幅
SortField_MarketCap = 6; // 市值
}
// 篩選條件類型
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_Price = 1; // 價格區間
IndicatorType_MarketCap = 2; // 市值區間
IndicatorType_PE = 3; // 市盈率TTM區間
IndicatorType_DividendYieldTTM = 4; // 股息率TTM區間
IndicatorType_ChangeRatio = 5; // 漲跌幅區間
}
// 篩選條件
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.Interval indicatorValue = 2; // 篩選區間
}
message C2S {
optional int32 sortField = 1; // SortField, 排序字段, 默認市值
optional int32 sortDir = 2; // SortDir, 排序方向, 默認降序
optional int32 offset = 3; // 起始位置, 默認0
optional int32 count = 4; // 返回數量 [1,200], 默認50
repeated Indicator filterList = 5; // 篩選條件(可覆蓋默認PB/股息率條件)
}
// 破淨高股息國央企數據項
// 默認固定條件(服務端硬編碼): 概念板塊=特估國企 + PB<=1 + 股息率TTM>=5% + PE>=0
message HighDividendSOERankItem {
required Qot_Common.Security security = 1; // 股票
optional string name = 2; // 名稱
optional string industry = 3; // 所屬行業
optional double curPrice = 10; // 最新價
optional double changeRatio = 11; // 漲跌幅(%)
optional double turnover = 12; // 成交額
optional int64 volume = 13; // 成交量
optional double marketCap = 14; // 市值
optional double peTTM = 20; // 市盈率TTM
optional double pb = 21; // 市淨率
optional double dividendYieldTTM = 22; // 股息率TTM(%)
optional double turnoverRatio = 23; // 換手率(%)
optional double changeRate5D = 30; // 5日漲幅(%)
optional double changeRate10D = 31; // 10日漲幅(%)
optional double changeRate20D = 32; // 20日漲幅(%)
optional double changeRate60D = 33; // 60日漲幅(%)
optional double changeRate120D = 34; // 120日漲幅(%)
optional double changeRate250D = 35; // 250日漲幅(%)
}
message S2C {
repeated HighDividendSOERankItem 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
- 接口調用結果,結構參見 RetType
協議 ID
3417
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;
QotGetHighDividendSOERank.C2S c2s = QotGetHighDividendSOERank.C2S.CreateBuilder()
.SetCount(3)
.Build();
QotGetHighDividendSOERank.Request req = QotGetHighDividendSOERank.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetHighDividendSOERank(req);
Console.Write("Send QotGetHighDividendSOERank: {0}
", seqNo);
}
public void OnDisconnect(MMAPI_Conn client, long errCode) {
Console.Write("Qot onDisConnect: {0}
", errCode);
}
public void OnReply_GetHighDividendSOERank(MMAPI_Conn client, uint nSerialNo, QotGetHighDividendSOERank.Response rsp)
{
Console.Write("Reply: QotGetHighDividendSOERank: {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
- Output
Send QotGetHighDividendSOERank: 3
Reply: QotGetHighDividendSOERank: 3
GetHighDividendSOERank: errCode 0, retMsg , retType 0
{
"allCount": 91,
"dataList": [
{ "security": { "market": 1, "code": "01398" }, "name": "工商銀行", "dividendYieldTtm": 5.087, "peTtm": 5.83050 },
{ "security": { "market": 1, "code": "00857" }, "name": "中國石油股份", "dividendYieldTtm": 5.764, "peTtm": 9.35648 },
{ "security": { "market": 1, "code": "00386" }, "name": "中國石油化工股份", "dividendYieldTtm": 5.432, "peTtm": 12.27138 }
]
}
2
3
4
5
6
7
8
9
10
11
int getHighDividendSOERank(Qot_GetHighDividendSOERank.Request req);
onReply_GetHighDividendSOERank(FTAPI_Conn client, int nSerialNo, Qot_GetHighDividendSOERank.Response rsp)
介紹
獲取破淨高股息國央企排行(港股),返回滿足特估國企概念板塊、PB<=1、股息率TTM>=5%、PE>=0 默認條件的港股排行數據。用戶可通過篩選條件覆蓋默認閾值。
參數
// 排序方向
enum SortDir {
SortDir_Descending = 0; // 降序(默認)
SortDir_Ascending = 1; // 升序
}
// 排序字段
enum SortField {
SortField_Unknown = 0; // 默認(市值降序)
SortField_DividendYieldTTM = 1; // 股息率TTM
SortField_PB = 2; // 市淨率
SortField_PeTTM = 3; // 市盈率TTM
SortField_Price = 4; // 最新價
SortField_ChangeRatio = 5; // 今日漲跌幅
SortField_MarketCap = 6; // 市值
}
// 篩選條件類型
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_Price = 1; // 價格區間
IndicatorType_MarketCap = 2; // 市值區間
IndicatorType_PE = 3; // 市盈率TTM區間
IndicatorType_DividendYieldTTM = 4; // 股息率TTM區間
IndicatorType_ChangeRatio = 5; // 漲跌幅區間
}
// 篩選條件
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.Interval indicatorValue = 2; // 篩選區間
}
message C2S {
optional int32 sortField = 1; // SortField, 排序字段, 默認市值
optional int32 sortDir = 2; // SortDir, 排序方向, 默認降序
optional int32 offset = 3; // 起始位置, 默認0
optional int32 count = 4; // 返回數量 [1,200], 默認50
repeated Indicator filterList = 5; // 篩選條件(可覆蓋默認PB/股息率條件)
}
// 破淨高股息國央企數據項
// 默認固定條件(服務端硬編碼): 概念板塊=特估國企 + PB<=1 + 股息率TTM>=5% + PE>=0
message HighDividendSOERankItem {
required Qot_Common.Security security = 1; // 股票
optional string name = 2; // 名稱
optional string industry = 3; // 所屬行業
optional double curPrice = 10; // 最新價
optional double changeRatio = 11; // 漲跌幅(%)
optional double turnover = 12; // 成交額
optional int64 volume = 13; // 成交量
optional double marketCap = 14; // 市值
optional double peTTM = 20; // 市盈率TTM
optional double pb = 21; // 市淨率
optional double dividendYieldTTM = 22; // 股息率TTM(%)
optional double turnoverRatio = 23; // 換手率(%)
optional double changeRate5D = 30; // 5日漲幅(%)
optional double changeRate10D = 31; // 10日漲幅(%)
optional double changeRate20D = 32; // 20日漲幅(%)
optional double changeRate60D = 33; // 60日漲幅(%)
optional double changeRate120D = 34; // 120日漲幅(%)
optional double changeRate250D = 35; // 250日漲幅(%)
}
message S2C {
repeated HighDividendSOERankItem 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
- 接口調用結果,結構參見 RetType
協議 ID
3417
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;
QotGetHighDividendSOERank.C2S c2s = QotGetHighDividendSOERank.C2S.newBuilder()
.setCount(3)
.build();
QotGetHighDividendSOERank.Request req = QotGetHighDividendSOERank.Request.newBuilder().setC2S(c2s).build();
int seqNo = qot.getHighDividendSOERank(req);
System.out.printf("Send QotGetHighDividendSOERank: %d
", seqNo);
}
@Override
public void onDisconnect(MMAPI_Conn client, long errCode) {
System.out.printf("Qot onDisConnect: %d
", errCode);
}
@Override
public void onReply_GetHighDividendSOERank(MMAPI_Conn client, int nSerialNo, QotGetHighDividendSOERank.Response rsp) {
if (rsp.getRetType() != 0) {
System.out.printf("QotGetHighDividendSOERank failed: %s
", rsp.getRetMsg());
} else {
try {
String json = JsonFormat.printer().print(rsp);
System.out.printf("Receive QotGetHighDividendSOERank: %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
- Output
Send QotGetHighDividendSOERank: 3
Receive QotGetHighDividendSOERank: {
"allCount": 91,
"dataList": [
{ "security": { "market": 1, "code": "01398" }, "name": "工商銀行", "dividendYieldTtm": 5.087, "peTtm": 5.83050 },
{ "security": { "market": 1, "code": "00857" }, "name": "中國石油股份", "dividendYieldTtm": 5.764, "peTtm": 9.35648 },
{ "security": { "market": 1, "code": "00386" }, "name": "中國石油化工股份", "dividendYieldTtm": 5.432, "peTtm": 12.27138 }
]
}
2
3
4
5
6
7
8
9
moomoo::u32_t GetHighDividendSOERank(const Qot_GetHighDividendSOERank::Request &stReq);
virtual void OnReply_GetHighDividendSOERank(moomoo::u32_t nSerialNo, const Qot_GetHighDividendSOERank::Response &stRsp) = 0;
介紹
協議請求及回應定義
參數
// 排序方向
enum SortDir {
SortDir_Descending = 0; // 降序(默認)
SortDir_Ascending = 1; // 升序
}
// 排序字段
enum SortField {
SortField_Unknown = 0; // 默認(市值降序)
SortField_DividendYieldTTM = 1; // 股息率TTM
SortField_PB = 2; // 市淨率
SortField_PeTTM = 3; // 市盈率TTM
SortField_Price = 4; // 最新價
SortField_ChangeRatio = 5; // 今日漲跌幅
SortField_MarketCap = 6; // 市值
}
// 篩選條件類型
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_Price = 1; // 價格區間
IndicatorType_MarketCap = 2; // 市值區間
IndicatorType_PE = 3; // 市盈率TTM區間
IndicatorType_DividendYieldTTM = 4; // 股息率TTM區間
IndicatorType_ChangeRatio = 5; // 漲跌幅區間
}
// 篩選條件
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.Interval indicatorValue = 2; // 篩選區間
}
message C2S {
optional int32 sortField = 1; // SortField, 排序字段, 默認市值
optional int32 sortDir = 2; // SortDir, 排序方向, 默認降序
optional int32 offset = 3; // 起始位置, 默認0
optional int32 count = 4; // 返回數量 [1,200], 默認50
repeated Indicator filterList = 5; // 篩選條件(可覆蓋默認PB/股息率條件)
}
// 破淨高股息國央企數據項
// 默認固定條件(服務端硬編碼): 概念板塊=特估國企 + PB<=1 + 股息率TTM>=5% + PE>=0
message HighDividendSOERankItem {
required Qot_Common.Security security = 1; // 股票
optional string name = 2; // 名稱
optional string industry = 3; // 所屬行業
optional double curPrice = 10; // 最新價
optional double changeRatio = 11; // 漲跌幅(%)
optional double turnover = 12; // 成交額
optional int64 volume = 13; // 成交量
optional double marketCap = 14; // 市值
optional double peTTM = 20; // 市盈率TTM
optional double pb = 21; // 市淨率
optional double dividendYieldTTM = 22; // 股息率TTM(%)
optional double turnoverRatio = 23; // 換手率(%)
optional double changeRate5D = 30; // 5日漲幅(%)
optional double changeRate10D = 31; // 10日漲幅(%)
optional double changeRate20D = 32; // 20日漲幅(%)
optional double changeRate60D = 33; // 60日漲幅(%)
optional double changeRate120D = 34; // 120日漲幅(%)
optional double changeRate250D = 35; // 250日漲幅(%)
}
message S2C {
repeated HighDividendSOERankItem 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
- 介面呼叫結果,結構參見 RetType
協議 ID
3417
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_GetHighDividendSOERank::Request req;
Qot_GetHighDividendSOERank::C2S *c2s = req.mutable_c2s();
c2s->set_count(50);
m_GetHighDividendSOERankSerialNo = m_pQotApi->GetHighDividendSOERank(req);
}
virtual void OnReply_GetHighDividendSOERank(moomoo::u32_t nSerialNo, const Qot_GetHighDividendSOERank::Response &stRsp) {
if (nSerialNo != m_GetHighDividendSOERankSerialNo) return;
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
MMAPI_Qot *m_pQotApi;
moomoo::u32_t m_GetHighDividendSOERankSerialNo = 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
- Output
{
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"dataList": [
{
"security": {
"market": 1,
"code": "00939"
},
"name": "CCB",
"industry": "Bank",
"curPrice": 6.58,
"changeRatio": 0.46,
"marketCap": 1643000000000.0
}
],
"allCount": 50
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
getHighDividendSOERank(qotGetHighDividendSOERank)
介紹
獲取破淨高股息國央企排行(港股),返回滿足特估國企概念板塊、PB<=1、股息率TTM>=5%、PE>=0 默認條件的港股排行數據。用戶可通過篩選條件覆蓋默認閾值。
參數
// 排序方向
enum SortDir {
SortDir_Descending = 0; // 降序(默認)
SortDir_Ascending = 1; // 升序
}
// 排序字段
enum SortField {
SortField_Unknown = 0; // 默認(市值降序)
SortField_DividendYieldTTM = 1; // 股息率TTM
SortField_PB = 2; // 市淨率
SortField_PeTTM = 3; // 市盈率TTM
SortField_Price = 4; // 最新價
SortField_ChangeRatio = 5; // 今日漲跌幅
SortField_MarketCap = 6; // 市值
}
// 篩選條件類型
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_Price = 1; // 價格區間
IndicatorType_MarketCap = 2; // 市值區間
IndicatorType_PE = 3; // 市盈率TTM區間
IndicatorType_DividendYieldTTM = 4; // 股息率TTM區間
IndicatorType_ChangeRatio = 5; // 漲跌幅區間
}
// 篩選條件
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.Interval indicatorValue = 2; // 篩選區間
}
message C2S {
optional int32 sortField = 1; // SortField, 排序字段, 默認市值
optional int32 sortDir = 2; // SortDir, 排序方向, 默認降序
optional int32 offset = 3; // 起始位置, 默認0
optional int32 count = 4; // 返回數量 [1,200], 默認50
repeated Indicator filterList = 5; // 篩選條件(可覆蓋默認PB/股息率條件)
}
// 破淨高股息國央企數據項
// 默認固定條件(服務端硬編碼): 概念板塊=特估國企 + PB<=1 + 股息率TTM>=5% + PE>=0
message HighDividendSOERankItem {
required Qot_Common.Security security = 1; // 股票
optional string name = 2; // 名稱
optional string industry = 3; // 所屬行業
optional double curPrice = 10; // 最新價
optional double changeRatio = 11; // 漲跌幅(%)
optional double turnover = 12; // 成交額
optional int64 volume = 13; // 成交量
optional double marketCap = 14; // 市值
optional double peTTM = 20; // 市盈率TTM
optional double pb = 21; // 市淨率
optional double dividendYieldTTM = 22; // 股息率TTM(%)
optional double turnoverRatio = 23; // 換手率(%)
optional double changeRate5D = 30; // 5日漲幅(%)
optional double changeRate10D = 31; // 10日漲幅(%)
optional double changeRate20D = 32; // 20日漲幅(%)
optional double changeRate60D = 33; // 60日漲幅(%)
optional double changeRate120D = 34; // 120日漲幅(%)
optional double changeRate250D = 35; // 250日漲幅(%)
}
message S2C {
repeated HighDividendSOERankItem 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
- 接口調用結果,結構參見 RetType
協議 ID
3417
Example
import mmWebsocket from "moomoo-api";
import { Common, Qot_Common } from "moomoo-api/proto";
import beautify from "js-beautify";
function QotGetHighDividendSOERank(){
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: { count: 3 },
};
websocket.GetHighDividendSOERank(req)
.then((res)=>{
let { errCode, retMsg, retType, s2c } = res
console.log("GetHighDividendSOERank: 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);
}
QotGetHighDividendSOERank()
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
GetHighDividendSOERank: errCode 0, retMsg , retType 0
{
"allCount": 91,
"dataList": [
{ "security": { "market": 1, "code": "01398" }, "name": "工商銀行", "dividendYieldTtm": 5.087, "peTtm": 5.83050 },
{ "security": { "market": 1, "code": "00857" }, "name": "中國石油股份", "dividendYieldTtm": 5.764, "peTtm": 9.35648 },
{ "security": { "market": 1, "code": "00386" }, "name": "中國石油化工股份", "dividendYieldTtm": 5.432, "peTtm": 12.27138 }
]
}
2
3
4
5
6
7
8
9
接口限制
- 30 秒內最多 60 次請求
- 分頁請求僅首頁計入限頻統計