# Get Short Selling Rank
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_short_selling_rank(market=None, sort_field=None, sort_dir=None, count=10, offset=None, plate_list=None)
Description
Get short selling rank, returning US/HK stock short selling data rankings, supporting 14 sorting dimensions and industry sector filtering, including short selling volume, ratio, short position, days to cover, and other data.
Parameters
Parameter Type Description market Market Market type (HK/US), default US sort_field ShortSellingSortField Sort field, default short selling change sort_dir RankSortDir Sort direction, default descending count int Return count [1, 35], default 10 offset int Start position, default 0 plate_list list[str] Industry sector code list (e.g. ['US.BK2024']), empty=allReturn
Parameter Type Description ret RET_CODE API call result data pd.DataFrame When ret == RET_OK, returns (all_count, DataFrame) tuple str When ret != RET_OK, returns error description - Data format:
Field Type Description security str Stock code (e.g. 'US.GME')name str Stock name close_price float Close price change_ratio float Change rate (%) change_ratio_5d float 5-day change rate (%) change_ratio_10d float 10-day change rate (%) volume int Volume short_number int Short selling volume short_number_change int Short selling change short_ratio float Short selling ratio (%) short_ratio_change float Short selling ratio change (%) short_position_volume int Short position volume short_position_ratio float Short position ratio (%) days_to_cover float Days to cover week_avg_short_number int Weekly average daily short volume week_avg_short_ratio float Weekly average daily short ratio (%) month_avg_short_number int Monthly average daily short volume month_avg_short_ratio float Monthly average daily short ratio (%)
- Data format:
Example
from futu import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data = quote_ctx.get_short_selling_rank(count=2)
if ret == RET_OK:
all_count, df = data
print(f'Total count: {all_count}')
print(df)
else:
print('error:', data)
quote_ctx.close()
2
3
4
5
6
7
8
9
10
11
12
13
- Output
总数据量: 0
security name close_price change_ratio change_ratio_5d change_ratio_10d volume short_number short_number_change short_ratio short_ratio_change short_position_volume short_position_ratio days_to_cover week_avg_short_number week_avg_short_ratio month_avg_short_number month_avg_short_ratio
0 US.SKYQ Sky Quarry 1.9000 62.39 45.03 4.39 221413731 20302431 20226903 9.16 26780.66 327119 6.82 1.0 4111613 9.19 1136188 8.26
1 US.TNON Tenon Medical 0.6215 77.57 0.72 2.89 271138156 15289764 15273389 5.63 93272.60 149174 1.28 2.9 3063337 5.01 772705 5.04
2
3
4
# Qot_GetShortSellingRank.proto
Description
Get short selling anomaly rank, returns US/HK stock short selling data rankings, supporting 14 sorting dimensions and industry plate filtering, including short selling quantity, ratio, short position, days to cover and other data.
Parameters
// Sort direction
enum SortDir {
SortDir_Descending = 0; // Descending (default)
SortDir_Ascending = 1; // Ascending
}
// Sort field
enum ShortSellingSortField {
ShortSellingSortField_Unknown = 0; // Default (short selling change volume)
ShortSellingSortField_ShortNumberChange = 1; // Short selling change volume
ShortSellingSortField_ShortRatioChange = 2; // Short selling change ratio
ShortSellingSortField_ShortNumber = 3; // Short selling quantity
ShortSellingSortField_ShortRatio = 4; // Short selling ratio
ShortSellingSortField_Volume = 5; // Volume
ShortSellingSortField_PositionVolume = 6; // Short position quantity
ShortSellingSortField_PositionRatio = 7; // Short position ratio
ShortSellingSortField_DaysToCover = 8; // Days to cover
ShortSellingSortField_WeekAvgVolume = 9; // Weekly avg daily volume
ShortSellingSortField_WeekAvgShortNumber = 10; // Weekly avg daily short selling quantity
ShortSellingSortField_WeekAvgShortRatio = 11; // Weekly avg daily short selling ratio
ShortSellingSortField_MonthAvgVolume = 12; // Monthly avg daily volume
ShortSellingSortField_MonthAvgShortNumber = 13; // Monthly avg daily short selling quantity
ShortSellingSortField_MonthAvgShortRatio = 14; // Monthly avg daily short selling ratio
}
message C2S {
optional int32 market = 1; // Qot_Common.QotMarket, market (HK=1, US=11), default US
optional int32 sortField = 2; // ShortSellingSortField, sort field, default short selling change volume
optional int32 sortDir = 3; // SortDir, sort direction, default descending
optional int32 offset = 4; // Start position, default 0
optional int32 count = 5; // Return count [1,35], default 10
repeated Qot_Common.Security plateList = 6; // Industry plate list, empty=all
}
// Short selling anomaly data item
message ShortSellingRankItem {
required Qot_Common.Security security = 1; // Stock
optional string name = 2; // Name
optional double closePrice = 10; // Close price
optional double changeRatio = 11; // Change(%)
optional double changeRatio5D = 12; // 5-day change(%)
optional double changeRatio10D = 13; // 10-day change(%)
optional int64 volume = 14; // Volume
optional int64 shortNumber = 20; // Short selling quantity
optional int64 shortNumberChange = 21; // Short selling change volume
optional double shortRatio = 22; // Short selling ratio(%)
optional double shortRatioChange = 23; // Short selling change ratio(%)
optional int64 shortPositionVolume = 24; // Short position quantity
optional double shortPositionRatio = 25; // Short position ratio(%)
optional double daysToCover = 26; // Days to cover
optional int64 weekAvgShortNumber = 27; // Weekly avg daily short selling
optional double weekAvgShortRatio = 28; // Weekly avg daily short selling ratio(%)
optional int64 monthAvgShortNumber = 29; // Monthly avg daily short selling
optional double monthAvgShortRatio = 30; // Monthly avg daily short selling ratio(%)
}
message S2C {
repeated ShortSellingRankItem dataList = 1; // Data list
optional int32 allCount = 2; // Total matching data count
}
message Request {
required C2S c2s = 1;
}
message Response {
required int32 retType = 1 [default = -400]; // RetType, return result
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
Protocol ID
3415
uint GetShortSellingRank(Qot_GetShortSellingRank.Request req);
virtual void OnReply_GetShortSellingRank(FTAPI_Conn client, uint nSerialNo, Qot_GetShortSellingRank.Response rsp);
Description
Get short selling anomaly rank, returns US/HK stock short selling data rankings, supporting 14 sorting dimensions and industry plate filtering, including short selling quantity, ratio, short position, days to cover and other data.
Parameters
// Sort direction
enum SortDir {
SortDir_Descending = 0; // Descending (default)
SortDir_Ascending = 1; // Ascending
}
// Sort field
enum ShortSellingSortField {
ShortSellingSortField_Unknown = 0; // Default (short selling change volume)
ShortSellingSortField_ShortNumberChange = 1; // Short selling change volume
ShortSellingSortField_ShortRatioChange = 2; // Short selling change ratio
ShortSellingSortField_ShortNumber = 3; // Short selling quantity
ShortSellingSortField_ShortRatio = 4; // Short selling ratio
ShortSellingSortField_Volume = 5; // Volume
ShortSellingSortField_PositionVolume = 6; // Short position quantity
ShortSellingSortField_PositionRatio = 7; // Short position ratio
ShortSellingSortField_DaysToCover = 8; // Days to cover
ShortSellingSortField_WeekAvgVolume = 9; // Weekly avg daily volume
ShortSellingSortField_WeekAvgShortNumber = 10; // Weekly avg daily short selling quantity
ShortSellingSortField_WeekAvgShortRatio = 11; // Weekly avg daily short selling ratio
ShortSellingSortField_MonthAvgVolume = 12; // Monthly avg daily volume
ShortSellingSortField_MonthAvgShortNumber = 13; // Monthly avg daily short selling quantity
ShortSellingSortField_MonthAvgShortRatio = 14; // Monthly avg daily short selling ratio
}
message C2S {
optional int32 market = 1; // Qot_Common.QotMarket, market (HK=1, US=11), default US
optional int32 sortField = 2; // ShortSellingSortField, sort field, default short selling change volume
optional int32 sortDir = 3; // SortDir, sort direction, default descending
optional int32 offset = 4; // Start position, default 0
optional int32 count = 5; // Return count [1,35], default 10
repeated Qot_Common.Security plateList = 6; // Industry plate list, empty=all
}
// Short selling anomaly data item
message ShortSellingRankItem {
required Qot_Common.Security security = 1; // Stock
optional string name = 2; // Name
optional double closePrice = 10; // Close price
optional double changeRatio = 11; // Change(%)
optional double changeRatio5D = 12; // 5-day change(%)
optional double changeRatio10D = 13; // 10-day change(%)
optional int64 volume = 14; // Volume
optional int64 shortNumber = 20; // Short selling quantity
optional int64 shortNumberChange = 21; // Short selling change volume
optional double shortRatio = 22; // Short selling ratio(%)
optional double shortRatioChange = 23; // Short selling change ratio(%)
optional int64 shortPositionVolume = 24; // Short position quantity
optional double shortPositionRatio = 25; // Short position ratio(%)
optional double daysToCover = 26; // Days to cover
optional int64 weekAvgShortNumber = 27; // Weekly avg daily short selling
optional double weekAvgShortRatio = 28; // Weekly avg daily short selling ratio(%)
optional int64 monthAvgShortNumber = 29; // Monthly avg daily short selling
optional double monthAvgShortRatio = 30; // Monthly avg daily short selling ratio(%)
}
message S2C {
repeated ShortSellingRankItem dataList = 1; // Data list
optional int32 allCount = 2; // Total matching data count
}
message Request {
required C2S c2s = 1;
}
message Response {
required int32 retType = 1 [default = -400]; // RetType, return result
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
- For interface result, refer to RetType
Protocol ID
3415
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;
QotGetShortSellingRank.C2S c2s = QotGetShortSellingRank.C2S.CreateBuilder()
.SetMarket(11)
.SetCount(3)
.Build();
QotGetShortSellingRank.Request req = QotGetShortSellingRank.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetShortSellingRank(req);
Console.Write("Send QotGetShortSellingRank: {0}
", seqNo);
}
public void OnDisconnect(FTAPI_Conn client, long errCode) {
Console.Write("Qot onDisConnect: {0}
", errCode);
}
public void OnReply_GetShortSellingRank(FTAPI_Conn client, uint nSerialNo, QotGetShortSellingRank.Response rsp)
{
Console.Write("Reply: QotGetShortSellingRank: {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
- Output
Send QotGetShortSellingRank: 3
Reply: QotGetShortSellingRank: 3
GetShortSellingRank: errCode 0, retMsg , retType 0
{
"allCount": 3,
"dataList": [
{ "security": { "market": 11, "code": "ADTX" }, "name": "Aditxt", "shortRatio": 5.42, "shortRatioChange": 62.78 },
{ "security": { "market": 11, "code": "CDE" }, "name": "科尔黛伦矿业", "shortRatio": 39.44, "shortRatioChange": 779.14 },
{ "security": { "market": 11, "code": "PFE" }, "name": "辉瑞", "shortRatio": 31.48, "shortRatioChange": 466.48 }
]
}
2
3
4
5
6
7
8
9
10
11
int getShortSellingRank(Qot_GetShortSellingRank.Request req);
onReply_GetShortSellingRank(FTAPI_Conn client, int nSerialNo, Qot_GetShortSellingRank.Response rsp)
Description
Get short selling anomaly rank, returns US/HK stock short selling data rankings, supporting 14 sorting dimensions and industry plate filtering, including short selling quantity, ratio, short position, days to cover and other data.
Parameters
// Sort direction
enum SortDir {
SortDir_Descending = 0; // Descending (default)
SortDir_Ascending = 1; // Ascending
}
// Sort field
enum ShortSellingSortField {
ShortSellingSortField_Unknown = 0; // Default (short selling change volume)
ShortSellingSortField_ShortNumberChange = 1; // Short selling change volume
ShortSellingSortField_ShortRatioChange = 2; // Short selling change ratio
ShortSellingSortField_ShortNumber = 3; // Short selling quantity
ShortSellingSortField_ShortRatio = 4; // Short selling ratio
ShortSellingSortField_Volume = 5; // Volume
ShortSellingSortField_PositionVolume = 6; // Short position quantity
ShortSellingSortField_PositionRatio = 7; // Short position ratio
ShortSellingSortField_DaysToCover = 8; // Days to cover
ShortSellingSortField_WeekAvgVolume = 9; // Weekly avg daily volume
ShortSellingSortField_WeekAvgShortNumber = 10; // Weekly avg daily short selling quantity
ShortSellingSortField_WeekAvgShortRatio = 11; // Weekly avg daily short selling ratio
ShortSellingSortField_MonthAvgVolume = 12; // Monthly avg daily volume
ShortSellingSortField_MonthAvgShortNumber = 13; // Monthly avg daily short selling quantity
ShortSellingSortField_MonthAvgShortRatio = 14; // Monthly avg daily short selling ratio
}
message C2S {
optional int32 market = 1; // Qot_Common.QotMarket, market (HK=1, US=11), default US
optional int32 sortField = 2; // ShortSellingSortField, sort field, default short selling change volume
optional int32 sortDir = 3; // SortDir, sort direction, default descending
optional int32 offset = 4; // Start position, default 0
optional int32 count = 5; // Return count [1,35], default 10
repeated Qot_Common.Security plateList = 6; // Industry plate list, empty=all
}
// Short selling anomaly data item
message ShortSellingRankItem {
required Qot_Common.Security security = 1; // Stock
optional string name = 2; // Name
optional double closePrice = 10; // Close price
optional double changeRatio = 11; // Change(%)
optional double changeRatio5D = 12; // 5-day change(%)
optional double changeRatio10D = 13; // 10-day change(%)
optional int64 volume = 14; // Volume
optional int64 shortNumber = 20; // Short selling quantity
optional int64 shortNumberChange = 21; // Short selling change volume
optional double shortRatio = 22; // Short selling ratio(%)
optional double shortRatioChange = 23; // Short selling change ratio(%)
optional int64 shortPositionVolume = 24; // Short position quantity
optional double shortPositionRatio = 25; // Short position ratio(%)
optional double daysToCover = 26; // Days to cover
optional int64 weekAvgShortNumber = 27; // Weekly avg daily short selling
optional double weekAvgShortRatio = 28; // Weekly avg daily short selling ratio(%)
optional int64 monthAvgShortNumber = 29; // Monthly avg daily short selling
optional double monthAvgShortRatio = 30; // Monthly avg daily short selling ratio(%)
}
message S2C {
repeated ShortSellingRankItem dataList = 1; // Data list
optional int32 allCount = 2; // Total matching data count
}
message Request {
required C2S c2s = 1;
}
message Response {
required int32 retType = 1 [default = -400]; // RetType, return result
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
- For interface result, refer to RetType
Protocol ID
3415
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;
QotGetShortSellingRank.C2S c2s = QotGetShortSellingRank.C2S.newBuilder()
.setMarket(11)
.setCount(3)
.build();
QotGetShortSellingRank.Request req = QotGetShortSellingRank.Request.newBuilder().setC2S(c2s).build();
int seqNo = qot.getShortSellingRank(req);
System.out.printf("Send QotGetShortSellingRank: %d
", seqNo);
}
@Override
public void onDisconnect(FTAPI_Conn client, long errCode) {
System.out.printf("Qot onDisConnect: %d
", errCode);
}
@Override
public void onReply_GetShortSellingRank(FTAPI_Conn client, int nSerialNo, QotGetShortSellingRank.Response rsp) {
if (rsp.getRetType() != 0) {
System.out.printf("QotGetShortSellingRank failed: %s
", rsp.getRetMsg());
} else {
try {
String json = JsonFormat.printer().print(rsp);
System.out.printf("Receive QotGetShortSellingRank: %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
- Output
Send QotGetShortSellingRank: 3
Receive QotGetShortSellingRank: {
"allCount": 3,
"dataList": [
{ "security": { "market": 11, "code": "ADTX" }, "name": "Aditxt", "shortRatio": 5.42, "shortRatioChange": 62.78 },
{ "security": { "market": 11, "code": "CDE" }, "name": "科尔黛伦矿业", "shortRatio": 39.44, "shortRatioChange": 779.14 },
{ "security": { "market": 11, "code": "PFE" }, "name": "辉瑞", "shortRatio": 31.48, "shortRatioChange": 466.48 }
]
}
2
3
4
5
6
7
8
9
Futu::u32_t GetShortSellingRank(const Qot_GetShortSellingRank::Request &stReq);
virtual void OnReply_GetShortSellingRank(Futu::u32_t nSerialNo, const Qot_GetShortSellingRank::Response &stRsp) = 0;
Description
Protocol request and response definition
Parameters
// Sort direction
enum SortDir {
SortDir_Descending = 0; // Descending (default)
SortDir_Ascending = 1; // Ascending
}
// Sort field
enum ShortSellingSortField {
ShortSellingSortField_Unknown = 0; // Default (short selling change volume)
ShortSellingSortField_ShortNumberChange = 1; // Short selling change volume
ShortSellingSortField_ShortRatioChange = 2; // Short selling change ratio
ShortSellingSortField_ShortNumber = 3; // Short selling quantity
ShortSellingSortField_ShortRatio = 4; // Short selling ratio
ShortSellingSortField_Volume = 5; // Volume
ShortSellingSortField_PositionVolume = 6; // Short position quantity
ShortSellingSortField_PositionRatio = 7; // Short position ratio
ShortSellingSortField_DaysToCover = 8; // Days to cover
ShortSellingSortField_WeekAvgVolume = 9; // Weekly avg daily volume
ShortSellingSortField_WeekAvgShortNumber = 10; // Weekly avg daily short selling quantity
ShortSellingSortField_WeekAvgShortRatio = 11; // Weekly avg daily short selling ratio
ShortSellingSortField_MonthAvgVolume = 12; // Monthly avg daily volume
ShortSellingSortField_MonthAvgShortNumber = 13; // Monthly avg daily short selling quantity
ShortSellingSortField_MonthAvgShortRatio = 14; // Monthly avg daily short selling ratio
}
message C2S {
optional int32 market = 1; // Qot_Common.QotMarket, market (HK=1, US=11), default US
optional int32 sortField = 2; // ShortSellingSortField, sort field, default short selling change volume
optional int32 sortDir = 3; // SortDir, sort direction, default descending
optional int32 offset = 4; // Start position, default 0
optional int32 count = 5; // Return count [1,35], default 10
repeated Qot_Common.Security plateList = 6; // Industry plate list, empty=all
}
// Short selling anomaly data item
message ShortSellingRankItem {
required Qot_Common.Security security = 1; // Stock
optional string name = 2; // Name
optional double closePrice = 10; // Close price
optional double changeRatio = 11; // Change(%)
optional double changeRatio5D = 12; // 5-day change(%)
optional double changeRatio10D = 13; // 10-day change(%)
optional int64 volume = 14; // Volume
optional int64 shortNumber = 20; // Short selling quantity
optional int64 shortNumberChange = 21; // Short selling change volume
optional double shortRatio = 22; // Short selling ratio(%)
optional double shortRatioChange = 23; // Short selling change ratio(%)
optional int64 shortPositionVolume = 24; // Short position quantity
optional double shortPositionRatio = 25; // Short position ratio(%)
optional double daysToCover = 26; // Days to cover
optional int64 weekAvgShortNumber = 27; // Weekly avg daily short selling
optional double weekAvgShortRatio = 28; // Weekly avg daily short selling ratio(%)
optional int64 monthAvgShortNumber = 29; // Monthly avg daily short selling
optional double monthAvgShortRatio = 30; // Monthly avg daily short selling ratio(%)
}
message S2C {
repeated ShortSellingRankItem dataList = 1; // Data list
optional int32 allCount = 2; // Total matching data count
}
message Request {
required C2S c2s = 1;
}
message Response {
required int32 retType = 1 [default = -400]; // RetType, return result
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
- For interface result, refer to RetType
Protocol ID
3415
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_GetShortSellingRank::Request req;
Qot_GetShortSellingRank::C2S *c2s = req.mutable_c2s();
c2s->set_market(Qot_Common::QotMarket::QotMarket_US_Security);
c2s->set_count(50);
m_GetShortSellingRankSerialNo = m_pQotApi->GetShortSellingRank(req);
}
virtual void OnReply_GetShortSellingRank(Futu::u32_t nSerialNo, const Qot_GetShortSellingRank::Response &stRsp) {
if (nSerialNo != m_GetShortSellingRankSerialNo) return;
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
FTAPI_Qot *m_pQotApi;
Futu::u32_t m_GetShortSellingRankSerialNo = 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
- Output
{
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"dataList": [
{
"security": {
"market": 11,
"code": "GME"
},
"name": "GameStop",
"closePrice": 25.5,
"changeRatio": 5.2,
"volume": 85000000,
"shortNumber": 45000000
}
],
"allCount": 50
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
getShortSellingRank(qotGetShortSellingRank)
Description
Get short selling anomaly rank, returns US/HK stock short selling data rankings, supporting 14 sorting dimensions and industry plate filtering, including short selling quantity, ratio, short position, days to cover and other data.
Parameters
// Sort direction
enum SortDir {
SortDir_Descending = 0; // Descending (default)
SortDir_Ascending = 1; // Ascending
}
// Sort field
enum ShortSellingSortField {
ShortSellingSortField_Unknown = 0; // Default (short selling change volume)
ShortSellingSortField_ShortNumberChange = 1; // Short selling change volume
ShortSellingSortField_ShortRatioChange = 2; // Short selling change ratio
ShortSellingSortField_ShortNumber = 3; // Short selling quantity
ShortSellingSortField_ShortRatio = 4; // Short selling ratio
ShortSellingSortField_Volume = 5; // Volume
ShortSellingSortField_PositionVolume = 6; // Short position quantity
ShortSellingSortField_PositionRatio = 7; // Short position ratio
ShortSellingSortField_DaysToCover = 8; // Days to cover
ShortSellingSortField_WeekAvgVolume = 9; // Weekly avg daily volume
ShortSellingSortField_WeekAvgShortNumber = 10; // Weekly avg daily short selling quantity
ShortSellingSortField_WeekAvgShortRatio = 11; // Weekly avg daily short selling ratio
ShortSellingSortField_MonthAvgVolume = 12; // Monthly avg daily volume
ShortSellingSortField_MonthAvgShortNumber = 13; // Monthly avg daily short selling quantity
ShortSellingSortField_MonthAvgShortRatio = 14; // Monthly avg daily short selling ratio
}
message C2S {
optional int32 market = 1; // Qot_Common.QotMarket, market (HK=1, US=11), default US
optional int32 sortField = 2; // ShortSellingSortField, sort field, default short selling change volume
optional int32 sortDir = 3; // SortDir, sort direction, default descending
optional int32 offset = 4; // Start position, default 0
optional int32 count = 5; // Return count [1,35], default 10
repeated Qot_Common.Security plateList = 6; // Industry plate list, empty=all
}
// Short selling anomaly data item
message ShortSellingRankItem {
required Qot_Common.Security security = 1; // Stock
optional string name = 2; // Name
optional double closePrice = 10; // Close price
optional double changeRatio = 11; // Change(%)
optional double changeRatio5D = 12; // 5-day change(%)
optional double changeRatio10D = 13; // 10-day change(%)
optional int64 volume = 14; // Volume
optional int64 shortNumber = 20; // Short selling quantity
optional int64 shortNumberChange = 21; // Short selling change volume
optional double shortRatio = 22; // Short selling ratio(%)
optional double shortRatioChange = 23; // Short selling change ratio(%)
optional int64 shortPositionVolume = 24; // Short position quantity
optional double shortPositionRatio = 25; // Short position ratio(%)
optional double daysToCover = 26; // Days to cover
optional int64 weekAvgShortNumber = 27; // Weekly avg daily short selling
optional double weekAvgShortRatio = 28; // Weekly avg daily short selling ratio(%)
optional int64 monthAvgShortNumber = 29; // Monthly avg daily short selling
optional double monthAvgShortRatio = 30; // Monthly avg daily short selling ratio(%)
}
message S2C {
repeated ShortSellingRankItem dataList = 1; // Data list
optional int32 allCount = 2; // Total matching data count
}
message Request {
required C2S c2s = 1;
}
message Response {
required int32 retType = 1 [default = -400]; // RetType, return result
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
- For interface result, refer to RetType
Protocol ID
3415
Example
import ftWebsocket from "futu-api";
import { Common, Qot_Common } from "futu-api/proto";
import beautify from "js-beautify";
function QotGetShortSellingRank(){
const { RetType } = Common
let [addr, port, enable_ssl, key] = ["127.0.0.1", 11111, false, "xxxxxx"];
let websocket = new ftWebsocket();
websocket.onlogin = (ret, msg)=>{
if (ret) {
const req = {
c2s: { market: 11, count: 3 },
};
websocket.GetShortSellingRank(req)
.then((res)=>{
let { errCode, retMsg, retType, s2c } = res
console.log("GetShortSellingRank: 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);
}
QotGetShortSellingRank()
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
GetShortSellingRank: errCode 0, retMsg , retType 0
{
"allCount": 3,
"dataList": [
{ "security": { "market": 11, "code": "ADTX" }, "name": "Aditxt", "shortRatio": 5.42, "shortRatioChange": 62.78 },
{ "security": { "market": 11, "code": "CDE" }, "name": "科尔黛伦矿业", "shortRatio": 39.44, "shortRatioChange": 779.14 },
{ "security": { "market": 11, "code": "PFE" }, "name": "辉瑞", "shortRatio": 31.48, "shortRatioChange": 466.48 }
]
}
2
3
4
5
6
7
8
9
API Limits
- Maximum 60 requests within 30 seconds
- Only the first page of paginated requests counts toward rate limiting
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_short_selling_rank(market=None, sort_field=None, sort_dir=None, count=10, offset=None, plate_list=None)
Description
Get short selling rank, returning US/HK stock short selling data rankings, supporting 14 sorting dimensions and industry sector filtering, including short selling volume, ratio, short position, days to cover, and other data.
Parameters
Parameter Type Description market Market Market type (HK/US), default US sort_field ShortSellingSortField Sort field, default short selling change sort_dir RankSortDir Sort direction, default descending count int Return count [1, 35], default 10 offset int Start position, default 0 plate_list list[str] Industry sector code list (e.g. ['US.BK2024']), empty=allReturn
Parameter Type Description ret RET_CODE API call result data pd.DataFrame When ret == RET_OK, returns (all_count, DataFrame) tuple str When ret != RET_OK, returns error description - Data format:
Field Type Description security str Stock code (e.g. 'US.GME')name str Stock name close_price float Close price change_ratio float Change rate (%) change_ratio_5d float 5-day change rate (%) change_ratio_10d float 10-day change rate (%) volume int Volume short_number int Short selling volume short_number_change int Short selling change short_ratio float Short selling ratio (%) short_ratio_change float Short selling ratio change (%) short_position_volume int Short position volume short_position_ratio float Short position ratio (%) days_to_cover float Days to cover week_avg_short_number int Weekly average daily short volume week_avg_short_ratio float Weekly average daily short ratio (%) month_avg_short_number int Monthly average daily short volume month_avg_short_ratio float Monthly average daily short ratio (%)
- Data format:
Example
from futu import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data = quote_ctx.get_short_selling_rank(count=2)
if ret == RET_OK:
all_count, df = data
print(f'Total count: {all_count}')
print(df)
else:
print('error:', data)
quote_ctx.close()
2
3
4
5
6
7
8
9
10
11
12
13
- Output
总数据量: 0
security name close_price change_ratio change_ratio_5d change_ratio_10d volume short_number short_number_change short_ratio short_ratio_change short_position_volume short_position_ratio days_to_cover week_avg_short_number week_avg_short_ratio month_avg_short_number month_avg_short_ratio
0 US.SKYQ Sky Quarry 1.9000 62.39 45.03 4.39 221413731 20302431 20226903 9.16 26780.66 327119 6.82 1.0 4111613 9.19 1136188 8.26
1 US.TNON Tenon Medical 0.6215 77.57 0.72 2.89 271138156 15289764 15273389 5.63 93272.60 149174 1.28 2.9 3063337 5.01 772705 5.04
2
3
4
# Qot_GetShortSellingRank.proto
Description
Get short selling anomaly rank, returns US/HK stock short selling data rankings, supporting 14 sorting dimensions and industry plate filtering, including short selling quantity, ratio, short position, days to cover and other data.
Parameters
// Sort direction
enum SortDir {
SortDir_Descending = 0; // Descending (default)
SortDir_Ascending = 1; // Ascending
}
// Sort field
enum ShortSellingSortField {
ShortSellingSortField_Unknown = 0; // Default (short selling change volume)
ShortSellingSortField_ShortNumberChange = 1; // Short selling change volume
ShortSellingSortField_ShortRatioChange = 2; // Short selling change ratio
ShortSellingSortField_ShortNumber = 3; // Short selling quantity
ShortSellingSortField_ShortRatio = 4; // Short selling ratio
ShortSellingSortField_Volume = 5; // Volume
ShortSellingSortField_PositionVolume = 6; // Short position quantity
ShortSellingSortField_PositionRatio = 7; // Short position ratio
ShortSellingSortField_DaysToCover = 8; // Days to cover
ShortSellingSortField_WeekAvgVolume = 9; // Weekly avg daily volume
ShortSellingSortField_WeekAvgShortNumber = 10; // Weekly avg daily short selling quantity
ShortSellingSortField_WeekAvgShortRatio = 11; // Weekly avg daily short selling ratio
ShortSellingSortField_MonthAvgVolume = 12; // Monthly avg daily volume
ShortSellingSortField_MonthAvgShortNumber = 13; // Monthly avg daily short selling quantity
ShortSellingSortField_MonthAvgShortRatio = 14; // Monthly avg daily short selling ratio
}
message C2S {
optional int32 market = 1; // Qot_Common.QotMarket, market (HK=1, US=11), default US
optional int32 sortField = 2; // ShortSellingSortField, sort field, default short selling change volume
optional int32 sortDir = 3; // SortDir, sort direction, default descending
optional int32 offset = 4; // Start position, default 0
optional int32 count = 5; // Return count [1,35], default 10
repeated Qot_Common.Security plateList = 6; // Industry plate list, empty=all
}
// Short selling anomaly data item
message ShortSellingRankItem {
required Qot_Common.Security security = 1; // Stock
optional string name = 2; // Name
optional double closePrice = 10; // Close price
optional double changeRatio = 11; // Change(%)
optional double changeRatio5D = 12; // 5-day change(%)
optional double changeRatio10D = 13; // 10-day change(%)
optional int64 volume = 14; // Volume
optional int64 shortNumber = 20; // Short selling quantity
optional int64 shortNumberChange = 21; // Short selling change volume
optional double shortRatio = 22; // Short selling ratio(%)
optional double shortRatioChange = 23; // Short selling change ratio(%)
optional int64 shortPositionVolume = 24; // Short position quantity
optional double shortPositionRatio = 25; // Short position ratio(%)
optional double daysToCover = 26; // Days to cover
optional int64 weekAvgShortNumber = 27; // Weekly avg daily short selling
optional double weekAvgShortRatio = 28; // Weekly avg daily short selling ratio(%)
optional int64 monthAvgShortNumber = 29; // Monthly avg daily short selling
optional double monthAvgShortRatio = 30; // Monthly avg daily short selling ratio(%)
}
message S2C {
repeated ShortSellingRankItem dataList = 1; // Data list
optional int32 allCount = 2; // Total matching data count
}
message Request {
required C2S c2s = 1;
}
message Response {
required int32 retType = 1 [default = -400]; // RetType, return result
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
Protocol ID
3415
uint GetShortSellingRank(Qot_GetShortSellingRank.Request req);
virtual void OnReply_GetShortSellingRank(FTAPI_Conn client, uint nSerialNo, Qot_GetShortSellingRank.Response rsp);
Description
Get short selling anomaly rank, returns US/HK stock short selling data rankings, supporting 14 sorting dimensions and industry plate filtering, including short selling quantity, ratio, short position, days to cover and other data.
Parameters
// Sort direction
enum SortDir {
SortDir_Descending = 0; // Descending (default)
SortDir_Ascending = 1; // Ascending
}
// Sort field
enum ShortSellingSortField {
ShortSellingSortField_Unknown = 0; // Default (short selling change volume)
ShortSellingSortField_ShortNumberChange = 1; // Short selling change volume
ShortSellingSortField_ShortRatioChange = 2; // Short selling change ratio
ShortSellingSortField_ShortNumber = 3; // Short selling quantity
ShortSellingSortField_ShortRatio = 4; // Short selling ratio
ShortSellingSortField_Volume = 5; // Volume
ShortSellingSortField_PositionVolume = 6; // Short position quantity
ShortSellingSortField_PositionRatio = 7; // Short position ratio
ShortSellingSortField_DaysToCover = 8; // Days to cover
ShortSellingSortField_WeekAvgVolume = 9; // Weekly avg daily volume
ShortSellingSortField_WeekAvgShortNumber = 10; // Weekly avg daily short selling quantity
ShortSellingSortField_WeekAvgShortRatio = 11; // Weekly avg daily short selling ratio
ShortSellingSortField_MonthAvgVolume = 12; // Monthly avg daily volume
ShortSellingSortField_MonthAvgShortNumber = 13; // Monthly avg daily short selling quantity
ShortSellingSortField_MonthAvgShortRatio = 14; // Monthly avg daily short selling ratio
}
message C2S {
optional int32 market = 1; // Qot_Common.QotMarket, market (HK=1, US=11), default US
optional int32 sortField = 2; // ShortSellingSortField, sort field, default short selling change volume
optional int32 sortDir = 3; // SortDir, sort direction, default descending
optional int32 offset = 4; // Start position, default 0
optional int32 count = 5; // Return count [1,35], default 10
repeated Qot_Common.Security plateList = 6; // Industry plate list, empty=all
}
// Short selling anomaly data item
message ShortSellingRankItem {
required Qot_Common.Security security = 1; // Stock
optional string name = 2; // Name
optional double closePrice = 10; // Close price
optional double changeRatio = 11; // Change(%)
optional double changeRatio5D = 12; // 5-day change(%)
optional double changeRatio10D = 13; // 10-day change(%)
optional int64 volume = 14; // Volume
optional int64 shortNumber = 20; // Short selling quantity
optional int64 shortNumberChange = 21; // Short selling change volume
optional double shortRatio = 22; // Short selling ratio(%)
optional double shortRatioChange = 23; // Short selling change ratio(%)
optional int64 shortPositionVolume = 24; // Short position quantity
optional double shortPositionRatio = 25; // Short position ratio(%)
optional double daysToCover = 26; // Days to cover
optional int64 weekAvgShortNumber = 27; // Weekly avg daily short selling
optional double weekAvgShortRatio = 28; // Weekly avg daily short selling ratio(%)
optional int64 monthAvgShortNumber = 29; // Monthly avg daily short selling
optional double monthAvgShortRatio = 30; // Monthly avg daily short selling ratio(%)
}
message S2C {
repeated ShortSellingRankItem dataList = 1; // Data list
optional int32 allCount = 2; // Total matching data count
}
message Request {
required C2S c2s = 1;
}
message Response {
required int32 retType = 1 [default = -400]; // RetType, return result
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
- For interface result, refer to RetType
Protocol ID
3415
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;
QotGetShortSellingRank.C2S c2s = QotGetShortSellingRank.C2S.CreateBuilder()
.SetMarket(11)
.SetCount(3)
.Build();
QotGetShortSellingRank.Request req = QotGetShortSellingRank.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetShortSellingRank(req);
Console.Write("Send QotGetShortSellingRank: {0}
", seqNo);
}
public void OnDisconnect(MMAPI_Conn client, long errCode) {
Console.Write("Qot onDisConnect: {0}
", errCode);
}
public void OnReply_GetShortSellingRank(MMAPI_Conn client, uint nSerialNo, QotGetShortSellingRank.Response rsp)
{
Console.Write("Reply: QotGetShortSellingRank: {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
- Output
Send QotGetShortSellingRank: 3
Reply: QotGetShortSellingRank: 3
GetShortSellingRank: errCode 0, retMsg , retType 0
{
"allCount": 3,
"dataList": [
{ "security": { "market": 11, "code": "ADTX" }, "name": "Aditxt", "shortRatio": 5.42, "shortRatioChange": 62.78 },
{ "security": { "market": 11, "code": "CDE" }, "name": "科尔黛伦矿业", "shortRatio": 39.44, "shortRatioChange": 779.14 },
{ "security": { "market": 11, "code": "PFE" }, "name": "辉瑞", "shortRatio": 31.48, "shortRatioChange": 466.48 }
]
}
2
3
4
5
6
7
8
9
10
11
int getShortSellingRank(Qot_GetShortSellingRank.Request req);
onReply_GetShortSellingRank(FTAPI_Conn client, int nSerialNo, Qot_GetShortSellingRank.Response rsp)
Description
Get short selling anomaly rank, returns US/HK stock short selling data rankings, supporting 14 sorting dimensions and industry plate filtering, including short selling quantity, ratio, short position, days to cover and other data.
Parameters
// Sort direction
enum SortDir {
SortDir_Descending = 0; // Descending (default)
SortDir_Ascending = 1; // Ascending
}
// Sort field
enum ShortSellingSortField {
ShortSellingSortField_Unknown = 0; // Default (short selling change volume)
ShortSellingSortField_ShortNumberChange = 1; // Short selling change volume
ShortSellingSortField_ShortRatioChange = 2; // Short selling change ratio
ShortSellingSortField_ShortNumber = 3; // Short selling quantity
ShortSellingSortField_ShortRatio = 4; // Short selling ratio
ShortSellingSortField_Volume = 5; // Volume
ShortSellingSortField_PositionVolume = 6; // Short position quantity
ShortSellingSortField_PositionRatio = 7; // Short position ratio
ShortSellingSortField_DaysToCover = 8; // Days to cover
ShortSellingSortField_WeekAvgVolume = 9; // Weekly avg daily volume
ShortSellingSortField_WeekAvgShortNumber = 10; // Weekly avg daily short selling quantity
ShortSellingSortField_WeekAvgShortRatio = 11; // Weekly avg daily short selling ratio
ShortSellingSortField_MonthAvgVolume = 12; // Monthly avg daily volume
ShortSellingSortField_MonthAvgShortNumber = 13; // Monthly avg daily short selling quantity
ShortSellingSortField_MonthAvgShortRatio = 14; // Monthly avg daily short selling ratio
}
message C2S {
optional int32 market = 1; // Qot_Common.QotMarket, market (HK=1, US=11), default US
optional int32 sortField = 2; // ShortSellingSortField, sort field, default short selling change volume
optional int32 sortDir = 3; // SortDir, sort direction, default descending
optional int32 offset = 4; // Start position, default 0
optional int32 count = 5; // Return count [1,35], default 10
repeated Qot_Common.Security plateList = 6; // Industry plate list, empty=all
}
// Short selling anomaly data item
message ShortSellingRankItem {
required Qot_Common.Security security = 1; // Stock
optional string name = 2; // Name
optional double closePrice = 10; // Close price
optional double changeRatio = 11; // Change(%)
optional double changeRatio5D = 12; // 5-day change(%)
optional double changeRatio10D = 13; // 10-day change(%)
optional int64 volume = 14; // Volume
optional int64 shortNumber = 20; // Short selling quantity
optional int64 shortNumberChange = 21; // Short selling change volume
optional double shortRatio = 22; // Short selling ratio(%)
optional double shortRatioChange = 23; // Short selling change ratio(%)
optional int64 shortPositionVolume = 24; // Short position quantity
optional double shortPositionRatio = 25; // Short position ratio(%)
optional double daysToCover = 26; // Days to cover
optional int64 weekAvgShortNumber = 27; // Weekly avg daily short selling
optional double weekAvgShortRatio = 28; // Weekly avg daily short selling ratio(%)
optional int64 monthAvgShortNumber = 29; // Monthly avg daily short selling
optional double monthAvgShortRatio = 30; // Monthly avg daily short selling ratio(%)
}
message S2C {
repeated ShortSellingRankItem dataList = 1; // Data list
optional int32 allCount = 2; // Total matching data count
}
message Request {
required C2S c2s = 1;
}
message Response {
required int32 retType = 1 [default = -400]; // RetType, return result
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
- For interface result, refer to RetType
Protocol ID
3415
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;
QotGetShortSellingRank.C2S c2s = QotGetShortSellingRank.C2S.newBuilder()
.setMarket(11)
.setCount(3)
.build();
QotGetShortSellingRank.Request req = QotGetShortSellingRank.Request.newBuilder().setC2S(c2s).build();
int seqNo = qot.getShortSellingRank(req);
System.out.printf("Send QotGetShortSellingRank: %d
", seqNo);
}
@Override
public void onDisconnect(MMAPI_Conn client, long errCode) {
System.out.printf("Qot onDisConnect: %d
", errCode);
}
@Override
public void onReply_GetShortSellingRank(MMAPI_Conn client, int nSerialNo, QotGetShortSellingRank.Response rsp) {
if (rsp.getRetType() != 0) {
System.out.printf("QotGetShortSellingRank failed: %s
", rsp.getRetMsg());
} else {
try {
String json = JsonFormat.printer().print(rsp);
System.out.printf("Receive QotGetShortSellingRank: %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
- Output
Send QotGetShortSellingRank: 3
Receive QotGetShortSellingRank: {
"allCount": 3,
"dataList": [
{ "security": { "market": 11, "code": "ADTX" }, "name": "Aditxt", "shortRatio": 5.42, "shortRatioChange": 62.78 },
{ "security": { "market": 11, "code": "CDE" }, "name": "科尔黛伦矿业", "shortRatio": 39.44, "shortRatioChange": 779.14 },
{ "security": { "market": 11, "code": "PFE" }, "name": "辉瑞", "shortRatio": 31.48, "shortRatioChange": 466.48 }
]
}
2
3
4
5
6
7
8
9
moomoo::u32_t GetShortSellingRank(const Qot_GetShortSellingRank::Request &stReq);
virtual void OnReply_GetShortSellingRank(moomoo::u32_t nSerialNo, const Qot_GetShortSellingRank::Response &stRsp) = 0;
Description
Protocol request and response definition
Parameters
// Sort direction
enum SortDir {
SortDir_Descending = 0; // Descending (default)
SortDir_Ascending = 1; // Ascending
}
// Sort field
enum ShortSellingSortField {
ShortSellingSortField_Unknown = 0; // Default (short selling change volume)
ShortSellingSortField_ShortNumberChange = 1; // Short selling change volume
ShortSellingSortField_ShortRatioChange = 2; // Short selling change ratio
ShortSellingSortField_ShortNumber = 3; // Short selling quantity
ShortSellingSortField_ShortRatio = 4; // Short selling ratio
ShortSellingSortField_Volume = 5; // Volume
ShortSellingSortField_PositionVolume = 6; // Short position quantity
ShortSellingSortField_PositionRatio = 7; // Short position ratio
ShortSellingSortField_DaysToCover = 8; // Days to cover
ShortSellingSortField_WeekAvgVolume = 9; // Weekly avg daily volume
ShortSellingSortField_WeekAvgShortNumber = 10; // Weekly avg daily short selling quantity
ShortSellingSortField_WeekAvgShortRatio = 11; // Weekly avg daily short selling ratio
ShortSellingSortField_MonthAvgVolume = 12; // Monthly avg daily volume
ShortSellingSortField_MonthAvgShortNumber = 13; // Monthly avg daily short selling quantity
ShortSellingSortField_MonthAvgShortRatio = 14; // Monthly avg daily short selling ratio
}
message C2S {
optional int32 market = 1; // Qot_Common.QotMarket, market (HK=1, US=11), default US
optional int32 sortField = 2; // ShortSellingSortField, sort field, default short selling change volume
optional int32 sortDir = 3; // SortDir, sort direction, default descending
optional int32 offset = 4; // Start position, default 0
optional int32 count = 5; // Return count [1,35], default 10
repeated Qot_Common.Security plateList = 6; // Industry plate list, empty=all
}
// Short selling anomaly data item
message ShortSellingRankItem {
required Qot_Common.Security security = 1; // Stock
optional string name = 2; // Name
optional double closePrice = 10; // Close price
optional double changeRatio = 11; // Change(%)
optional double changeRatio5D = 12; // 5-day change(%)
optional double changeRatio10D = 13; // 10-day change(%)
optional int64 volume = 14; // Volume
optional int64 shortNumber = 20; // Short selling quantity
optional int64 shortNumberChange = 21; // Short selling change volume
optional double shortRatio = 22; // Short selling ratio(%)
optional double shortRatioChange = 23; // Short selling change ratio(%)
optional int64 shortPositionVolume = 24; // Short position quantity
optional double shortPositionRatio = 25; // Short position ratio(%)
optional double daysToCover = 26; // Days to cover
optional int64 weekAvgShortNumber = 27; // Weekly avg daily short selling
optional double weekAvgShortRatio = 28; // Weekly avg daily short selling ratio(%)
optional int64 monthAvgShortNumber = 29; // Monthly avg daily short selling
optional double monthAvgShortRatio = 30; // Monthly avg daily short selling ratio(%)
}
message S2C {
repeated ShortSellingRankItem dataList = 1; // Data list
optional int32 allCount = 2; // Total matching data count
}
message Request {
required C2S c2s = 1;
}
message Response {
required int32 retType = 1 [default = -400]; // RetType, return result
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
- For interface result, refer to RetType
Protocol ID
3415
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_GetShortSellingRank::Request req;
Qot_GetShortSellingRank::C2S *c2s = req.mutable_c2s();
c2s->set_market(Qot_Common::QotMarket::QotMarket_US_Security);
c2s->set_count(50);
m_GetShortSellingRankSerialNo = m_pQotApi->GetShortSellingRank(req);
}
virtual void OnReply_GetShortSellingRank(moomoo::u32_t nSerialNo, const Qot_GetShortSellingRank::Response &stRsp) {
if (nSerialNo != m_GetShortSellingRankSerialNo) return;
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
MMAPI_Qot *m_pQotApi;
moomoo::u32_t m_GetShortSellingRankSerialNo = 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
- Output
{
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"dataList": [
{
"security": {
"market": 11,
"code": "GME"
},
"name": "GameStop",
"closePrice": 25.5,
"changeRatio": 5.2,
"volume": 85000000,
"shortNumber": 45000000
}
],
"allCount": 50
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
getShortSellingRank(qotGetShortSellingRank)
Description
Get short selling anomaly rank, returns US/HK stock short selling data rankings, supporting 14 sorting dimensions and industry plate filtering, including short selling quantity, ratio, short position, days to cover and other data.
Parameters
// Sort direction
enum SortDir {
SortDir_Descending = 0; // Descending (default)
SortDir_Ascending = 1; // Ascending
}
// Sort field
enum ShortSellingSortField {
ShortSellingSortField_Unknown = 0; // Default (short selling change volume)
ShortSellingSortField_ShortNumberChange = 1; // Short selling change volume
ShortSellingSortField_ShortRatioChange = 2; // Short selling change ratio
ShortSellingSortField_ShortNumber = 3; // Short selling quantity
ShortSellingSortField_ShortRatio = 4; // Short selling ratio
ShortSellingSortField_Volume = 5; // Volume
ShortSellingSortField_PositionVolume = 6; // Short position quantity
ShortSellingSortField_PositionRatio = 7; // Short position ratio
ShortSellingSortField_DaysToCover = 8; // Days to cover
ShortSellingSortField_WeekAvgVolume = 9; // Weekly avg daily volume
ShortSellingSortField_WeekAvgShortNumber = 10; // Weekly avg daily short selling quantity
ShortSellingSortField_WeekAvgShortRatio = 11; // Weekly avg daily short selling ratio
ShortSellingSortField_MonthAvgVolume = 12; // Monthly avg daily volume
ShortSellingSortField_MonthAvgShortNumber = 13; // Monthly avg daily short selling quantity
ShortSellingSortField_MonthAvgShortRatio = 14; // Monthly avg daily short selling ratio
}
message C2S {
optional int32 market = 1; // Qot_Common.QotMarket, market (HK=1, US=11), default US
optional int32 sortField = 2; // ShortSellingSortField, sort field, default short selling change volume
optional int32 sortDir = 3; // SortDir, sort direction, default descending
optional int32 offset = 4; // Start position, default 0
optional int32 count = 5; // Return count [1,35], default 10
repeated Qot_Common.Security plateList = 6; // Industry plate list, empty=all
}
// Short selling anomaly data item
message ShortSellingRankItem {
required Qot_Common.Security security = 1; // Stock
optional string name = 2; // Name
optional double closePrice = 10; // Close price
optional double changeRatio = 11; // Change(%)
optional double changeRatio5D = 12; // 5-day change(%)
optional double changeRatio10D = 13; // 10-day change(%)
optional int64 volume = 14; // Volume
optional int64 shortNumber = 20; // Short selling quantity
optional int64 shortNumberChange = 21; // Short selling change volume
optional double shortRatio = 22; // Short selling ratio(%)
optional double shortRatioChange = 23; // Short selling change ratio(%)
optional int64 shortPositionVolume = 24; // Short position quantity
optional double shortPositionRatio = 25; // Short position ratio(%)
optional double daysToCover = 26; // Days to cover
optional int64 weekAvgShortNumber = 27; // Weekly avg daily short selling
optional double weekAvgShortRatio = 28; // Weekly avg daily short selling ratio(%)
optional int64 monthAvgShortNumber = 29; // Monthly avg daily short selling
optional double monthAvgShortRatio = 30; // Monthly avg daily short selling ratio(%)
}
message S2C {
repeated ShortSellingRankItem dataList = 1; // Data list
optional int32 allCount = 2; // Total matching data count
}
message Request {
required C2S c2s = 1;
}
message Response {
required int32 retType = 1 [default = -400]; // RetType, return result
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
- For interface result, refer to RetType
Protocol ID
3415
Example
import mmWebsocket from "moomoo-api";
import { Common, Qot_Common } from "moomoo-api/proto";
import beautify from "js-beautify";
function QotGetShortSellingRank(){
const { RetType } = Common
let [addr, port, enable_ssl, key] = ["127.0.0.1", 11111, false, "xxxxxx"];
let websocket = new mmWebsocket();
websocket.onlogin = (ret, msg)=>{
if (ret) {
const req = {
c2s: { market: 11, count: 3 },
};
websocket.GetShortSellingRank(req)
.then((res)=>{
let { errCode, retMsg, retType, s2c } = res
console.log("GetShortSellingRank: 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);
}
QotGetShortSellingRank()
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
GetShortSellingRank: errCode 0, retMsg , retType 0
{
"allCount": 3,
"dataList": [
{ "security": { "market": 11, "code": "ADTX" }, "name": "Aditxt", "shortRatio": 5.42, "shortRatioChange": 62.78 },
{ "security": { "market": 11, "code": "CDE" }, "name": "科尔黛伦矿业", "shortRatio": 39.44, "shortRatioChange": 779.14 },
{ "security": { "market": 11, "code": "PFE" }, "name": "辉瑞", "shortRatio": 31.48, "shortRatioChange": 466.48 }
]
}
2
3
4
5
6
7
8
9
API Limits
- Maximum 60 requests within 30 seconds
- Only the first page of paginated requests counts toward rate limiting