# Get Top Ten Buy/Sell Brokers
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_top_ten_buy_sell_brokers(code, days_before=None)
Description
Get the top ten net buy and net sell broker lists for the specified HK stock (real-time or historical)
Parameters
Parameter Type Description code str Stock code HK stocks only (equities and funds), e.g. HK.00700days_before int Historical days Leave empty or 0 = real-time data (includes avg price / total volume / total turnover); >0 = historical data for the N-th previous trading day (net volume and broker name only)Return
Parameter Type Description ret RET_CODE API call result data pd.DataFrame When ret == RET_OK, returns broker data DataFrame str When ret != RET_OK, returns error description DataFrame fields:
Field Type Description is_real_time bool Whether real-time data true = real-time, false = historicaldata_time int Data update timestamp Unix timestamp in secondsdata_time_str str Data update time string Format YYYY-MM-DD HH:MM:SS, in the market's timezonenet_vol int Net buy/sell volume Positive for net buy, negative for net sellbroker_name str Broker display name Real-time uses broker profile data; historical uses the name from the responsebuy_sell_type BuySellType Buy/sell type avg_price float Average trade price Real-time data onlytotal_vol float Total trade volume Real-time data onlytotal_turnover float Total trade turnover Real-time data only
BuySellType Enum
Enum Name Value Description Unknown 0 Unknown NetBuy 1 Net buy NetSell 2 Net sell Example
from futu import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data = quote_ctx.get_top_ten_buy_sell_brokers("HK.00700")
if ret == RET_OK:
print(data)
else:
print('error:', data)
quote_ctx.close()
2
3
4
5
6
7
8
9
- Output
net_vol is_real_time buy_sell_type ... avg_price total_vol total_turnover
0 99200 True 1 ... 466.852156 398800.0 186180640.0
1 46500 True 1 ... 466.508972 61300.0 28597000.0
2 45400 True 1 ... 466.224332 67400.0 31423520.0
3 36000 True 1 ... 467.343428 240400.0 112349360.0
4 31300 True 1 ... 466.900580 155100.0 72416280.0
5 30000 True 1 ... 465.546667 30000.0 13966400.0
6 15000 True 1 ... 466.809333 15000.0 7002140.0
7 13700 True 1 ... 466.816577 55500.0 25908320.0
8 12300 True 1 ... 466.557724 12300.0 5738660.0
9 9200 True 1 ... 466.217391 9200.0 4289200.0
10 -373700 True 2 ... 467.064060 414300.0 193504640.0
11 -235100 True 2 ... 466.822072 502900.0 234764820.0
12 -168100 True 2 ... 466.281052 311900.0 145433060.0
13 -138300 True 2 ... 467.436639 547500.0 255921560.0
14 -89800 True 2 ... 466.722515 265600.0 123961500.0
15 -79400 True 2 ... 466.431910 79600.0 37127980.0
16 -69700 True 2 ... 466.950688 94500.0 44126840.0
17 -43600 True 2 ... 466.546230 61000.0 28459320.0
18 -25300 True 2 ... 466.652174 25300.0 11806300.0
19 -19500 True 2 ... 466.124484 33900.0 15801620.0
[20 rows x 9 columns]
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Qot_GetTopTenBuySellBrokers.proto
Description
Get Top Ten Buy/Sell Brokers
Parameters
message C2S
{
required Qot_Common.Security security = 1; // Stock
optional int32 daysBefore = 2; // Leave empty or 0 = real-time; N = historical data for the N-th previous trading day
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
- Security structure: refer to Security
- Return
message BrokerItem
{
optional int64 netVol = 1; // Net buy/sell volume
optional string brokerName = 2; // Broker display name (real-time uses broker profile; historical uses response name)
optional Qot_Common.BuySellType buySellType = 3; // Buy/sell type, see Qot_Common.BuySellType
optional double avgPrice = 4; // Average trade price (real-time data only)
optional double totalVol = 5; // Total trade volume (real-time data only)
optional double totalTurnover = 6; // Total trade turnover (real-time data only)
}
message S2C
{
optional bool isRealTime = 1; // true = real-time data, false = historical data
optional int64 dataTime = 2; // Data update timestamp (seconds)
optional string dataTimeStr = 3; // Data update time string, format YYYY-MM-DD HH:MM:SS, in the market's timezone
repeated BrokerItem brokerList = 4; // Broker list, sorted by net buy/sell volume descending
}
message Response
{
required int32 retType = 1 [default = -400]; // Return result, see Common.RetType
optional string retMsg = 2; // Return result description
optional int32 errCode = 3; // Error code
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
- API call result: refer to RetType
- Buy/sell type: refer to BuySellType
Protocol ID
3247
uint GetTopTenBuySellBrokers(QotGetTopTenBuySellBrokers.Request req);
virtual void OnReply_GetTopTenBuySellBrokers(MMAPI_Conn client, uint nSerialNo, QotGetTopTenBuySellBrokers.Response rsp);
Description
Get Top Ten Buy/Sell Brokers
Parameters
message C2S
{
required Qot_Common.Security security = 1; // Stock
optional int32 daysBefore = 2; // Leave empty or 0 = real-time; N = historical data for the N-th previous trading day
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
- Security structure: refer to Security
- Return
message S2C
{
optional bool isRealTime = 1; // true = real-time data, false = historical data
optional int64 dataTime = 2; // Data update timestamp (seconds)
optional string dataTimeStr = 3; // Data update time string, format YYYY-MM-DD HH:MM:SS
repeated BrokerItem brokerList = 4; // Broker list, sorted by net buy/sell volume descending
}
message Response
{
required int32 retType = 1 [default = -400]; // Return result, see Common.RetType
optional string retMsg = 2; // Return result description
optional int32 errCode = 3; // Error code
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
- API call result: refer to RetType
- Buy/sell type: refer to BuySellType
- 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}\n", errCode, desc, client.GetConnectID());
if (errCode != 0)
return;
QotCommon.Security sec = QotCommon.Security.CreateBuilder()
.SetMarket((int)QotCommon.QotMarket.QotMarket_HK_Security)
.SetCode("00700")
.Build();
QotGetTopTenBuySellBrokers.C2S c2s = QotGetTopTenBuySellBrokers.C2S.CreateBuilder()
.SetSecurity(sec)
.Build();
QotGetTopTenBuySellBrokers.Request req = QotGetTopTenBuySellBrokers.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetTopTenBuySellBrokers(req);
Console.Write("Send QotGetTopTenBuySellBrokers: {0}\n", seqNo);
}
public void OnDisconnect(FTAPI_Conn client, long errCode)
{
Console.Write("Qot onDisConnect: {0}\n", errCode);
}
public void OnReply_GetTopTenBuySellBrokers(FTAPI_Conn client, uint nSerialNo, QotGetTopTenBuySellBrokers.Response rsp)
{
Console.Write("Reply: QotGetTopTenBuySellBrokers: {0} {1}\n", nSerialNo, rsp.ToString());
}
public static void Main(String[] args)
{
FTAPI.Init();
Program qot = new Program();
qot.Start();
while (true)
Thread.Sleep(1000 * 600);
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
- Output
sent seqNo=3
retType: 0
retMsg: ""
errCode: 0
s2c {
isRealTime: true
dataTime: 1778227221
dataTimeStr: "2026-05-08 16:00:21"
brokerList {
netVol: 360300
brokerName: "Goldman Sachs"
buySellType: BuySellType_NetBuy
avgPrice: 471.037340153
totalVol: 586500
totalTurnover: 276263400
}
brokerList {
//...
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
int getTopTenBuySellBrokers(QotGetTopTenBuySellBrokers.Request req);
void onReply_GetTopTenBuySellBrokers(MMAPI_Conn client, int nSerialNo, QotGetTopTenBuySellBrokers.Response rsp);
Description
Get Top Ten Buy/Sell Brokers
Parameters
message C2S
{
required Qot_Common.Security security = 1; // Stock
optional int32 daysBefore = 2; // Leave empty or 0 = real-time; N = historical data for the N-th previous trading day
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
- Security structure: refer to Security
- Return
message S2C
{
optional bool isRealTime = 1; // true = real-time data, false = historical data
optional int64 dataTime = 2; // Data update timestamp (seconds)
optional string dataTimeStr = 3; // Data update time string, format YYYY-MM-DD HH:MM:SS
repeated BrokerItem brokerList = 4; // Broker list, sorted by net buy/sell volume descending
}
message Response
{
required int32 retType = 1 [default = -400]; // Return result, see Common.RetType
optional string retMsg = 2; // Return result description
optional int32 errCode = 3; // Error code
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
- API call result: refer to RetType
- Buy/sell type: refer to BuySellType
- 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=%b desc=%s connID=%d\n", errCode, desc, client.getConnectID());
if (errCode != 0)
return;
QotCommon.Security sec = QotCommon.Security.newBuilder()
.setMarket(QotCommon.QotMarket.QotMarket_HK_Security_VALUE)
.setCode("00700")
.build();
QotGetTopTenBuySellBrokers.C2S c2s = QotGetTopTenBuySellBrokers.C2S.newBuilder()
.setSecurity(sec)
.build();
QotGetTopTenBuySellBrokers.Request req = QotGetTopTenBuySellBrokers.Request.newBuilder().setC2S(c2s).build();
int seqNo = qot.getTopTenBuySellBrokers(req);
System.out.printf("Send QotGetTopTenBuySellBrokers: %d\n", seqNo);
}
@Override
public void onDisconnect(FTAPI_Conn client, long errCode) {
System.out.printf("Qot onDisConnect: %d\n", errCode);
}
@Override
public void onReply_GetTopTenBuySellBrokers(FTAPI_Conn client, int nSerialNo, QotGetTopTenBuySellBrokers.Response rsp) {
if (rsp.getRetType() != 0) {
System.out.printf("QotGetTopTenBuySellBrokers failed: %s\n", rsp.getRetMsg());
}
else {
try {
String json = JsonFormat.printer().print(rsp);
System.out.printf("Receive QotGetTopTenBuySellBrokers: %s\n", 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
Qot onInitConnect: ret=0 desc= connID=7459212704997168681
Send Qot_GetTopTenBuySellBrokers: 2
Receive Qot_GetTopTenBuySellBrokers: retType: 0
retMsg: ""
errCode: 0
s2c {
isRealTime: true
dataTime: 1778227221
dataTimeStr: "2026-05-08 16:00:21"
brokerList {
netVol: 360300
brokerName: "Goldman Sachs"
buySellType: BuySellType_NetBuy
avgPrice: 471.037340153
totalVol: 586500.0
totalTurnover: 2.762634E8
}
brokerList {
//...
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
moomoo::u32_t GetTopTenBuySellBrokers(const Qot_GetTopTenBuySellBrokers::Request &stReq);
virtual void OnReply_GetTopTenBuySellBrokers(moomoo::u32_t nSerialNo, const Qot_GetTopTenBuySellBrokers::Response &stRsp) = 0;
Description
Get Top Ten Buy/Sell Brokers
Parameters
message C2S
{
required Qot_Common.Security security = 1; // Stock
optional int32 daysBefore = 2; // Leave empty or 0 = real-time; N = historical data for the N-th previous trading day
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
- Security structure: refer to Security
- Return
message S2C
{
optional bool isRealTime = 1; // true = real-time data, false = historical data
optional int64 dataTime = 2; // Data update timestamp (seconds)
optional string dataTimeStr = 3; // Data update time string, format YYYY-MM-DD HH:MM:SS
repeated BrokerItem brokerList = 4; // Broker list, sorted by net buy/sell volume descending
}
message Response
{
required int32 retType = 1 [default = -400]; // Return result, see Common.RetType
optional string retMsg = 2; // Return result description
optional int32 errCode = 3; // Error code
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
- API call result: refer to RetType
- Buy/sell type: refer to BuySellType
- Example
class Program : public FTSPI_Qot, public FTSPI_Trd, 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) {
cout << "connect" << endl;
// construct request message
Qot_GetTopTenBuySellBrokers::Request req;
Qot_GetTopTenBuySellBrokers::C2S *c2s = req.mutable_c2s();
Qot_Common::Security *sec = c2s->mutable_security();
sec->set_code("00700");
sec->set_market(Qot_Common::QotMarket::QotMarket_HK_Security);
m_pQotApi->GetTopTenBuySellBrokers(req);
cout << "GetTopTenBuySellBrokers" << endl;
}
virtual void OnReply_GetTopTenBuySellBrokers(Futu::u32_t nSerialNo, const Qot_GetTopTenBuySellBrokers::Response &stRsp){
cout << "OnReply_GetTopTenBuySellBrokers:" << endl;
// print response
// ProtoBufToBodyData and UTF8ToLocal refer to tool.h in Samples
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
FTAPI_Qot *m_pQotApi;
};
int32_t main(int32_t argc, char** argv)
{
FTAPI::Init();
{
Program program;
program.Start();
getchar();
}
protobuf::ShutdownProtobufLibrary();
FTAPI::UnInit();
return 0;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
- Output
onInitConnect: ret=0 desc=Succeed!
Send Qot_GetTopTenBuySellBrokers seqNo=3
retType: 0
retMsg: ""
errCode: 0
s2c {
isRealTime: true
dataTime: 1778227221
dataTimeStr: "2026-05-08 16:00:21"
brokerList {
netVol: 360300
brokerName: "Goldman Sachs"
buySellType: BuySellType_NetBuy
avgPrice: 471.037340153
totalVol: 586500
totalTurnover: 276263400
}
brokerList {
//...
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
GetTopTenBuySellBrokers(req);
Description
Get Top Ten Buy/Sell Brokers
Parameters
message C2S
{
required Qot_Common.Security security = 1; // Stock
optional int32 daysBefore = 2; // Leave empty or 0 = real-time; N = historical data for the N-th previous trading day
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
- Security structure: refer to Security
- Return
message S2C
{
optional bool isRealTime = 1; // true = real-time data, false = historical data
optional int64 dataTime = 2; // Data update timestamp (seconds)
optional string dataTimeStr = 3; // Data update time string, format YYYY-MM-DD HH:MM:SS
repeated BrokerItem brokerList = 4; // Broker list, sorted by net buy/sell volume descending
}
message Response
{
required int32 retType = 1 [default = -400]; // Return result, see Common.RetType
optional string retMsg = 2; // Return result description
optional int32 errCode = 3; // Error code
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
- API call result: refer to RetType
- Buy/sell type: refer to BuySellType
- Example
import ftWebsocket from "futu-api";
import { Common, Qot_Common } from "futu-api/proto";
import beautify from "js-beautify";
function QotGetTopTenBuySellBrokers(){
const { RetType } = Common
const { QotMarket } = Qot_Common
let [addr, port, enable_ssl, key] = ["127.0.0.1", 33333, false, '7522027ccf5a06b1'];
let websocket = new ftWebsocket();
websocket.onlogin = (ret, msg)=>{
if (ret) {
const req = {
c2s: {
security: {
market: QotMarket.QotMarket_HK_Security,
code: "00700",
},
},
};
websocket.GetTopTenBuySellBrokers(req)
.then((res) => {
let { errCode, retMsg, retType,s2c } = res
console.log("GetTopTenBuySellBrokers: 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("error", msg);
}
};
websocket.start(addr, port, enable_ssl, key);
setTimeout(()=>{
websocket.stop();
console.log("stop");
}, 5000);
}
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
- Output
GetTopTenBuySellBrokers: errCode 0, retMsg , retType 0
{
"isRealTime": true,
"dataTime": "1778227221",
"dataTimeStr": "2026-05-08 16:00:21",
"brokerList": [{
"netVol": "360300",
"brokerName": "Goldman Sachs",
"buySellType": "BuySellType_NetBuy",
"avgPrice": 471.037340153,
"totalVol": 586500,
"totalTurnover": 276263400
//...
}]
}
stop
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Restrictions
- Maximum 30 requests per 30 seconds.
- HK stocks only (equities and funds).
days_before=0or omitted returns real-time data (includes avg price / total volume / total turnover);days_before>0returns net volume and broker name only.
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_top_ten_buy_sell_brokers(code, days_before=None)
Description
Get the top ten net buy and net sell broker lists for the specified HK stock (real-time or historical)
Parameters
Parameter Type Description code str Stock code HK stocks only (equities and funds), e.g. HK.00700days_before int Historical days Leave empty or 0 = real-time data (includes avg price / total volume / total turnover); >0 = historical data for the N-th previous trading day (net volume and broker name only)Return
Parameter Type Description ret RET_CODE API call result data pd.DataFrame When ret == RET_OK, returns broker data DataFrame str When ret != RET_OK, returns error description DataFrame fields:
Field Type Description is_real_time bool Whether real-time data true = real-time, false = historicaldata_time int Data update timestamp Unix timestamp in secondsdata_time_str str Data update time string Format YYYY-MM-DD HH:MM:SS, in the market's timezonenet_vol int Net buy/sell volume Positive for net buy, negative for net sellbroker_name str Broker display name Real-time uses broker profile data; historical uses the name from the responsebuy_sell_type BuySellType Buy/sell type avg_price float Average trade price Real-time data onlytotal_vol float Total trade volume Real-time data onlytotal_turnover float Total trade turnover Real-time data only
BuySellType Enum
Enum Name Value Description Unknown 0 Unknown NetBuy 1 Net buy NetSell 2 Net sell Example
from moomoo import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data = quote_ctx.get_top_ten_buy_sell_brokers("HK.00700")
if ret == RET_OK:
print(data)
else:
print('error:', data)
quote_ctx.close()
2
3
4
5
6
7
8
9
- Output
net_vol is_real_time buy_sell_type ... avg_price total_vol total_turnover
0 99200 True 1 ... 466.852156 398800.0 186180640.0
1 46500 True 1 ... 466.508972 61300.0 28597000.0
2 45400 True 1 ... 466.224332 67400.0 31423520.0
3 36000 True 1 ... 467.343428 240400.0 112349360.0
4 31300 True 1 ... 466.900580 155100.0 72416280.0
5 30000 True 1 ... 465.546667 30000.0 13966400.0
6 15000 True 1 ... 466.809333 15000.0 7002140.0
7 13700 True 1 ... 466.816577 55500.0 25908320.0
8 12300 True 1 ... 466.557724 12300.0 5738660.0
9 9200 True 1 ... 466.217391 9200.0 4289200.0
10 -373700 True 2 ... 467.064060 414300.0 193504640.0
11 -235100 True 2 ... 466.822072 502900.0 234764820.0
12 -168100 True 2 ... 466.281052 311900.0 145433060.0
13 -138300 True 2 ... 467.436639 547500.0 255921560.0
14 -89800 True 2 ... 466.722515 265600.0 123961500.0
15 -79400 True 2 ... 466.431910 79600.0 37127980.0
16 -69700 True 2 ... 466.950688 94500.0 44126840.0
17 -43600 True 2 ... 466.546230 61000.0 28459320.0
18 -25300 True 2 ... 466.652174 25300.0 11806300.0
19 -19500 True 2 ... 466.124484 33900.0 15801620.0
[20 rows x 9 columns]
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Qot_GetTopTenBuySellBrokers.proto
Description
Get Top Ten Buy/Sell Brokers
Parameters
message C2S
{
required Qot_Common.Security security = 1; // Stock
optional int32 daysBefore = 2; // Leave empty or 0 = real-time; N = historical data for the N-th previous trading day
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
- Security structure: refer to Security
- Return
message BrokerItem
{
optional int64 netVol = 1; // Net buy/sell volume
optional string brokerName = 2; // Broker display name (real-time uses broker profile; historical uses response name)
optional Qot_Common.BuySellType buySellType = 3; // Buy/sell type, see Qot_Common.BuySellType
optional double avgPrice = 4; // Average trade price (real-time data only)
optional double totalVol = 5; // Total trade volume (real-time data only)
optional double totalTurnover = 6; // Total trade turnover (real-time data only)
}
message S2C
{
optional bool isRealTime = 1; // true = real-time data, false = historical data
optional int64 dataTime = 2; // Data update timestamp (seconds)
optional string dataTimeStr = 3; // Data update time string, format YYYY-MM-DD HH:MM:SS, in the market's timezone
repeated BrokerItem brokerList = 4; // Broker list, sorted by net buy/sell volume descending
}
message Response
{
required int32 retType = 1 [default = -400]; // Return result, see Common.RetType
optional string retMsg = 2; // Return result description
optional int32 errCode = 3; // Error code
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
- API call result: refer to RetType
- Buy/sell type: refer to BuySellType
Protocol ID
3247
uint GetTopTenBuySellBrokers(QotGetTopTenBuySellBrokers.Request req);
virtual void OnReply_GetTopTenBuySellBrokers(MMAPI_Conn client, uint nSerialNo, QotGetTopTenBuySellBrokers.Response rsp);
Description
Get Top Ten Buy/Sell Brokers
Parameters
message C2S
{
required Qot_Common.Security security = 1; // Stock
optional int32 daysBefore = 2; // Leave empty or 0 = real-time; N = historical data for the N-th previous trading day
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
- Security structure: refer to Security
- Return
message S2C
{
optional bool isRealTime = 1; // true = real-time data, false = historical data
optional int64 dataTime = 2; // Data update timestamp (seconds)
optional string dataTimeStr = 3; // Data update time string, format YYYY-MM-DD HH:MM:SS
repeated BrokerItem brokerList = 4; // Broker list, sorted by net buy/sell volume descending
}
message Response
{
required int32 retType = 1 [default = -400]; // Return result, see Common.RetType
optional string retMsg = 2; // Return result description
optional int32 errCode = 3; // Error code
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
- API call result: refer to RetType
- Buy/sell type: refer to BuySellType
- 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}\n", errCode, desc, client.GetConnectID());
if (errCode != 0)
return;
QotCommon.Security sec = QotCommon.Security.CreateBuilder()
.SetMarket((int)QotCommon.QotMarket.QotMarket_HK_Security)
.SetCode("00700")
.Build();
QotGetTopTenBuySellBrokers.C2S c2s = QotGetTopTenBuySellBrokers.C2S.CreateBuilder()
.SetSecurity(sec)
.Build();
QotGetTopTenBuySellBrokers.Request req = QotGetTopTenBuySellBrokers.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetTopTenBuySellBrokers(req);
Console.Write("Send QotGetTopTenBuySellBrokers: {0}\n", seqNo);
}
public void OnDisconnect(MMAPI_Conn client, long errCode)
{
Console.Write("Qot onDisConnect: {0}\n", errCode);
}
public void OnReply_GetTopTenBuySellBrokers(MMAPI_Conn client, uint nSerialNo, QotGetTopTenBuySellBrokers.Response rsp)
{
Console.Write("Reply: QotGetTopTenBuySellBrokers: {0} {1}\n", nSerialNo, rsp.ToString());
}
public static void Main(String[] args)
{
MMAPI.Init();
Program qot = new Program();
qot.Start();
while (true)
Thread.Sleep(1000 * 600);
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
- Output
sent seqNo=3
retType: 0
retMsg: ""
errCode: 0
s2c {
isRealTime: true
dataTime: 1778227221
dataTimeStr: "2026-05-08 16:00:21"
brokerList {
netVol: 360300
brokerName: "Goldman Sachs"
buySellType: BuySellType_NetBuy
avgPrice: 471.037340153
totalVol: 586500
totalTurnover: 276263400
}
brokerList {
//...
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
int getTopTenBuySellBrokers(QotGetTopTenBuySellBrokers.Request req);
void onReply_GetTopTenBuySellBrokers(MMAPI_Conn client, int nSerialNo, QotGetTopTenBuySellBrokers.Response rsp);
Description
Get Top Ten Buy/Sell Brokers
Parameters
message C2S
{
required Qot_Common.Security security = 1; // Stock
optional int32 daysBefore = 2; // Leave empty or 0 = real-time; N = historical data for the N-th previous trading day
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
- Security structure: refer to Security
- Return
message S2C
{
optional bool isRealTime = 1; // true = real-time data, false = historical data
optional int64 dataTime = 2; // Data update timestamp (seconds)
optional string dataTimeStr = 3; // Data update time string, format YYYY-MM-DD HH:MM:SS
repeated BrokerItem brokerList = 4; // Broker list, sorted by net buy/sell volume descending
}
message Response
{
required int32 retType = 1 [default = -400]; // Return result, see Common.RetType
optional string retMsg = 2; // Return result description
optional int32 errCode = 3; // Error code
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
- API call result: refer to RetType
- Buy/sell type: refer to BuySellType
- 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=%b desc=%s connID=%d\n", errCode, desc, client.getConnectID());
if (errCode != 0)
return;
QotCommon.Security sec = QotCommon.Security.newBuilder()
.setMarket(QotCommon.QotMarket.QotMarket_HK_Security_VALUE)
.setCode("00700")
.build();
QotGetTopTenBuySellBrokers.C2S c2s = QotGetTopTenBuySellBrokers.C2S.newBuilder()
.setSecurity(sec)
.build();
QotGetTopTenBuySellBrokers.Request req = QotGetTopTenBuySellBrokers.Request.newBuilder().setC2S(c2s).build();
int seqNo = qot.getTopTenBuySellBrokers(req);
System.out.printf("Send QotGetTopTenBuySellBrokers: %d\n", seqNo);
}
@Override
public void onDisconnect(MMAPI_Conn client, long errCode) {
System.out.printf("Qot onDisConnect: %d\n", errCode);
}
@Override
public void onReply_GetTopTenBuySellBrokers(MMAPI_Conn client, int nSerialNo, QotGetTopTenBuySellBrokers.Response rsp) {
if (rsp.getRetType() != 0) {
System.out.printf("QotGetTopTenBuySellBrokers failed: %s\n", rsp.getRetMsg());
}
else {
try {
String json = JsonFormat.printer().print(rsp);
System.out.printf("Receive QotGetTopTenBuySellBrokers: %s\n", 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
Qot onInitConnect: ret=0 desc= connID=7459212704997168681
Send Qot_GetTopTenBuySellBrokers: 2
Receive Qot_GetTopTenBuySellBrokers: retType: 0
retMsg: ""
errCode: 0
s2c {
isRealTime: true
dataTime: 1778227221
dataTimeStr: "2026-05-08 16:00:21"
brokerList {
netVol: 360300
brokerName: "Goldman Sachs"
buySellType: BuySellType_NetBuy
avgPrice: 471.037340153
totalVol: 586500.0
totalTurnover: 2.762634E8
}
brokerList {
//...
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
moomoo::u32_t GetTopTenBuySellBrokers(const Qot_GetTopTenBuySellBrokers::Request &stReq);
virtual void OnReply_GetTopTenBuySellBrokers(moomoo::u32_t nSerialNo, const Qot_GetTopTenBuySellBrokers::Response &stRsp) = 0;
Description
Get Top Ten Buy/Sell Brokers
Parameters
message C2S
{
required Qot_Common.Security security = 1; // Stock
optional int32 daysBefore = 2; // Leave empty or 0 = real-time; N = historical data for the N-th previous trading day
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
- Security structure: refer to Security
- Return
message S2C
{
optional bool isRealTime = 1; // true = real-time data, false = historical data
optional int64 dataTime = 2; // Data update timestamp (seconds)
optional string dataTimeStr = 3; // Data update time string, format YYYY-MM-DD HH:MM:SS
repeated BrokerItem brokerList = 4; // Broker list, sorted by net buy/sell volume descending
}
message Response
{
required int32 retType = 1 [default = -400]; // Return result, see Common.RetType
optional string retMsg = 2; // Return result description
optional int32 errCode = 3; // Error code
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
- API call result: refer to RetType
- Buy/sell type: refer to BuySellType
- Example
class Program : public MMSPI_Qot, public MMSPI_Trd, 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) {
cout << "connect" << endl;
// construct request message
Qot_GetTopTenBuySellBrokers::Request req;
Qot_GetTopTenBuySellBrokers::C2S *c2s = req.mutable_c2s();
Qot_Common::Security *sec = c2s->mutable_security();
sec->set_code("00700");
sec->set_market(Qot_Common::QotMarket::QotMarket_HK_Security);
m_pQotApi->GetTopTenBuySellBrokers(req);
cout << "GetTopTenBuySellBrokers" << endl;
}
virtual void OnReply_GetTopTenBuySellBrokers(moomoo::u32_t nSerialNo, const Qot_GetTopTenBuySellBrokers::Response &stRsp){
cout << "OnReply_GetTopTenBuySellBrokers:" << endl;
// print response
// ProtoBufToBodyData and UTF8ToLocal refer to tool.h in Samples
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
MMAPI_Qot *m_pQotApi;
};
int32_t main(int32_t argc, char** argv)
{
MMAPI::Init();
{
Program program;
program.Start();
getchar();
}
protobuf::ShutdownProtobufLibrary();
MMAPI::UnInit();
return 0;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
- Output
onInitConnect: ret=0 desc=Succeed!
Send Qot_GetTopTenBuySellBrokers seqNo=3
retType: 0
retMsg: ""
errCode: 0
s2c {
isRealTime: true
dataTime: 1778227221
dataTimeStr: "2026-05-08 16:00:21"
brokerList {
netVol: 360300
brokerName: "Goldman Sachs"
buySellType: BuySellType_NetBuy
avgPrice: 471.037340153
totalVol: 586500
totalTurnover: 276263400
}
brokerList {
//...
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
GetTopTenBuySellBrokers(req);
Description
Get Top Ten Buy/Sell Brokers
Parameters
message C2S
{
required Qot_Common.Security security = 1; // Stock
optional int32 daysBefore = 2; // Leave empty or 0 = real-time; N = historical data for the N-th previous trading day
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
- Security structure: refer to Security
- Return
message S2C
{
optional bool isRealTime = 1; // true = real-time data, false = historical data
optional int64 dataTime = 2; // Data update timestamp (seconds)
optional string dataTimeStr = 3; // Data update time string, format YYYY-MM-DD HH:MM:SS
repeated BrokerItem brokerList = 4; // Broker list, sorted by net buy/sell volume descending
}
message Response
{
required int32 retType = 1 [default = -400]; // Return result, see Common.RetType
optional string retMsg = 2; // Return result description
optional int32 errCode = 3; // Error code
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
- API call result: refer to RetType
- Buy/sell type: refer to BuySellType
- Example
import mmWebsocket from "moomoo-api";
import { Common, Qot_Common } from "moomoo-api/proto";
import beautify from "js-beautify";
function QotGetTopTenBuySellBrokers(){
const { RetType } = Common
const { QotMarket } = Qot_Common
let [addr, port, enable_ssl, key] = ["127.0.0.1", 33333, false, '7522027ccf5a06b1'];
let websocket = new mmWebsocket();
websocket.onlogin = (ret, msg)=>{
if (ret) {
const req = {
c2s: {
security: {
market: QotMarket.QotMarket_HK_Security,
code: "00700",
},
},
};
websocket.GetTopTenBuySellBrokers(req)
.then((res) => {
let { errCode, retMsg, retType,s2c } = res
console.log("GetTopTenBuySellBrokers: 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("error", msg);
}
};
websocket.start(addr, port, enable_ssl, key);
setTimeout(()=>{
websocket.stop();
console.log("stop");
}, 5000);
}
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
- Output
GetTopTenBuySellBrokers: errCode 0, retMsg , retType 0
{
"isRealTime": true,
"dataTime": "1778227221",
"dataTimeStr": "2026-05-08 16:00:21",
"brokerList": [{
"netVol": "360300",
"brokerName": "Goldman Sachs",
"buySellType": "BuySellType_NetBuy",
"avgPrice": 471.037340153,
"totalVol": 586500,
"totalTurnover": 276263400
//...
}]
}
stop
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Restrictions
- Maximum 30 requests per 30 seconds.
- HK stocks only (equities and funds).
days_before=0or omitted returns real-time data (includes avg price / total volume / total turnover);days_before>0returns net volume and broker name only.