# 獲取十大經紀商買賣數據
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_top_ten_buy_sell_brokers(code, days_before=None)
介紹
獲取指定港股的十大淨買入和淨賣出經紀商列表(實時或歷史)
參數
參數 類型 說明 code str 股票代碼 僅支援港股正股及基金,如 HK.00700days_before int 歷史天數 不填或 0=實時數據(含均價/總量/總額),>0=取前第 N 個交易日的歷史數據(僅含淨量和經紀商名稱)回傳
參數 類型 說明 ret RET_CODE 介面調用結果 data pd.DataFrame 當 ret == RET_OK,回傳經紀商數據 DataFrame str 當 ret != RET_OK,回傳錯誤描述 DataFrame 欄位說明:
欄位 類型 說明 is_real_time bool 是否實時數據 true=實時,false=歷史data_time int 數據更新時間戳(秒級 Unix 時間戳) data_time_str str 數據更新時間字串 格式 YYYY-MM-DD HH:MM:SS,對應市場時區net_vol int 淨買賣量 淨買入為正,淨賣出為負broker_name str 經紀商名稱 實時按券商資料填充,歷史取回包名稱buy_sell_type BuySellType 買賣類型 avg_price float 成交均價 僅實時數據有效total_vol float 總成交量 僅實時數據有效total_turnover float 總成交額 僅實時數據有效
BuySellType 枚舉
枚舉名 值 說明 Unknown 0 未知 NetBuy 1 淨買入 NetSell 2 淨賣出 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
介紹
獲取十大經紀商買賣數據
參數
message C2S
{
required Qot_Common.Security security = 1; // 股票
optional int32 daysBefore = 2; // 不填或 0=實時,N=取前第 N 個交易日的歷史數據
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
- 股票結構參見 Security
- 回傳
message BrokerItem
{
optional int64 netVol = 1; // 淨買入/賣出量
optional string brokerName = 2; // 經紀商展示名稱(實時按券商資料填充,歷史取回包名稱)
optional Qot_Common.BuySellType buySellType = 3; // 買賣類型,詳見 Qot_Common.BuySellType 定義
optional double avgPrice = 4; // 成交均價(僅實時數據有效)
optional double totalVol = 5; // 總成交量(僅實時數據有效)
optional double totalTurnover = 6; // 總成交額(僅實時數據有效)
}
message S2C
{
optional bool isRealTime = 1; // true=實時數據,false=歷史數據
optional int64 dataTime = 2; // 數據更新時間戳(秒)
optional string dataTimeStr = 3; // 數據更新時間字串,格式 YYYY-MM-DD HH:MM:SS,對應市場時區
repeated BrokerItem brokerList = 4; // 經紀商列表,按淨買/賣量從高到低排列
}
message Response
{
required int32 retType = 1 [default = -400]; // 回傳結果,詳見 Common.RetType
optional string retMsg = 2; // 回傳結果描述
optional int32 errCode = 3; // 錯誤碼
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
- 介面調用結果,結構參見 RetType
- 買賣方向參見 BuySellType
協議 ID
3247
uint GetTopTenBuySellBrokers(QotGetTopTenBuySellBrokers.Request req);
virtual void OnReply_GetTopTenBuySellBrokers(FTAPI_Conn client, uint nSerialNo, QotGetTopTenBuySellBrokers.Response rsp);
介紹
獲取十大經紀商買賣數據
參數
message C2S
{
required Qot_Common.Security security = 1; // 股票
optional int32 daysBefore = 2; // 不填或 0=實時,N=取前第 N 個交易日的歷史數據
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
- 股票結構參見 Security
- 回傳
message S2C
{
optional bool isRealTime = 1; // true=實時數據,false=歷史數據
optional int64 dataTime = 2; // 數據更新時間戳(秒)
optional string dataTimeStr = 3; // 數據更新時間字串,格式 YYYY-MM-DD HH:MM:SS
repeated BrokerItem brokerList = 4; // 經紀商列表,按淨買/賣量從高到低排列
}
message Response
{
required int32 retType = 1 [default = -400]; // 回傳結果,詳見 Common.RetType
optional string retMsg = 2; // 回傳結果描述
optional int32 errCode = 3; // 錯誤碼
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
- 介面調用結果,結構參見 RetType
- 買賣方向參見 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(FTAPI_Conn client, int nSerialNo, QotGetTopTenBuySellBrokers.Response rsp);
介紹
獲取十大經紀商買賣數據
參數
message C2S
{
required Qot_Common.Security security = 1; // 股票
optional int32 daysBefore = 2; // 不填或 0=實時,N=取前第 N 個交易日的歷史數據
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
- 股票結構參見 Security
- 回傳
message S2C
{
optional bool isRealTime = 1; // true=實時數據,false=歷史數據
optional int64 dataTime = 2; // 數據更新時間戳(秒)
optional string dataTimeStr = 3; // 數據更新時間字串,格式 YYYY-MM-DD HH:MM:SS
repeated BrokerItem brokerList = 4; // 經紀商列表,按淨買/賣量從高到低排列
}
message Response
{
required int32 retType = 1 [default = -400]; // 回傳結果,詳見 Common.RetType
optional string retMsg = 2; // 回傳結果描述
optional int32 errCode = 3; // 錯誤碼
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
- 介面調用結果,結構參見 RetType
- 買賣方向參見 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
Futu::u32_t GetTopTenBuySellBrokers(const Qot_GetTopTenBuySellBrokers::Request &stReq);
virtual void OnReply_GetTopTenBuySellBrokers(Futu::u32_t nSerialNo, const Qot_GetTopTenBuySellBrokers::Response &stRsp) = 0;
介紹
獲取十大經紀商買賣數據
參數
message C2S
{
required Qot_Common.Security security = 1; // 股票
optional int32 daysBefore = 2; // 不填或 0=實時,N=取前第 N 個交易日的歷史數據
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
- 股票結構參見 Security
- 回傳
message S2C
{
optional bool isRealTime = 1; // true=實時數據,false=歷史數據
optional int64 dataTime = 2; // 數據更新時間戳(秒)
optional string dataTimeStr = 3; // 數據更新時間字串,格式 YYYY-MM-DD HH:MM:SS
repeated BrokerItem brokerList = 4; // 經紀商列表,按淨買/賣量從高到低排列
}
message Response
{
required int32 retType = 1 [default = -400]; // 回傳結果,詳見 Common.RetType
optional string retMsg = 2; // 回傳結果描述
optional int32 errCode = 3; // 錯誤碼
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
- 介面調用結果,結構參見 RetType
- 買賣方向參見 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);
介紹
獲取十大經紀商買賣數據
參數
message C2S
{
required Qot_Common.Security security = 1; // 股票
optional int32 daysBefore = 2; // 不填或 0=實時,N=取前第 N 個交易日的歷史數據
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
- 股票結構參見 Security
- 回傳
message S2C
{
optional bool isRealTime = 1; // true=實時數據,false=歷史數據
optional int64 dataTime = 2; // 數據更新時間戳(秒)
optional string dataTimeStr = 3; // 數據更新時間字串,格式 YYYY-MM-DD HH:MM:SS
repeated BrokerItem brokerList = 4; // 經紀商列表,按淨買/賣量從高到低排列
}
message Response
{
required int32 retType = 1 [default = -400]; // 回傳結果,詳見 Common.RetType
optional string retMsg = 2; // 回傳結果描述
optional int32 errCode = 3; // 錯誤碼
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
- 介面調用結果,結構參見 RetType
- 買賣方向參見 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
介面限制
- 每 30 秒內最多請求 30 次。
- 僅支援港股正股及基金。
days_before=0或不填回傳實時數據(含均價/總量/總額),days_before>0僅含淨量和經紀商名稱。
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_top_ten_buy_sell_brokers(code, days_before=None)
介紹
獲取指定港股的十大淨買入和淨賣出經紀商列表(實時或歷史)
參數
參數 類型 說明 code str 股票代碼 僅支援港股正股及基金,如 HK.00700days_before int 歷史天數 不填或 0=實時數據(含均價/總量/總額),>0=取前第 N 個交易日的歷史數據(僅含淨量和經紀商名稱)回傳
參數 類型 說明 ret RET_CODE 介面調用結果 data pd.DataFrame 當 ret == RET_OK,回傳經紀商數據 DataFrame str 當 ret != RET_OK,回傳錯誤描述 DataFrame 欄位說明:
欄位 類型 說明 is_real_time bool 是否實時數據 true=實時,false=歷史data_time int 數據更新時間戳(秒級 Unix 時間戳) data_time_str str 數據更新時間字串 格式 YYYY-MM-DD HH:MM:SS,對應市場時區net_vol int 淨買賣量 淨買入為正,淨賣出為負broker_name str 經紀商名稱 實時按券商資料填充,歷史取回包名稱buy_sell_type BuySellType 買賣類型 avg_price float 成交均價 僅實時數據有效total_vol float 總成交量 僅實時數據有效total_turnover float 總成交額 僅實時數據有效
BuySellType 枚舉
枚舉名 值 說明 Unknown 0 未知 NetBuy 1 淨買入 NetSell 2 淨賣出 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
介紹
獲取十大經紀商買賣數據
參數
message C2S
{
required Qot_Common.Security security = 1; // 股票
optional int32 daysBefore = 2; // 不填或 0=實時,N=取前第 N 個交易日的歷史數據
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
- 股票結構參見 Security
- 回傳
message BrokerItem
{
optional int64 netVol = 1; // 淨買入/賣出量
optional string brokerName = 2; // 經紀商展示名稱(實時按券商資料填充,歷史取回包名稱)
optional Qot_Common.BuySellType buySellType = 3; // 買賣類型,詳見 Qot_Common.BuySellType 定義
optional double avgPrice = 4; // 成交均價(僅實時數據有效)
optional double totalVol = 5; // 總成交量(僅實時數據有效)
optional double totalTurnover = 6; // 總成交額(僅實時數據有效)
}
message S2C
{
optional bool isRealTime = 1; // true=實時數據,false=歷史數據
optional int64 dataTime = 2; // 數據更新時間戳(秒)
optional string dataTimeStr = 3; // 數據更新時間字串,格式 YYYY-MM-DD HH:MM:SS,對應市場時區
repeated BrokerItem brokerList = 4; // 經紀商列表,按淨買/賣量從高到低排列
}
message Response
{
required int32 retType = 1 [default = -400]; // 回傳結果,詳見 Common.RetType
optional string retMsg = 2; // 回傳結果描述
optional int32 errCode = 3; // 錯誤碼
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
- 介面調用結果,結構參見 RetType
- 買賣方向參見 BuySellType
協議 ID
3247
uint GetTopTenBuySellBrokers(QotGetTopTenBuySellBrokers.Request req);
virtual void OnReply_GetTopTenBuySellBrokers(MMAPI_Conn client, uint nSerialNo, QotGetTopTenBuySellBrokers.Response rsp);
介紹
獲取十大經紀商買賣數據
參數
message C2S
{
required Qot_Common.Security security = 1; // 股票
optional int32 daysBefore = 2; // 不填或 0=實時,N=取前第 N 個交易日的歷史數據
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
- 股票結構參見 Security
- 回傳
message S2C
{
optional bool isRealTime = 1; // true=實時數據,false=歷史數據
optional int64 dataTime = 2; // 數據更新時間戳(秒)
optional string dataTimeStr = 3; // 數據更新時間字串,格式 YYYY-MM-DD HH:MM:SS
repeated BrokerItem brokerList = 4; // 經紀商列表,按淨買/賣量從高到低排列
}
message Response
{
required int32 retType = 1 [default = -400]; // 回傳結果,詳見 Common.RetType
optional string retMsg = 2; // 回傳結果描述
optional int32 errCode = 3; // 錯誤碼
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
- 介面調用結果,結構參見 RetType
- 買賣方向參見 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);
介紹
獲取十大經紀商買賣數據
參數
message C2S
{
required Qot_Common.Security security = 1; // 股票
optional int32 daysBefore = 2; // 不填或 0=實時,N=取前第 N 個交易日的歷史數據
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
- 股票結構參見 Security
- 回傳
message S2C
{
optional bool isRealTime = 1; // true=實時數據,false=歷史數據
optional int64 dataTime = 2; // 數據更新時間戳(秒)
optional string dataTimeStr = 3; // 數據更新時間字串,格式 YYYY-MM-DD HH:MM:SS
repeated BrokerItem brokerList = 4; // 經紀商列表,按淨買/賣量從高到低排列
}
message Response
{
required int32 retType = 1 [default = -400]; // 回傳結果,詳見 Common.RetType
optional string retMsg = 2; // 回傳結果描述
optional int32 errCode = 3; // 錯誤碼
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
- 介面調用結果,結構參見 RetType
- 買賣方向參見 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;
介紹
獲取十大經紀商買賣數據
參數
message C2S
{
required Qot_Common.Security security = 1; // 股票
optional int32 daysBefore = 2; // 不填或 0=實時,N=取前第 N 個交易日的歷史數據
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
- 股票結構參見 Security
- 回傳
message S2C
{
optional bool isRealTime = 1; // true=實時數據,false=歷史數據
optional int64 dataTime = 2; // 數據更新時間戳(秒)
optional string dataTimeStr = 3; // 數據更新時間字串,格式 YYYY-MM-DD HH:MM:SS
repeated BrokerItem brokerList = 4; // 經紀商列表,按淨買/賣量從高到低排列
}
message Response
{
required int32 retType = 1 [default = -400]; // 回傳結果,詳見 Common.RetType
optional string retMsg = 2; // 回傳結果描述
optional int32 errCode = 3; // 錯誤碼
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
- 介面調用結果,結構參見 RetType
- 買賣方向參見 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);
介紹
獲取十大經紀商買賣數據
參數
message C2S
{
required Qot_Common.Security security = 1; // 股票
optional int32 daysBefore = 2; // 不填或 0=實時,N=取前第 N 個交易日的歷史數據
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
- 股票結構參見 Security
- 回傳
message S2C
{
optional bool isRealTime = 1; // true=實時數據,false=歷史數據
optional int64 dataTime = 2; // 數據更新時間戳(秒)
optional string dataTimeStr = 3; // 數據更新時間字串,格式 YYYY-MM-DD HH:MM:SS
repeated BrokerItem brokerList = 4; // 經紀商列表,按淨買/賣量從高到低排列
}
message Response
{
required int32 retType = 1 [default = -400]; // 回傳結果,詳見 Common.RetType
optional string retMsg = 2; // 回傳結果描述
optional int32 errCode = 3; // 錯誤碼
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
- 介面調用結果,結構參見 RetType
- 買賣方向參見 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
介面限制
- 每 30 秒內最多請求 30 次。
- 僅支援港股正股及基金。
days_before=0或不填回傳實時數據(含均價/總量/總額),days_before>0僅含淨量和經紀商名稱。