# Get Institution List
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_institution_list(market, sort_field=None, sort_dir=None, count=None, page=None, name_part=None)
Description
Get institution list, returning a list of institutions ranked by position value/position change/holding count in a specified market, supporting fuzzy search and cursor pagination.
Parameters
Parameter Type Description market Market Market type (HK/US) (required) sort_field InstitutionListSortField Sort field, default position value sort_dir RankSortDir Sort direction, default descending count int Return count [1, 200], default 20 page str Page cursor, do not provide for first request, pass next_page from previous response name_part str Institution name fuzzy search Return
Parameter Type Description ret RET_CODE API call result data pd.DataFrame When ret == RET_OK, returns data str When ret != RET_OK, returns error description - Data format:
Field Type Description institution_id int Institution ID institution_name str Institution name position_value float Position value position_value_change float Position value change position_count int Position stock count position_count_change int Position stock count change disclosure_date str Disclosure date (yyyy-MM-dd) currency str Currency
- Data format:
Example
from futu import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data, next_page, all_count = quote_ctx.get_institution_list(market=Market.US, count=2)
if ret == RET_OK:
print(f'Total count: {all_count}')
print(data)
else:
print('error:', data)
quote_ctx.close()
2
3
4
5
6
7
8
9
10
11
12
- Output
Total count: 17030
institution_id institution_name position_value position_value_change position_count position_count_change disclosure_date currency
0 403413 贝莱德 6.959193e+12 3.432083e+10 4443 56 2026-06-19 USD
1 1951572549 Vanguard Capital Management, LLC 4.881261e+12 4.492246e+12 4289 3859 2026-06-10 USD
2
3
4
# Qot_GetInstitutionList.proto
Description
Get institution list. Returns the institution list ranked by dimensions such as holding market value/position changes/holding stock count in the specified market, with support for fuzzy search and cursor-based pagination.
Parameters
// Sort field
enum SortField {
SortField_Unknown = 0; // Default (holding market value)
SortField_PositionValue = 1; // Holding market value
SortField_PositionValueChange = 2; // Position change
SortField_PositionCount = 3; // Holding shares
SortField_PositionCountChange = 4; // Holding shares change
}
// Sort direction
enum SortDir {
SortDir_Descending = 0; // Descending (default)
SortDir_Ascending = 1; // Ascending
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket
optional int32 sortField = 2; // SortField, default holding market value
optional int32 sortDir = 3; // SortDir, default descending
optional int32 count = 4; // Count [1,200], default 20
optional string page = 5; // Page cursor, omit for first request, pass nextPage from S2C for next page
optional string namePart = 6; // Institution name fuzzy search
}
// Institution list data item
message InstitutionListItem {
required int32 institutionId = 1; // Institution ID
optional string institutionName = 2; // Institution name
optional double positionValue = 3; // Holding market value
optional double positionValueChange = 4;// Holding market value change
optional int32 positionCount = 5; // Number of holding stocks
optional int32 positionCountChange = 6; // Number of holding stocks change
optional string disclosureDate = 7; // Disclosure date (yyyy-MM-dd)
}
message S2C {
repeated InstitutionListItem dataList = 1; // Data list
optional int32 allCount = 2; // Total count
optional string nextPage = 3; // Next page cursor, empty=no more
optional string currency = 4; // Currency
}
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
Protocol ID
3418
uint GetInstitutionList(Qot_GetInstitutionList.Request req);
virtual void OnReply_GetInstitutionList(FTAPI_Conn client, uint nSerialNo, Qot_GetInstitutionList.Response rsp);
Description
Get institution list. Returns the institution list ranked by dimensions such as holding market value/position changes/holding stock count in the specified market, with support for fuzzy search and cursor-based pagination.
Parameters
// Sort field
enum SortField {
SortField_Unknown = 0; // Default (holding market value)
SortField_PositionValue = 1; // Holding market value
SortField_PositionValueChange = 2; // Position change
SortField_PositionCount = 3; // Holding shares
SortField_PositionCountChange = 4; // Holding shares change
}
// Sort direction
enum SortDir {
SortDir_Descending = 0; // Descending (default)
SortDir_Ascending = 1; // Ascending
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket
optional int32 sortField = 2; // SortField, default holding market value
optional int32 sortDir = 3; // SortDir, default descending
optional int32 count = 4; // Count [1,200], default 20
optional string page = 5; // Page cursor, omit for first request, pass nextPage from S2C for next page
optional string namePart = 6; // Institution name fuzzy search
}
// Institution list data item
message InstitutionListItem {
required int32 institutionId = 1; // Institution ID
optional string institutionName = 2; // Institution name
optional double positionValue = 3; // Holding market value
optional double positionValueChange = 4;// Holding market value change
optional int32 positionCount = 5; // Number of holding stocks
optional int32 positionCountChange = 6; // Number of holding stocks change
optional string disclosureDate = 7; // Disclosure date (yyyy-MM-dd)
}
message S2C {
repeated InstitutionListItem dataList = 1; // Data list
optional int32 allCount = 2; // Total count
optional string nextPage = 3; // Next page cursor, empty=no more
optional string currency = 4; // Currency
}
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
- For interface result, refer to RetType
Protocol ID
3418
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;
QotGetInstitutionList.C2S c2s = QotGetInstitutionList.C2S.CreateBuilder()
.SetMarket(11)
.SetCount(3)
.Build();
QotGetInstitutionList.Request req = QotGetInstitutionList.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetInstitutionList(req);
Console.Write("Send QotGetInstitutionList: {0}
", seqNo);
}
public void OnDisconnect(FTAPI_Conn client, long errCode) {
Console.Write("Qot onDisConnect: {0}
", errCode);
}
public void OnReply_GetInstitutionList(FTAPI_Conn client, uint nSerialNo, QotGetInstitutionList.Response rsp)
{
Console.Write("Reply: QotGetInstitutionList: {0}
", nSerialNo);
if (rsp.RetType == 0 && rsp.HasS2C)
Console.Write("{0}
", rsp.ToString());
}
public static void Main(String[] args) {
FTAPI.Init();
Program program = new Program();
program.Start();
while (true)
Thread.Sleep(1000 * 600);
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
- Output
Send QotGetInstitutionList: 3
Reply: QotGetInstitutionList: 3
GetInstitutionList: errCode 0, retMsg , retType 0
{
"allCount": 17031,
"currency": "USD",
"dataList": [
{ "institutionId": 403413, "institutionName": "贝莱德", "positionValue": 7040103000000.0 },
{ "institutionId": 1951572549, "institutionName": "Vanguard Capital Management, LLC", "positionValue": 4944657000000.0 },
{ "institutionId": 823170, "institutionName": "道富", "positionValue": 3363354000000.0 }
]
}
2
3
4
5
6
7
8
9
10
11
12
int getInstitutionList(Qot_GetInstitutionList.Request req);
onReply_GetInstitutionList(FTAPI_Conn client, int nSerialNo, Qot_GetInstitutionList.Response rsp)
Description
Get institution list. Returns the institution list ranked by dimensions such as holding market value/position changes/holding stock count in the specified market, with support for fuzzy search and cursor-based pagination.
Parameters
// Sort field
enum SortField {
SortField_Unknown = 0; // Default (holding market value)
SortField_PositionValue = 1; // Holding market value
SortField_PositionValueChange = 2; // Position change
SortField_PositionCount = 3; // Holding shares
SortField_PositionCountChange = 4; // Holding shares change
}
// Sort direction
enum SortDir {
SortDir_Descending = 0; // Descending (default)
SortDir_Ascending = 1; // Ascending
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket
optional int32 sortField = 2; // SortField, default holding market value
optional int32 sortDir = 3; // SortDir, default descending
optional int32 count = 4; // Count [1,200], default 20
optional string page = 5; // Page cursor, omit for first request, pass nextPage from S2C for next page
optional string namePart = 6; // Institution name fuzzy search
}
// Institution list data item
message InstitutionListItem {
required int32 institutionId = 1; // Institution ID
optional string institutionName = 2; // Institution name
optional double positionValue = 3; // Holding market value
optional double positionValueChange = 4;// Holding market value change
optional int32 positionCount = 5; // Number of holding stocks
optional int32 positionCountChange = 6; // Number of holding stocks change
optional string disclosureDate = 7; // Disclosure date (yyyy-MM-dd)
}
message S2C {
repeated InstitutionListItem dataList = 1; // Data list
optional int32 allCount = 2; // Total count
optional string nextPage = 3; // Next page cursor, empty=no more
optional string currency = 4; // Currency
}
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
- For interface result, refer to RetType
Protocol ID
3418
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;
QotGetInstitutionList.C2S c2s = QotGetInstitutionList.C2S.newBuilder()
.setMarket(11)
.setCount(3)
.build();
QotGetInstitutionList.Request req = QotGetInstitutionList.Request.newBuilder().setC2S(c2s).build();
int seqNo = qot.getInstitutionList(req);
System.out.printf("Send QotGetInstitutionList: %d
", seqNo);
}
@Override
public void onDisconnect(FTAPI_Conn client, long errCode) {
System.out.printf("Qot onDisConnect: %d
", errCode);
}
@Override
public void onReply_GetInstitutionList(FTAPI_Conn client, int nSerialNo, QotGetInstitutionList.Response rsp) {
if (rsp.getRetType() != 0) {
System.out.printf("QotGetInstitutionList failed: %s
", rsp.getRetMsg());
} else {
try {
String json = JsonFormat.printer().print(rsp);
System.out.printf("Receive QotGetInstitutionList: %s
", json);
} catch (InvalidProtocolBufferException e) {
e.printStackTrace();
}
}
}
public static void main(String[] args) {
FTAPI.init();
QotDemo qot = new QotDemo();
qot.start();
while (true) {
try {
Thread.sleep(1000 * 600);
} catch (InterruptedException exc) {
}
}
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
- Output
Send QotGetInstitutionList: 3
Receive QotGetInstitutionList: {
"allCount": 17031,
"currency": "USD",
"dataList": [
{ "institutionId": 403413, "institutionName": "贝莱德", "positionValue": 7040103000000.0 },
{ "institutionId": 1951572549, "institutionName": "Vanguard Capital Management, LLC", "positionValue": 4944657000000.0 },
{ "institutionId": 823170, "institutionName": "道富", "positionValue": 3363354000000.0 }
]
}
2
3
4
5
6
7
8
9
10
Futu::u32_t GetInstitutionList(const Qot_GetInstitutionList::Request &stReq);
virtual void OnReply_GetInstitutionList(Futu::u32_t nSerialNo, const Qot_GetInstitutionList::Response &stRsp) = 0;
Description
Protocol request and response definition
Parameters
// Sort field
enum SortField {
SortField_Unknown = 0; // Default (holding market value)
SortField_PositionValue = 1; // Holding market value
SortField_PositionValueChange = 2; // Position change
SortField_PositionCount = 3; // Holding shares
SortField_PositionCountChange = 4; // Holding shares change
}
// Sort direction
enum SortDir {
SortDir_Descending = 0; // Descending (default)
SortDir_Ascending = 1; // Ascending
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket
optional int32 sortField = 2; // SortField, default holding market value
optional int32 sortDir = 3; // SortDir, default descending
optional int32 count = 4; // Count [1,200], default 20
optional string page = 5; // Page cursor, omit for first request, pass nextPage from S2C for next page
optional string namePart = 6; // Institution name fuzzy search
}
// Institution list data item
message InstitutionListItem {
required int32 institutionId = 1; // Institution ID
optional string institutionName = 2; // Institution name
optional double positionValue = 3; // Holding market value
optional double positionValueChange = 4;// Holding market value change
optional int32 positionCount = 5; // Number of holding stocks
optional int32 positionCountChange = 6; // Number of holding stocks change
optional string disclosureDate = 7; // Disclosure date (yyyy-MM-dd)
}
message S2C {
repeated InstitutionListItem dataList = 1; // Data list
optional int32 allCount = 2; // Total count
optional string nextPage = 3; // Next page cursor, empty=no more
optional string currency = 4; // Currency
}
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
- For interface result, refer to RetType
Protocol ID
3418
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_GetInstitutionList::Request req;
Qot_GetInstitutionList::C2S *c2s = req.mutable_c2s();
c2s->set_market(Qot_Common::QotMarket::QotMarket_US_Security);
c2s->set_count(20);
m_GetInstitutionListSerialNo = m_pQotApi->GetInstitutionList(req);
}
virtual void OnReply_GetInstitutionList(Futu::u32_t nSerialNo, const Qot_GetInstitutionList::Response &stRsp) {
if (nSerialNo != m_GetInstitutionListSerialNo) return;
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
FTAPI_Qot *m_pQotApi;
Futu::u32_t m_GetInstitutionListSerialNo = 0;
};
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
- Output
{
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"dataList": [
{
"institutionId": 1001,
"institutionName": "Vanguard Group",
"positionValue": 8500000000000.0,
"positionCount": 3850,
"disclosureDate": "2024-03-31"
}
],
"allCount": 100,
"currency": "USD"
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
getInstitutionList(qotGetInstitutionList)
Description
Get institution list. Returns the institution list ranked by dimensions such as holding market value/position changes/holding stock count in the specified market, with support for fuzzy search and cursor-based pagination.
Parameters
// Sort field
enum SortField {
SortField_Unknown = 0; // Default (holding market value)
SortField_PositionValue = 1; // Holding market value
SortField_PositionValueChange = 2; // Position change
SortField_PositionCount = 3; // Holding shares
SortField_PositionCountChange = 4; // Holding shares change
}
// Sort direction
enum SortDir {
SortDir_Descending = 0; // Descending (default)
SortDir_Ascending = 1; // Ascending
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket
optional int32 sortField = 2; // SortField, default holding market value
optional int32 sortDir = 3; // SortDir, default descending
optional int32 count = 4; // Count [1,200], default 20
optional string page = 5; // Page cursor, omit for first request, pass nextPage from S2C for next page
optional string namePart = 6; // Institution name fuzzy search
}
// Institution list data item
message InstitutionListItem {
required int32 institutionId = 1; // Institution ID
optional string institutionName = 2; // Institution name
optional double positionValue = 3; // Holding market value
optional double positionValueChange = 4;// Holding market value change
optional int32 positionCount = 5; // Number of holding stocks
optional int32 positionCountChange = 6; // Number of holding stocks change
optional string disclosureDate = 7; // Disclosure date (yyyy-MM-dd)
}
message S2C {
repeated InstitutionListItem dataList = 1; // Data list
optional int32 allCount = 2; // Total count
optional string nextPage = 3; // Next page cursor, empty=no more
optional string currency = 4; // Currency
}
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
- For interface result, refer to RetType
Protocol ID
3418
Example
import ftWebsocket from "futu-api";
import { Common, Qot_Common } from "futu-api/proto";
import beautify from "js-beautify";
function QotGetInstitutionList(){
const { RetType } = Common
let [addr, port, enable_ssl, key] = ["127.0.0.1", 11111, false, "xxxxxx"];
let websocket = new ftWebsocket();
websocket.onlogin = (ret, msg)=>{
if (ret) {
const req = {
c2s: { market: 11, count: 3 },
};
websocket.GetInstitutionList(req)
.then((res)=>{
let { errCode, retMsg, retType, s2c } = res
console.log("GetInstitutionList: 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);
}
QotGetInstitutionList()
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
GetInstitutionList: errCode 0, retMsg , retType 0
{
"allCount": 17031,
"currency": "USD",
"dataList": [
{ "institutionId": 403413, "institutionName": "贝莱德", "positionValue": 7040103000000.0 },
{ "institutionId": 1951572549, "institutionName": "Vanguard Capital Management, LLC", "positionValue": 4944657000000.0 },
{ "institutionId": 823170, "institutionName": "道富", "positionValue": 3363354000000.0 }
]
}
2
3
4
5
6
7
8
9
10
API Limits
- Maximum 60 requests within 30 seconds
- Only the first page of paginated requests counts towards rate limiting
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_institution_list(market, sort_field=None, sort_dir=None, count=None, page=None, name_part=None)
Description
Get institution list, returning a list of institutions ranked by position value/position change/holding count in a specified market, supporting fuzzy search and cursor pagination.
Parameters
Parameter Type Description market Market Market type (HK/US) (required) sort_field InstitutionListSortField Sort field, default position value sort_dir RankSortDir Sort direction, default descending count int Return count [1, 200], default 20 page str Page cursor, do not provide for first request, pass next_page from previous response name_part str Institution name fuzzy search Return
Parameter Type Description ret RET_CODE API call result data pd.DataFrame When ret == RET_OK, returns data str When ret != RET_OK, returns error description - Data format:
Field Type Description institution_id int Institution ID institution_name str Institution name position_value float Position value position_value_change float Position value change position_count int Position stock count position_count_change int Position stock count change disclosure_date str Disclosure date (yyyy-MM-dd) currency str Currency
- Data format:
Example
from futu import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data, next_page, all_count = quote_ctx.get_institution_list(market=Market.US, count=2)
if ret == RET_OK:
print(f'Total count: {all_count}')
print(data)
else:
print('error:', data)
quote_ctx.close()
2
3
4
5
6
7
8
9
10
11
12
- Output
Total count: 17030
institution_id institution_name position_value position_value_change position_count position_count_change disclosure_date currency
0 403413 贝莱德 6.959193e+12 3.432083e+10 4443 56 2026-06-19 USD
1 1951572549 Vanguard Capital Management, LLC 4.881261e+12 4.492246e+12 4289 3859 2026-06-10 USD
2
3
4
# Qot_GetInstitutionList.proto
Description
Get institution list. Returns the institution list ranked by dimensions such as holding market value/position changes/holding stock count in the specified market, with support for fuzzy search and cursor-based pagination.
Parameters
// Sort field
enum SortField {
SortField_Unknown = 0; // Default (holding market value)
SortField_PositionValue = 1; // Holding market value
SortField_PositionValueChange = 2; // Position change
SortField_PositionCount = 3; // Holding shares
SortField_PositionCountChange = 4; // Holding shares change
}
// Sort direction
enum SortDir {
SortDir_Descending = 0; // Descending (default)
SortDir_Ascending = 1; // Ascending
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket
optional int32 sortField = 2; // SortField, default holding market value
optional int32 sortDir = 3; // SortDir, default descending
optional int32 count = 4; // Count [1,200], default 20
optional string page = 5; // Page cursor, omit for first request, pass nextPage from S2C for next page
optional string namePart = 6; // Institution name fuzzy search
}
// Institution list data item
message InstitutionListItem {
required int32 institutionId = 1; // Institution ID
optional string institutionName = 2; // Institution name
optional double positionValue = 3; // Holding market value
optional double positionValueChange = 4;// Holding market value change
optional int32 positionCount = 5; // Number of holding stocks
optional int32 positionCountChange = 6; // Number of holding stocks change
optional string disclosureDate = 7; // Disclosure date (yyyy-MM-dd)
}
message S2C {
repeated InstitutionListItem dataList = 1; // Data list
optional int32 allCount = 2; // Total count
optional string nextPage = 3; // Next page cursor, empty=no more
optional string currency = 4; // Currency
}
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
Protocol ID
3418
uint GetInstitutionList(Qot_GetInstitutionList.Request req);
virtual void OnReply_GetInstitutionList(FTAPI_Conn client, uint nSerialNo, Qot_GetInstitutionList.Response rsp);
Description
Get institution list. Returns the institution list ranked by dimensions such as holding market value/position changes/holding stock count in the specified market, with support for fuzzy search and cursor-based pagination.
Parameters
// Sort field
enum SortField {
SortField_Unknown = 0; // Default (holding market value)
SortField_PositionValue = 1; // Holding market value
SortField_PositionValueChange = 2; // Position change
SortField_PositionCount = 3; // Holding shares
SortField_PositionCountChange = 4; // Holding shares change
}
// Sort direction
enum SortDir {
SortDir_Descending = 0; // Descending (default)
SortDir_Ascending = 1; // Ascending
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket
optional int32 sortField = 2; // SortField, default holding market value
optional int32 sortDir = 3; // SortDir, default descending
optional int32 count = 4; // Count [1,200], default 20
optional string page = 5; // Page cursor, omit for first request, pass nextPage from S2C for next page
optional string namePart = 6; // Institution name fuzzy search
}
// Institution list data item
message InstitutionListItem {
required int32 institutionId = 1; // Institution ID
optional string institutionName = 2; // Institution name
optional double positionValue = 3; // Holding market value
optional double positionValueChange = 4;// Holding market value change
optional int32 positionCount = 5; // Number of holding stocks
optional int32 positionCountChange = 6; // Number of holding stocks change
optional string disclosureDate = 7; // Disclosure date (yyyy-MM-dd)
}
message S2C {
repeated InstitutionListItem dataList = 1; // Data list
optional int32 allCount = 2; // Total count
optional string nextPage = 3; // Next page cursor, empty=no more
optional string currency = 4; // Currency
}
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
- For interface result, refer to RetType
Protocol ID
3418
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;
QotGetInstitutionList.C2S c2s = QotGetInstitutionList.C2S.CreateBuilder()
.SetMarket(11)
.SetCount(3)
.Build();
QotGetInstitutionList.Request req = QotGetInstitutionList.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetInstitutionList(req);
Console.Write("Send QotGetInstitutionList: {0}
", seqNo);
}
public void OnDisconnect(MMAPI_Conn client, long errCode) {
Console.Write("Qot onDisConnect: {0}
", errCode);
}
public void OnReply_GetInstitutionList(MMAPI_Conn client, uint nSerialNo, QotGetInstitutionList.Response rsp)
{
Console.Write("Reply: QotGetInstitutionList: {0}
", nSerialNo);
if (rsp.RetType == 0 && rsp.HasS2C)
Console.Write("{0}
", rsp.ToString());
}
public static void Main(String[] args) {
MMAPI.Init();
Program program = new Program();
program.Start();
while (true)
Thread.Sleep(1000 * 600);
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
- Output
Send QotGetInstitutionList: 3
Reply: QotGetInstitutionList: 3
GetInstitutionList: errCode 0, retMsg , retType 0
{
"allCount": 17031,
"currency": "USD",
"dataList": [
{ "institutionId": 403413, "institutionName": "贝莱德", "positionValue": 7040103000000.0 },
{ "institutionId": 1951572549, "institutionName": "Vanguard Capital Management, LLC", "positionValue": 4944657000000.0 },
{ "institutionId": 823170, "institutionName": "道富", "positionValue": 3363354000000.0 }
]
}
2
3
4
5
6
7
8
9
10
11
12
int getInstitutionList(Qot_GetInstitutionList.Request req);
onReply_GetInstitutionList(FTAPI_Conn client, int nSerialNo, Qot_GetInstitutionList.Response rsp)
Description
Get institution list. Returns the institution list ranked by dimensions such as holding market value/position changes/holding stock count in the specified market, with support for fuzzy search and cursor-based pagination.
Parameters
// Sort field
enum SortField {
SortField_Unknown = 0; // Default (holding market value)
SortField_PositionValue = 1; // Holding market value
SortField_PositionValueChange = 2; // Position change
SortField_PositionCount = 3; // Holding shares
SortField_PositionCountChange = 4; // Holding shares change
}
// Sort direction
enum SortDir {
SortDir_Descending = 0; // Descending (default)
SortDir_Ascending = 1; // Ascending
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket
optional int32 sortField = 2; // SortField, default holding market value
optional int32 sortDir = 3; // SortDir, default descending
optional int32 count = 4; // Count [1,200], default 20
optional string page = 5; // Page cursor, omit for first request, pass nextPage from S2C for next page
optional string namePart = 6; // Institution name fuzzy search
}
// Institution list data item
message InstitutionListItem {
required int32 institutionId = 1; // Institution ID
optional string institutionName = 2; // Institution name
optional double positionValue = 3; // Holding market value
optional double positionValueChange = 4;// Holding market value change
optional int32 positionCount = 5; // Number of holding stocks
optional int32 positionCountChange = 6; // Number of holding stocks change
optional string disclosureDate = 7; // Disclosure date (yyyy-MM-dd)
}
message S2C {
repeated InstitutionListItem dataList = 1; // Data list
optional int32 allCount = 2; // Total count
optional string nextPage = 3; // Next page cursor, empty=no more
optional string currency = 4; // Currency
}
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
- For interface result, refer to RetType
Protocol ID
3418
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;
QotGetInstitutionList.C2S c2s = QotGetInstitutionList.C2S.newBuilder()
.setMarket(11)
.setCount(3)
.build();
QotGetInstitutionList.Request req = QotGetInstitutionList.Request.newBuilder().setC2S(c2s).build();
int seqNo = qot.getInstitutionList(req);
System.out.printf("Send QotGetInstitutionList: %d
", seqNo);
}
@Override
public void onDisconnect(MMAPI_Conn client, long errCode) {
System.out.printf("Qot onDisConnect: %d
", errCode);
}
@Override
public void onReply_GetInstitutionList(MMAPI_Conn client, int nSerialNo, QotGetInstitutionList.Response rsp) {
if (rsp.getRetType() != 0) {
System.out.printf("QotGetInstitutionList failed: %s
", rsp.getRetMsg());
} else {
try {
String json = JsonFormat.printer().print(rsp);
System.out.printf("Receive QotGetInstitutionList: %s
", json);
} catch (InvalidProtocolBufferException e) {
e.printStackTrace();
}
}
}
public static void main(String[] args) {
MMAPI.init();
QotDemo qot = new QotDemo();
qot.start();
while (true) {
try {
Thread.sleep(1000 * 600);
} catch (InterruptedException exc) {
}
}
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
- Output
Send QotGetInstitutionList: 3
Receive QotGetInstitutionList: {
"allCount": 17031,
"currency": "USD",
"dataList": [
{ "institutionId": 403413, "institutionName": "贝莱德", "positionValue": 7040103000000.0 },
{ "institutionId": 1951572549, "institutionName": "Vanguard Capital Management, LLC", "positionValue": 4944657000000.0 },
{ "institutionId": 823170, "institutionName": "道富", "positionValue": 3363354000000.0 }
]
}
2
3
4
5
6
7
8
9
10
moomoo::u32_t GetInstitutionList(const Qot_GetInstitutionList::Request &stReq);
virtual void OnReply_GetInstitutionList(moomoo::u32_t nSerialNo, const Qot_GetInstitutionList::Response &stRsp) = 0;
Description
Protocol request and response definition
Parameters
// Sort field
enum SortField {
SortField_Unknown = 0; // Default (holding market value)
SortField_PositionValue = 1; // Holding market value
SortField_PositionValueChange = 2; // Position change
SortField_PositionCount = 3; // Holding shares
SortField_PositionCountChange = 4; // Holding shares change
}
// Sort direction
enum SortDir {
SortDir_Descending = 0; // Descending (default)
SortDir_Ascending = 1; // Ascending
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket
optional int32 sortField = 2; // SortField, default holding market value
optional int32 sortDir = 3; // SortDir, default descending
optional int32 count = 4; // Count [1,200], default 20
optional string page = 5; // Page cursor, omit for first request, pass nextPage from S2C for next page
optional string namePart = 6; // Institution name fuzzy search
}
// Institution list data item
message InstitutionListItem {
required int32 institutionId = 1; // Institution ID
optional string institutionName = 2; // Institution name
optional double positionValue = 3; // Holding market value
optional double positionValueChange = 4;// Holding market value change
optional int32 positionCount = 5; // Number of holding stocks
optional int32 positionCountChange = 6; // Number of holding stocks change
optional string disclosureDate = 7; // Disclosure date (yyyy-MM-dd)
}
message S2C {
repeated InstitutionListItem dataList = 1; // Data list
optional int32 allCount = 2; // Total count
optional string nextPage = 3; // Next page cursor, empty=no more
optional string currency = 4; // Currency
}
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
- For interface result, refer to RetType
Protocol ID
3418
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_GetInstitutionList::Request req;
Qot_GetInstitutionList::C2S *c2s = req.mutable_c2s();
c2s->set_market(Qot_Common::QotMarket::QotMarket_US_Security);
c2s->set_count(20);
m_GetInstitutionListSerialNo = m_pQotApi->GetInstitutionList(req);
}
virtual void OnReply_GetInstitutionList(moomoo::u32_t nSerialNo, const Qot_GetInstitutionList::Response &stRsp) {
if (nSerialNo != m_GetInstitutionListSerialNo) return;
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
MMAPI_Qot *m_pQotApi;
moomoo::u32_t m_GetInstitutionListSerialNo = 0;
};
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
- Output
{
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"dataList": [
{
"institutionId": 1001,
"institutionName": "Vanguard Group",
"positionValue": 8500000000000.0,
"positionCount": 3850,
"disclosureDate": "2024-03-31"
}
],
"allCount": 100,
"currency": "USD"
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
getInstitutionList(qotGetInstitutionList)
Description
Get institution list. Returns the institution list ranked by dimensions such as holding market value/position changes/holding stock count in the specified market, with support for fuzzy search and cursor-based pagination.
Parameters
// Sort field
enum SortField {
SortField_Unknown = 0; // Default (holding market value)
SortField_PositionValue = 1; // Holding market value
SortField_PositionValueChange = 2; // Position change
SortField_PositionCount = 3; // Holding shares
SortField_PositionCountChange = 4; // Holding shares change
}
// Sort direction
enum SortDir {
SortDir_Descending = 0; // Descending (default)
SortDir_Ascending = 1; // Ascending
}
message C2S {
required int32 market = 1; // Qot_Common.QotMarket
optional int32 sortField = 2; // SortField, default holding market value
optional int32 sortDir = 3; // SortDir, default descending
optional int32 count = 4; // Count [1,200], default 20
optional string page = 5; // Page cursor, omit for first request, pass nextPage from S2C for next page
optional string namePart = 6; // Institution name fuzzy search
}
// Institution list data item
message InstitutionListItem {
required int32 institutionId = 1; // Institution ID
optional string institutionName = 2; // Institution name
optional double positionValue = 3; // Holding market value
optional double positionValueChange = 4;// Holding market value change
optional int32 positionCount = 5; // Number of holding stocks
optional int32 positionCountChange = 6; // Number of holding stocks change
optional string disclosureDate = 7; // Disclosure date (yyyy-MM-dd)
}
message S2C {
repeated InstitutionListItem dataList = 1; // Data list
optional int32 allCount = 2; // Total count
optional string nextPage = 3; // Next page cursor, empty=no more
optional string currency = 4; // Currency
}
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
- For interface result, refer to RetType
Protocol ID
3418
Example
import mmWebsocket from "moomoo-api";
import { Common, Qot_Common } from "moomoo-api/proto";
import beautify from "js-beautify";
function QotGetInstitutionList(){
const { RetType } = Common
let [addr, port, enable_ssl, key] = ["127.0.0.1", 11111, false, "xxxxxx"];
let websocket = new mmWebsocket();
websocket.onlogin = (ret, msg)=>{
if (ret) {
const req = {
c2s: { market: 11, count: 3 },
};
websocket.GetInstitutionList(req)
.then((res)=>{
let { errCode, retMsg, retType, s2c } = res
console.log("GetInstitutionList: 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);
}
QotGetInstitutionList()
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
GetInstitutionList: errCode 0, retMsg , retType 0
{
"allCount": 17031,
"currency": "USD",
"dataList": [
{ "institutionId": 403413, "institutionName": "贝莱德", "positionValue": 7040103000000.0 },
{ "institutionId": 1951572549, "institutionName": "Vanguard Capital Management, LLC", "positionValue": 4944657000000.0 },
{ "institutionId": 823170, "institutionName": "道富", "positionValue": 3363354000000.0 }
]
}
2
3
4
5
6
7
8
9
10
API Limits
- Maximum 60 requests within 30 seconds
- Only the first page of paginated requests counts towards rate limiting