# Get US Pre-Market Rank
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_us_pre_market_rank(sort_dir=None, count=10, offset=None, filter_list=None)
Description
Get US pre-market rank, returning pre-market trading session change rate rankings, including pre-market price, change rate, turnover, volume, and other data.
Parameters
Parameter Type Description sort_dir RankSortDir Sort direction, default descending (top gainers) count int Return count [1, 200], default 10 offset int Start position, default 0 filter_list list[ SimpleRankFilter]Filter condition list (multiple conditions are AND-combined) Input Limits
filter_listFilter Conditions(SimpleRankFilter):Construct filter conditions via
SimpleRankFilter:Constructor Parameter Description indicator_typeFilter indicator type ( SimpleRankIndicatorType, required)interval_minRange minimum (closed interval, for MARKET_CAP/PE) interval_maxRange maximum (closed interval, for MARKET_CAP/PE) price_filterPrice filter enum ( PriceFilter, required for PRICE type)
Return
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.AAPL')name str Stock name pre_market_price float Pre-market price pre_market_change_ratio float Pre-market change rate (%) pre_market_change_amount float Pre-market change amount pre_market_turnover float Pre-market turnover pre_market_volume int Pre-market volume close_price float Close price (previous trading day) change_ratio float Intraday change rate (%) change_amount float Intraday change amount
- Data format:
Example
from futu import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data = quote_ctx.get_us_pre_market_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
Total count: 17728
security name pre_market_price pre_market_change_ratio pre_market_change_amount pre_market_turnover pre_market_volume close_price change_ratio change_amount
0 US.ATLN Atlantic International 1.18 168.303 0.74 1.219515e+08 136776297 1.33 202.961276 0.891
1 US.BOLD Boundless Bio 2.40 71.428 1.00 6.180064e+07 25082585 2.60 85.714286 1.200
2
3
4
# Qot_GetUSPreMarketRank.proto
Description
Get US pre-market rank, returns price change rankings during pre-market trading session, including pre-market price, price change, turnover, volume and other data.
Parameters
// Sort direction
enum SortDir {
SortDir_Descending = 0; // Descending (top gainers, default)
SortDir_Ascending = 1; // Ascending (top losers)
}
// Filter condition type
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_Price = 1; // Price filter (enum, see PriceFilter)
IndicatorType_MarketCap = 2; // Market cap range
IndicatorType_PE = 3; // P/E ratio range
}
// Price filter enum
enum PriceFilter {
PriceFilter_All = 0; // All (default)
PriceFilter_LessThan1 = 1; // Less than 1
PriceFilter_Between1And10 = 2; // Between 1~10
PriceFilter_Between10And100 = 3; // Between 10~100
PriceFilter_GreaterThan100 = 4; // Greater than 100
PriceFilter_Near52WeekHigh = 5; // Near 52-week high
PriceFilter_Near52WeekLow = 6; // Near 52-week low
}
// Filter conditions
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.Interval indicatorValue = 2; // Filter range (for MarketCap/PE)
optional int32 priceFilter = 3; // PriceFilter, price filter enum (used for IndicatorType_Price)
}
message C2S {
optional int32 sortDir = 1; // SortDir, sort direction, default descending (top gainers)
optional int32 offset = 2; // Start position, default 0
optional int32 count = 3; // Return count [1,200], default 50
repeated Indicator filterList = 4; // Filter conditions (AND relationship)
}
// Pre-market ranking data item
message PreMarketRankItem {
required Qot_Common.Security security = 1; // Stock
optional string name = 2; // Name
optional double preMarketPrice = 10; // Pre-market price
optional double preMarketChangeRatio = 11; // Pre-market change(%)
optional double preMarketChangeAmount = 12; // Pre-market price change amount
optional double preMarketTurnover = 13; // Pre-market turnover
optional int64 preMarketVolume = 14; // Pre-market volume
optional double closePrice = 15; // Close price (previous trading day)
optional double changeRatio = 16; // Intraday change(%)
optional double changeAmount = 17; // Intraday price change amount
}
message S2C {
repeated PreMarketRankItem 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
Protocol ID
3410
uint GetUSPreMarketRank(Qot_GetUSPreMarketRank.Request req);
virtual void OnReply_GetUSPreMarketRank(FTAPI_Conn client, uint nSerialNo, Qot_GetUSPreMarketRank.Response rsp);
Description
Get US pre-market rank, returns price change rankings during pre-market trading session, including pre-market price, price change, turnover, volume and other data.
Parameters
// Sort direction
enum SortDir {
SortDir_Descending = 0; // Descending (top gainers, default)
SortDir_Ascending = 1; // Ascending (top losers)
}
// Filter condition type
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_Price = 1; // Price filter (enum, see PriceFilter)
IndicatorType_MarketCap = 2; // Market cap range
IndicatorType_PE = 3; // P/E ratio range
}
// Price filter enum
enum PriceFilter {
PriceFilter_All = 0; // All (default)
PriceFilter_LessThan1 = 1; // Less than 1
PriceFilter_Between1And10 = 2; // Between 1~10
PriceFilter_Between10And100 = 3; // Between 10~100
PriceFilter_GreaterThan100 = 4; // Greater than 100
PriceFilter_Near52WeekHigh = 5; // Near 52-week high
PriceFilter_Near52WeekLow = 6; // Near 52-week low
}
// Filter conditions
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.Interval indicatorValue = 2; // Filter range (for MarketCap/PE)
optional int32 priceFilter = 3; // PriceFilter, price filter enum (used for IndicatorType_Price)
}
message C2S {
optional int32 sortDir = 1; // SortDir, sort direction, default descending (top gainers)
optional int32 offset = 2; // Start position, default 0
optional int32 count = 3; // Return count [1,200], default 50
repeated Indicator filterList = 4; // Filter conditions (AND relationship)
}
// Pre-market ranking data item
message PreMarketRankItem {
required Qot_Common.Security security = 1; // Stock
optional string name = 2; // Name
optional double preMarketPrice = 10; // Pre-market price
optional double preMarketChangeRatio = 11; // Pre-market change(%)
optional double preMarketChangeAmount = 12; // Pre-market price change amount
optional double preMarketTurnover = 13; // Pre-market turnover
optional int64 preMarketVolume = 14; // Pre-market volume
optional double closePrice = 15; // Close price (previous trading day)
optional double changeRatio = 16; // Intraday change(%)
optional double changeAmount = 17; // Intraday price change amount
}
message S2C {
repeated PreMarketRankItem 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
- For interface result, refer to RetType
Protocol ID
3410
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;
QotGetUSPreMarketRank.C2S c2s = QotGetUSPreMarketRank.C2S.CreateBuilder()
.SetCount(3)
.Build();
QotGetUSPreMarketRank.Request req = QotGetUSPreMarketRank.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetUSPreMarketRank(req);
Console.Write("Send QotGetUSPreMarketRank: {0}
", seqNo);
}
public void OnDisconnect(FTAPI_Conn client, long errCode) {
Console.Write("Qot onDisConnect: {0}
", errCode);
}
public void OnReply_GetUSPreMarketRank(FTAPI_Conn client, uint nSerialNo, QotGetUSPreMarketRank.Response rsp)
{
Console.Write("Reply: QotGetUSPreMarketRank: {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 QotGetUSPreMarketRank: 3
Reply: QotGetUSPreMarketRank: 3
GetUSPreMarketRank: errCode 0, retMsg , retType 0
{
"allCount": 17711,
"dataList": [
{ "security": { "market": 11, "code": "GETY" }, "name": "Getty Images", "preMarketPrice": 1.639, "preMarketChangeRatio": 170.996 },
{ "security": { "market": 11, "code": "ADTX" }, "name": "Aditxt", "preMarketPrice": 0.020, "preMarketChangeRatio": 109.000 },
{ "security": { "market": 11, "code": "EHGO" }, "name": "君长数码", "preMarketPrice": 3.270, "preMarketChangeRatio": 81.672 }
]
}
2
3
4
5
6
7
8
9
10
11
int getUSPreMarketRank(Qot_GetUSPreMarketRank.Request req);
onReply_GetUSPreMarketRank(FTAPI_Conn client, int nSerialNo, Qot_GetUSPreMarketRank.Response rsp)
Description
Get US pre-market rank, returns price change rankings during pre-market trading session, including pre-market price, price change, turnover, volume and other data.
Parameters
// Sort direction
enum SortDir {
SortDir_Descending = 0; // Descending (top gainers, default)
SortDir_Ascending = 1; // Ascending (top losers)
}
// Filter condition type
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_Price = 1; // Price filter (enum, see PriceFilter)
IndicatorType_MarketCap = 2; // Market cap range
IndicatorType_PE = 3; // P/E ratio range
}
// Price filter enum
enum PriceFilter {
PriceFilter_All = 0; // All (default)
PriceFilter_LessThan1 = 1; // Less than 1
PriceFilter_Between1And10 = 2; // Between 1~10
PriceFilter_Between10And100 = 3; // Between 10~100
PriceFilter_GreaterThan100 = 4; // Greater than 100
PriceFilter_Near52WeekHigh = 5; // Near 52-week high
PriceFilter_Near52WeekLow = 6; // Near 52-week low
}
// Filter conditions
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.Interval indicatorValue = 2; // Filter range (for MarketCap/PE)
optional int32 priceFilter = 3; // PriceFilter, price filter enum (used for IndicatorType_Price)
}
message C2S {
optional int32 sortDir = 1; // SortDir, sort direction, default descending (top gainers)
optional int32 offset = 2; // Start position, default 0
optional int32 count = 3; // Return count [1,200], default 50
repeated Indicator filterList = 4; // Filter conditions (AND relationship)
}
// Pre-market ranking data item
message PreMarketRankItem {
required Qot_Common.Security security = 1; // Stock
optional string name = 2; // Name
optional double preMarketPrice = 10; // Pre-market price
optional double preMarketChangeRatio = 11; // Pre-market change(%)
optional double preMarketChangeAmount = 12; // Pre-market price change amount
optional double preMarketTurnover = 13; // Pre-market turnover
optional int64 preMarketVolume = 14; // Pre-market volume
optional double closePrice = 15; // Close price (previous trading day)
optional double changeRatio = 16; // Intraday change(%)
optional double changeAmount = 17; // Intraday price change amount
}
message S2C {
repeated PreMarketRankItem 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
- For interface result, refer to RetType
Protocol ID
3410
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;
QotGetUSPreMarketRank.C2S c2s = QotGetUSPreMarketRank.C2S.newBuilder()
.setCount(3)
.build();
QotGetUSPreMarketRank.Request req = QotGetUSPreMarketRank.Request.newBuilder().setC2S(c2s).build();
int seqNo = qot.getUSPreMarketRank(req);
System.out.printf("Send QotGetUSPreMarketRank: %d
", seqNo);
}
@Override
public void onDisconnect(FTAPI_Conn client, long errCode) {
System.out.printf("Qot onDisConnect: %d
", errCode);
}
@Override
public void onReply_GetUSPreMarketRank(FTAPI_Conn client, int nSerialNo, QotGetUSPreMarketRank.Response rsp) {
if (rsp.getRetType() != 0) {
System.out.printf("QotGetUSPreMarketRank failed: %s
", rsp.getRetMsg());
} else {
try {
String json = JsonFormat.printer().print(rsp);
System.out.printf("Receive QotGetUSPreMarketRank: %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 QotGetUSPreMarketRank: 3
Receive QotGetUSPreMarketRank: {
"allCount": 17711,
"dataList": [
{ "security": { "market": 11, "code": "GETY" }, "name": "Getty Images", "preMarketPrice": 1.639, "preMarketChangeRatio": 170.996 },
{ "security": { "market": 11, "code": "ADTX" }, "name": "Aditxt", "preMarketPrice": 0.020, "preMarketChangeRatio": 109.000 },
{ "security": { "market": 11, "code": "EHGO" }, "name": "君长数码", "preMarketPrice": 3.270, "preMarketChangeRatio": 81.672 }
]
}
2
3
4
5
6
7
8
9
Futu::u32_t GetUSPreMarketRank(const Qot_GetUSPreMarketRank::Request &stReq);
virtual void OnReply_GetUSPreMarketRank(Futu::u32_t nSerialNo, const Qot_GetUSPreMarketRank::Response &stRsp) = 0;
Description
Protocol request and response definition
Parameters
// Sort direction
enum SortDir {
SortDir_Descending = 0; // Descending (top gainers, default)
SortDir_Ascending = 1; // Ascending (top losers)
}
// Filter condition type
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_Price = 1; // Price filter (enum, see PriceFilter)
IndicatorType_MarketCap = 2; // Market cap range
IndicatorType_PE = 3; // P/E ratio range
}
// Price filter enum
enum PriceFilter {
PriceFilter_All = 0; // All (default)
PriceFilter_LessThan1 = 1; // Less than 1
PriceFilter_Between1And10 = 2; // Between 1~10
PriceFilter_Between10And100 = 3; // Between 10~100
PriceFilter_GreaterThan100 = 4; // Greater than 100
PriceFilter_Near52WeekHigh = 5; // Near 52-week high
PriceFilter_Near52WeekLow = 6; // Near 52-week low
}
// Filter conditions
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.Interval indicatorValue = 2; // Filter range (for MarketCap/PE)
optional int32 priceFilter = 3; // PriceFilter, price filter enum (used for IndicatorType_Price)
}
message C2S {
optional int32 sortDir = 1; // SortDir, sort direction, default descending (top gainers)
optional int32 offset = 2; // Start position, default 0
optional int32 count = 3; // Return count [1,200], default 50
repeated Indicator filterList = 4; // Filter conditions (AND relationship)
}
// Pre-market ranking data item
message PreMarketRankItem {
required Qot_Common.Security security = 1; // Stock
optional string name = 2; // Name
optional double preMarketPrice = 10; // Pre-market price
optional double preMarketChangeRatio = 11; // Pre-market change(%)
optional double preMarketChangeAmount = 12; // Pre-market price change amount
optional double preMarketTurnover = 13; // Pre-market turnover
optional int64 preMarketVolume = 14; // Pre-market volume
optional double closePrice = 15; // Close price (previous trading day)
optional double changeRatio = 16; // Intraday change(%)
optional double changeAmount = 17; // Intraday price change amount
}
message S2C {
repeated PreMarketRankItem 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
- For interface result, refer to RetType
Protocol ID
3410
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_GetUSPreMarketRank::Request req;
Qot_GetUSPreMarketRank::C2S *c2s = req.mutable_c2s();
c2s->set_count(50);
m_GetUSPreMarketRankSerialNo = m_pQotApi->GetUSPreMarketRank(req);
}
virtual void OnReply_GetUSPreMarketRank(Futu::u32_t nSerialNo, const Qot_GetUSPreMarketRank::Response &stRsp) {
if (nSerialNo != m_GetUSPreMarketRankSerialNo) return;
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
FTAPI_Qot *m_pQotApi;
Futu::u32_t m_GetUSPreMarketRankSerialNo = 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": 11,
"code": "NVDA"
},
"name": "NVIDIA",
"preMarketPrice": 892.0,
"preMarketChangeRatio": 1.9,
"preMarketChangeAmount": 16.6,
"closePrice": 875.4
}
],
"allCount": 50
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
getUSPreMarketRank(qotGetUSPreMarketRank)
Description
Get US pre-market rank, returns price change rankings during pre-market trading session, including pre-market price, price change, turnover, volume and other data.
Parameters
// Sort direction
enum SortDir {
SortDir_Descending = 0; // Descending (top gainers, default)
SortDir_Ascending = 1; // Ascending (top losers)
}
// Filter condition type
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_Price = 1; // Price filter (enum, see PriceFilter)
IndicatorType_MarketCap = 2; // Market cap range
IndicatorType_PE = 3; // P/E ratio range
}
// Price filter enum
enum PriceFilter {
PriceFilter_All = 0; // All (default)
PriceFilter_LessThan1 = 1; // Less than 1
PriceFilter_Between1And10 = 2; // Between 1~10
PriceFilter_Between10And100 = 3; // Between 10~100
PriceFilter_GreaterThan100 = 4; // Greater than 100
PriceFilter_Near52WeekHigh = 5; // Near 52-week high
PriceFilter_Near52WeekLow = 6; // Near 52-week low
}
// Filter conditions
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.Interval indicatorValue = 2; // Filter range (for MarketCap/PE)
optional int32 priceFilter = 3; // PriceFilter, price filter enum (used for IndicatorType_Price)
}
message C2S {
optional int32 sortDir = 1; // SortDir, sort direction, default descending (top gainers)
optional int32 offset = 2; // Start position, default 0
optional int32 count = 3; // Return count [1,200], default 50
repeated Indicator filterList = 4; // Filter conditions (AND relationship)
}
// Pre-market ranking data item
message PreMarketRankItem {
required Qot_Common.Security security = 1; // Stock
optional string name = 2; // Name
optional double preMarketPrice = 10; // Pre-market price
optional double preMarketChangeRatio = 11; // Pre-market change(%)
optional double preMarketChangeAmount = 12; // Pre-market price change amount
optional double preMarketTurnover = 13; // Pre-market turnover
optional int64 preMarketVolume = 14; // Pre-market volume
optional double closePrice = 15; // Close price (previous trading day)
optional double changeRatio = 16; // Intraday change(%)
optional double changeAmount = 17; // Intraday price change amount
}
message S2C {
repeated PreMarketRankItem 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
- For interface result, refer to RetType
Protocol ID
3410
Example
import ftWebsocket from "futu-api";
import { Common, Qot_Common } from "futu-api/proto";
import beautify from "js-beautify";
function QotGetUSPreMarketRank(){
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.GetUSPreMarketRank(req)
.then((res)=>{
let { errCode, retMsg, retType, s2c } = res
console.log("GetUSPreMarketRank: 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);
}
QotGetUSPreMarketRank()
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
GetUSPreMarketRank: errCode 0, retMsg , retType 0
{
"allCount": 17711,
"dataList": [
{ "security": { "market": 11, "code": "GETY" }, "name": "Getty Images", "preMarketPrice": 1.639, "preMarketChangeRatio": 170.996 },
{ "security": { "market": 11, "code": "ADTX" }, "name": "Aditxt", "preMarketPrice": 0.020, "preMarketChangeRatio": 109.000 },
{ "security": { "market": 11, "code": "EHGO" }, "name": "君长数码", "preMarketPrice": 3.270, "preMarketChangeRatio": 81.672 }
]
}
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_us_pre_market_rank(sort_dir=None, count=10, offset=None, filter_list=None)
Description
Get US pre-market rank, returning pre-market trading session change rate rankings, including pre-market price, change rate, turnover, volume, and other data.
Parameters
Parameter Type Description sort_dir RankSortDir Sort direction, default descending (top gainers) count int Return count [1, 200], default 10 offset int Start position, default 0 filter_list list[ SimpleRankFilter]Filter condition list (multiple conditions are AND-combined) Input Limits
filter_listFilter Conditions(SimpleRankFilter):Construct filter conditions via
SimpleRankFilter:Constructor Parameter Description indicator_typeFilter indicator type ( SimpleRankIndicatorType, required)interval_minRange minimum (closed interval, for MARKET_CAP/PE) interval_maxRange maximum (closed interval, for MARKET_CAP/PE) price_filterPrice filter enum ( PriceFilter, required for PRICE type)
Return
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.AAPL')name str Stock name pre_market_price float Pre-market price pre_market_change_ratio float Pre-market change rate (%) pre_market_change_amount float Pre-market change amount pre_market_turnover float Pre-market turnover pre_market_volume int Pre-market volume close_price float Close price (previous trading day) change_ratio float Intraday change rate (%) change_amount float Intraday change amount
- Data format:
Example
from futu import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data = quote_ctx.get_us_pre_market_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
Total count: 17728
security name pre_market_price pre_market_change_ratio pre_market_change_amount pre_market_turnover pre_market_volume close_price change_ratio change_amount
0 US.ATLN Atlantic International 1.18 168.303 0.74 1.219515e+08 136776297 1.33 202.961276 0.891
1 US.BOLD Boundless Bio 2.40 71.428 1.00 6.180064e+07 25082585 2.60 85.714286 1.200
2
3
4
# Qot_GetUSPreMarketRank.proto
Description
Get US pre-market rank, returns price change rankings during pre-market trading session, including pre-market price, price change, turnover, volume and other data.
Parameters
// Sort direction
enum SortDir {
SortDir_Descending = 0; // Descending (top gainers, default)
SortDir_Ascending = 1; // Ascending (top losers)
}
// Filter condition type
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_Price = 1; // Price filter (enum, see PriceFilter)
IndicatorType_MarketCap = 2; // Market cap range
IndicatorType_PE = 3; // P/E ratio range
}
// Price filter enum
enum PriceFilter {
PriceFilter_All = 0; // All (default)
PriceFilter_LessThan1 = 1; // Less than 1
PriceFilter_Between1And10 = 2; // Between 1~10
PriceFilter_Between10And100 = 3; // Between 10~100
PriceFilter_GreaterThan100 = 4; // Greater than 100
PriceFilter_Near52WeekHigh = 5; // Near 52-week high
PriceFilter_Near52WeekLow = 6; // Near 52-week low
}
// Filter conditions
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.Interval indicatorValue = 2; // Filter range (for MarketCap/PE)
optional int32 priceFilter = 3; // PriceFilter, price filter enum (used for IndicatorType_Price)
}
message C2S {
optional int32 sortDir = 1; // SortDir, sort direction, default descending (top gainers)
optional int32 offset = 2; // Start position, default 0
optional int32 count = 3; // Return count [1,200], default 50
repeated Indicator filterList = 4; // Filter conditions (AND relationship)
}
// Pre-market ranking data item
message PreMarketRankItem {
required Qot_Common.Security security = 1; // Stock
optional string name = 2; // Name
optional double preMarketPrice = 10; // Pre-market price
optional double preMarketChangeRatio = 11; // Pre-market change(%)
optional double preMarketChangeAmount = 12; // Pre-market price change amount
optional double preMarketTurnover = 13; // Pre-market turnover
optional int64 preMarketVolume = 14; // Pre-market volume
optional double closePrice = 15; // Close price (previous trading day)
optional double changeRatio = 16; // Intraday change(%)
optional double changeAmount = 17; // Intraday price change amount
}
message S2C {
repeated PreMarketRankItem 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
Protocol ID
3410
uint GetUSPreMarketRank(Qot_GetUSPreMarketRank.Request req);
virtual void OnReply_GetUSPreMarketRank(FTAPI_Conn client, uint nSerialNo, Qot_GetUSPreMarketRank.Response rsp);
Description
Get US pre-market rank, returns price change rankings during pre-market trading session, including pre-market price, price change, turnover, volume and other data.
Parameters
// Sort direction
enum SortDir {
SortDir_Descending = 0; // Descending (top gainers, default)
SortDir_Ascending = 1; // Ascending (top losers)
}
// Filter condition type
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_Price = 1; // Price filter (enum, see PriceFilter)
IndicatorType_MarketCap = 2; // Market cap range
IndicatorType_PE = 3; // P/E ratio range
}
// Price filter enum
enum PriceFilter {
PriceFilter_All = 0; // All (default)
PriceFilter_LessThan1 = 1; // Less than 1
PriceFilter_Between1And10 = 2; // Between 1~10
PriceFilter_Between10And100 = 3; // Between 10~100
PriceFilter_GreaterThan100 = 4; // Greater than 100
PriceFilter_Near52WeekHigh = 5; // Near 52-week high
PriceFilter_Near52WeekLow = 6; // Near 52-week low
}
// Filter conditions
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.Interval indicatorValue = 2; // Filter range (for MarketCap/PE)
optional int32 priceFilter = 3; // PriceFilter, price filter enum (used for IndicatorType_Price)
}
message C2S {
optional int32 sortDir = 1; // SortDir, sort direction, default descending (top gainers)
optional int32 offset = 2; // Start position, default 0
optional int32 count = 3; // Return count [1,200], default 50
repeated Indicator filterList = 4; // Filter conditions (AND relationship)
}
// Pre-market ranking data item
message PreMarketRankItem {
required Qot_Common.Security security = 1; // Stock
optional string name = 2; // Name
optional double preMarketPrice = 10; // Pre-market price
optional double preMarketChangeRatio = 11; // Pre-market change(%)
optional double preMarketChangeAmount = 12; // Pre-market price change amount
optional double preMarketTurnover = 13; // Pre-market turnover
optional int64 preMarketVolume = 14; // Pre-market volume
optional double closePrice = 15; // Close price (previous trading day)
optional double changeRatio = 16; // Intraday change(%)
optional double changeAmount = 17; // Intraday price change amount
}
message S2C {
repeated PreMarketRankItem 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
- For interface result, refer to RetType
Protocol ID
3410
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;
QotGetUSPreMarketRank.C2S c2s = QotGetUSPreMarketRank.C2S.CreateBuilder()
.SetCount(3)
.Build();
QotGetUSPreMarketRank.Request req = QotGetUSPreMarketRank.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetUSPreMarketRank(req);
Console.Write("Send QotGetUSPreMarketRank: {0}
", seqNo);
}
public void OnDisconnect(MMAPI_Conn client, long errCode) {
Console.Write("Qot onDisConnect: {0}
", errCode);
}
public void OnReply_GetUSPreMarketRank(MMAPI_Conn client, uint nSerialNo, QotGetUSPreMarketRank.Response rsp)
{
Console.Write("Reply: QotGetUSPreMarketRank: {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 QotGetUSPreMarketRank: 3
Reply: QotGetUSPreMarketRank: 3
GetUSPreMarketRank: errCode 0, retMsg , retType 0
{
"allCount": 17711,
"dataList": [
{ "security": { "market": 11, "code": "GETY" }, "name": "Getty Images", "preMarketPrice": 1.639, "preMarketChangeRatio": 170.996 },
{ "security": { "market": 11, "code": "ADTX" }, "name": "Aditxt", "preMarketPrice": 0.020, "preMarketChangeRatio": 109.000 },
{ "security": { "market": 11, "code": "EHGO" }, "name": "君长数码", "preMarketPrice": 3.270, "preMarketChangeRatio": 81.672 }
]
}
2
3
4
5
6
7
8
9
10
11
int getUSPreMarketRank(Qot_GetUSPreMarketRank.Request req);
onReply_GetUSPreMarketRank(FTAPI_Conn client, int nSerialNo, Qot_GetUSPreMarketRank.Response rsp)
Description
Get US pre-market rank, returns price change rankings during pre-market trading session, including pre-market price, price change, turnover, volume and other data.
Parameters
// Sort direction
enum SortDir {
SortDir_Descending = 0; // Descending (top gainers, default)
SortDir_Ascending = 1; // Ascending (top losers)
}
// Filter condition type
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_Price = 1; // Price filter (enum, see PriceFilter)
IndicatorType_MarketCap = 2; // Market cap range
IndicatorType_PE = 3; // P/E ratio range
}
// Price filter enum
enum PriceFilter {
PriceFilter_All = 0; // All (default)
PriceFilter_LessThan1 = 1; // Less than 1
PriceFilter_Between1And10 = 2; // Between 1~10
PriceFilter_Between10And100 = 3; // Between 10~100
PriceFilter_GreaterThan100 = 4; // Greater than 100
PriceFilter_Near52WeekHigh = 5; // Near 52-week high
PriceFilter_Near52WeekLow = 6; // Near 52-week low
}
// Filter conditions
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.Interval indicatorValue = 2; // Filter range (for MarketCap/PE)
optional int32 priceFilter = 3; // PriceFilter, price filter enum (used for IndicatorType_Price)
}
message C2S {
optional int32 sortDir = 1; // SortDir, sort direction, default descending (top gainers)
optional int32 offset = 2; // Start position, default 0
optional int32 count = 3; // Return count [1,200], default 50
repeated Indicator filterList = 4; // Filter conditions (AND relationship)
}
// Pre-market ranking data item
message PreMarketRankItem {
required Qot_Common.Security security = 1; // Stock
optional string name = 2; // Name
optional double preMarketPrice = 10; // Pre-market price
optional double preMarketChangeRatio = 11; // Pre-market change(%)
optional double preMarketChangeAmount = 12; // Pre-market price change amount
optional double preMarketTurnover = 13; // Pre-market turnover
optional int64 preMarketVolume = 14; // Pre-market volume
optional double closePrice = 15; // Close price (previous trading day)
optional double changeRatio = 16; // Intraday change(%)
optional double changeAmount = 17; // Intraday price change amount
}
message S2C {
repeated PreMarketRankItem 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
- For interface result, refer to RetType
Protocol ID
3410
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;
QotGetUSPreMarketRank.C2S c2s = QotGetUSPreMarketRank.C2S.newBuilder()
.setCount(3)
.build();
QotGetUSPreMarketRank.Request req = QotGetUSPreMarketRank.Request.newBuilder().setC2S(c2s).build();
int seqNo = qot.getUSPreMarketRank(req);
System.out.printf("Send QotGetUSPreMarketRank: %d
", seqNo);
}
@Override
public void onDisconnect(MMAPI_Conn client, long errCode) {
System.out.printf("Qot onDisConnect: %d
", errCode);
}
@Override
public void onReply_GetUSPreMarketRank(MMAPI_Conn client, int nSerialNo, QotGetUSPreMarketRank.Response rsp) {
if (rsp.getRetType() != 0) {
System.out.printf("QotGetUSPreMarketRank failed: %s
", rsp.getRetMsg());
} else {
try {
String json = JsonFormat.printer().print(rsp);
System.out.printf("Receive QotGetUSPreMarketRank: %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 QotGetUSPreMarketRank: 3
Receive QotGetUSPreMarketRank: {
"allCount": 17711,
"dataList": [
{ "security": { "market": 11, "code": "GETY" }, "name": "Getty Images", "preMarketPrice": 1.639, "preMarketChangeRatio": 170.996 },
{ "security": { "market": 11, "code": "ADTX" }, "name": "Aditxt", "preMarketPrice": 0.020, "preMarketChangeRatio": 109.000 },
{ "security": { "market": 11, "code": "EHGO" }, "name": "君长数码", "preMarketPrice": 3.270, "preMarketChangeRatio": 81.672 }
]
}
2
3
4
5
6
7
8
9
moomoo::u32_t GetUSPreMarketRank(const Qot_GetUSPreMarketRank::Request &stReq);
virtual void OnReply_GetUSPreMarketRank(moomoo::u32_t nSerialNo, const Qot_GetUSPreMarketRank::Response &stRsp) = 0;
Description
Protocol request and response definition
Parameters
// Sort direction
enum SortDir {
SortDir_Descending = 0; // Descending (top gainers, default)
SortDir_Ascending = 1; // Ascending (top losers)
}
// Filter condition type
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_Price = 1; // Price filter (enum, see PriceFilter)
IndicatorType_MarketCap = 2; // Market cap range
IndicatorType_PE = 3; // P/E ratio range
}
// Price filter enum
enum PriceFilter {
PriceFilter_All = 0; // All (default)
PriceFilter_LessThan1 = 1; // Less than 1
PriceFilter_Between1And10 = 2; // Between 1~10
PriceFilter_Between10And100 = 3; // Between 10~100
PriceFilter_GreaterThan100 = 4; // Greater than 100
PriceFilter_Near52WeekHigh = 5; // Near 52-week high
PriceFilter_Near52WeekLow = 6; // Near 52-week low
}
// Filter conditions
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.Interval indicatorValue = 2; // Filter range (for MarketCap/PE)
optional int32 priceFilter = 3; // PriceFilter, price filter enum (used for IndicatorType_Price)
}
message C2S {
optional int32 sortDir = 1; // SortDir, sort direction, default descending (top gainers)
optional int32 offset = 2; // Start position, default 0
optional int32 count = 3; // Return count [1,200], default 50
repeated Indicator filterList = 4; // Filter conditions (AND relationship)
}
// Pre-market ranking data item
message PreMarketRankItem {
required Qot_Common.Security security = 1; // Stock
optional string name = 2; // Name
optional double preMarketPrice = 10; // Pre-market price
optional double preMarketChangeRatio = 11; // Pre-market change(%)
optional double preMarketChangeAmount = 12; // Pre-market price change amount
optional double preMarketTurnover = 13; // Pre-market turnover
optional int64 preMarketVolume = 14; // Pre-market volume
optional double closePrice = 15; // Close price (previous trading day)
optional double changeRatio = 16; // Intraday change(%)
optional double changeAmount = 17; // Intraday price change amount
}
message S2C {
repeated PreMarketRankItem 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
- For interface result, refer to RetType
Protocol ID
3410
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_GetUSPreMarketRank::Request req;
Qot_GetUSPreMarketRank::C2S *c2s = req.mutable_c2s();
c2s->set_count(50);
m_GetUSPreMarketRankSerialNo = m_pQotApi->GetUSPreMarketRank(req);
}
virtual void OnReply_GetUSPreMarketRank(moomoo::u32_t nSerialNo, const Qot_GetUSPreMarketRank::Response &stRsp) {
if (nSerialNo != m_GetUSPreMarketRankSerialNo) return;
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
MMAPI_Qot *m_pQotApi;
moomoo::u32_t m_GetUSPreMarketRankSerialNo = 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": 11,
"code": "NVDA"
},
"name": "NVIDIA",
"preMarketPrice": 892.0,
"preMarketChangeRatio": 1.9,
"preMarketChangeAmount": 16.6,
"closePrice": 875.4
}
],
"allCount": 50
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
getUSPreMarketRank(qotGetUSPreMarketRank)
Description
Get US pre-market rank, returns price change rankings during pre-market trading session, including pre-market price, price change, turnover, volume and other data.
Parameters
// Sort direction
enum SortDir {
SortDir_Descending = 0; // Descending (top gainers, default)
SortDir_Ascending = 1; // Ascending (top losers)
}
// Filter condition type
enum IndicatorType {
IndicatorType_Unknown = 0;
IndicatorType_Price = 1; // Price filter (enum, see PriceFilter)
IndicatorType_MarketCap = 2; // Market cap range
IndicatorType_PE = 3; // P/E ratio range
}
// Price filter enum
enum PriceFilter {
PriceFilter_All = 0; // All (default)
PriceFilter_LessThan1 = 1; // Less than 1
PriceFilter_Between1And10 = 2; // Between 1~10
PriceFilter_Between10And100 = 3; // Between 10~100
PriceFilter_GreaterThan100 = 4; // Greater than 100
PriceFilter_Near52WeekHigh = 5; // Near 52-week high
PriceFilter_Near52WeekLow = 6; // Near 52-week low
}
// Filter conditions
message Indicator {
required int32 indicatorType = 1; // IndicatorType
optional Qot_OptionCommon.Interval indicatorValue = 2; // Filter range (for MarketCap/PE)
optional int32 priceFilter = 3; // PriceFilter, price filter enum (used for IndicatorType_Price)
}
message C2S {
optional int32 sortDir = 1; // SortDir, sort direction, default descending (top gainers)
optional int32 offset = 2; // Start position, default 0
optional int32 count = 3; // Return count [1,200], default 50
repeated Indicator filterList = 4; // Filter conditions (AND relationship)
}
// Pre-market ranking data item
message PreMarketRankItem {
required Qot_Common.Security security = 1; // Stock
optional string name = 2; // Name
optional double preMarketPrice = 10; // Pre-market price
optional double preMarketChangeRatio = 11; // Pre-market change(%)
optional double preMarketChangeAmount = 12; // Pre-market price change amount
optional double preMarketTurnover = 13; // Pre-market turnover
optional int64 preMarketVolume = 14; // Pre-market volume
optional double closePrice = 15; // Close price (previous trading day)
optional double changeRatio = 16; // Intraday change(%)
optional double changeAmount = 17; // Intraday price change amount
}
message S2C {
repeated PreMarketRankItem 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
- For interface result, refer to RetType
Protocol ID
3410
Example
import mmWebsocket from "moomoo-api";
import { Common, Qot_Common } from "moomoo-api/proto";
import beautify from "js-beautify";
function QotGetUSPreMarketRank(){
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.GetUSPreMarketRank(req)
.then((res)=>{
let { errCode, retMsg, retType, s2c } = res
console.log("GetUSPreMarketRank: 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);
}
QotGetUSPreMarketRank()
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
GetUSPreMarketRank: errCode 0, retMsg , retType 0
{
"allCount": 17711,
"dataList": [
{ "security": { "market": 11, "code": "GETY" }, "name": "Getty Images", "preMarketPrice": 1.639, "preMarketChangeRatio": 170.996 },
{ "security": { "market": 11, "code": "ADTX" }, "name": "Aditxt", "preMarketPrice": 0.020, "preMarketChangeRatio": 109.000 },
{ "security": { "market": 11, "code": "EHGO" }, "name": "君长数码", "preMarketPrice": 3.270, "preMarketChangeRatio": 81.672 }
]
}
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