# Search Quotes
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_search_quote(keyword, max_count=10)
Description
Search quotes by keyword and return a list of matched securities.
Parameters
Parameter Type Description keyword str Search keyword max_count int Maximum number of items returned in this request Default 10, maximum 100Return
Parameter Type Description ret RET_CODE API call result data pd.DataFrame When ret == RET_OK, returns search quote list str When ret != RET_OK, returns error description DataFrame fields:
Field Type Description market Market Market type code str Stock code name str Stock name sec_type SecurityType Stock type is_watched bool In watchlist
Example
from futu import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data = quote_ctx.get_search_quote('aapl',10)
if ret == RET_OK:
print(data)
else:
print('error:', data)
quote_ctx.close() # Remember to close the connection to avoid exhausting connection quota
2
3
4
5
6
7
8
- Output
market code name sec_type is_watched
0 US US.AAPL 苹果 STOCK True
1 US US.AAPB 2倍做多AAPL ETF-GraniteShares ETF False
2 US US.LIST2139 虚拟现实 PLATE False
3 US US.LIST2432 流媒体概念 PLATE False
4 US US.LIST2437 苹果概念 PLATE False
5 JP JP.2788 Apple International STOCK False
6 US US.AAPI APPLE ISPORTS GROUP INC STOCK False
7 SH SH.603020 爱普股份 STOCK False
8 US US.APLY AAPL期权收益策略ETF-YieldMax ETF False
9 US US.APRU APPLE RUSH COMPANY INC STOCK False
2
3
4
5
6
7
8
9
10
11
# Qot_GetSearchQuote.proto
Description
Search quotes by keyword and return a list of matched securities.
Parameters
message C2S
{
required string keyword = 1; //Search keyword
optional int32 max_count = 2; //Maximum items returned in this request, default 10, maximum 100
optional Qot_Common.QotHeader header = 100; //Quote common header
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- Return
message SearchQuote
{
optional int32 market = 1; //Qot_Common.QotMarket,Market type
optional string code = 2; //Stock code
optional string name = 3; //Stock name
optional int32 sec_type = 4; //Qot_Common.SecurityType,Stock type
optional bool is_watched = 5; //In watchlist
}
message S2C
{
repeated SearchQuote searchQuoteList = 1; //Search quote list
}
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
- Quote market: QotMarket
- Stock type: SecurityType
- API call result structure: RetType
Protocol ID
3262
uint GetSearchQuote(QotGetSearchQuote.Request req);
virtual void OnReply_GetSearchQuote(FTAPI_Conn client, uint nSerialNo, QotGetSearchQuote.Response rsp);
Description
Search quotes by keyword and return a list of matched securities.
Parameters
message C2S
{
required string keyword = 1; //Search keyword
optional int32 max_count = 2; //Maximum items returned in this request, default 10, maximum 100
optional Qot_Common.QotHeader header = 100; //Quote common header
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- Return
message SearchQuote
{
optional int32 market = 1; //Qot_Common.QotMarket,Market type
optional string code = 2; //Stock code
optional string name = 3; //Stock name
optional int32 sec_type = 4; //Qot_Common.SecurityType,Stock type
optional bool is_watched = 5; //In watchlist
}
message S2C
{
repeated SearchQuote searchQuoteList = 1; //Search quote list
}
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
- Quote market: QotMarket
- Stock type: SecurityType
- API call result structure: RetType
- Example
- Output
int getSearchQuote(QotGetSearchQuote.Request req);
void onReply_GetSearchQuote(FTAPI_Conn client, int nSerialNo, QotGetSearchQuote.Response rsp);
Description
Search quotes by keyword and return a list of matched securities.
Parameters
message C2S
{
required string keyword = 1; //Search keyword
optional int32 max_count = 2; //Maximum items returned in this request, default 10, maximum 100
optional Qot_Common.QotHeader header = 100; //Quote common header
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- Return
message SearchQuote
{
optional int32 market = 1; //Qot_Common.QotMarket,Market type
optional string code = 2; //Stock code
optional string name = 3; //Stock name
optional int32 sec_type = 4; //Qot_Common.SecurityType,Stock type
optional bool is_watched = 5; //In watchlist
}
message S2C
{
repeated SearchQuote searchQuoteList = 1; //Search quote list
}
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
- Quote market: QotMarket
- Stock type: SecurityType
- API call result structure: RetType
- Example
- Output
Futu::u32_t GetSearchQuote(const Qot_GetSearchQuote::Request &stReq);
virtual void OnReply_GetSearchQuote(Futu::u32_t nSerialNo, const Qot_GetSearchQuote::Response &stRsp) = 0;
Description
Search quotes by keyword and return a list of matched securities.
Parameters
message C2S
{
required string keyword = 1; //Search keyword
optional int32 max_count = 2; //Maximum items returned in this request, default 10, maximum 100
optional Qot_Common.QotHeader header = 100; //Quote common header
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- Return
message SearchQuote
{
optional int32 market = 1; //Qot_Common.QotMarket,Market type
optional string code = 2; //Stock code
optional string name = 3; //Stock name
optional int32 sec_type = 4; //Qot_Common.SecurityType,Stock type
optional bool is_watched = 5; //In watchlist
}
message S2C
{
repeated SearchQuote searchQuoteList = 1; //Search quote list
}
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
- Quote market: QotMarket
- Stock type: SecurityType
- API call result structure: RetType
- 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_GetSearchQuote::Request req;
Qot_GetSearchQuote::C2S *c2s = req.mutable_c2s();
c2s->set_keyword("lite");
c2s->set_max_count(10);
m_GetSearchQuoteSerialNo = m_pQotApi->GetSearchQuote(req);
}
virtual void OnReply_GetSearchQuote(Futu::u32_t nSerialNo, const Qot_GetSearchQuote::Response &stRsp) {
if (nSerialNo != m_GetSearchQuoteSerialNo) return;
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
FTAPI_Qot *m_pQotApi;
Futu::u32_t m_GetSearchQuoteSerialNo = 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
GetSearchQuote(req);
Description
Search quotes by keyword and return a list of matched securities.
Parameters
message C2S
{
required string keyword = 1; //Search keyword
optional int32 max_count = 2; //Maximum items returned in this request, default 10, maximum 100
optional Qot_Common.QotHeader header = 100; //Quote common header
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- Return
message SearchQuote
{
optional int32 market = 1; //Qot_Common.QotMarket,Market type
optional string code = 2; //Stock code
optional string name = 3; //Stock name
optional int32 sec_type = 4; //Qot_Common.SecurityType,Stock type
optional bool is_watched = 5; //In watchlist
}
message S2C
{
repeated SearchQuote searchQuoteList = 1; //Search quote list
}
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
- Quote market: QotMarket
- Stock type: SecurityType
- API call result structure: RetType
- Example
import ftWebsocket from "futu-api";
import { Common } from "futu-api/proto";
import beautify from "js-beautify";
function QotGetSearchQuote(){
const { RetType } = 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: {
keyword: "lite",
maxCount: 10,
},
};
websocket.GetSearchQuote(req)
.then((res) => {
let { errCode, retMsg, retType, s2c } = res
console.log("GetSearchQuote: 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);
}
QotGetSearchQuote()
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
API Restrictions
- Maximum 10 search quote requests per 30 seconds.
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_search_quote(keyword, max_count=10)
Description
Search quotes by keyword and return a list of matched securities.
Parameters
Parameter Type Description keyword str Search keyword max_count int Maximum number of items returned in this request Default 10, maximum 100Return
Parameter Type Description ret RET_CODE API call result data pd.DataFrame When ret == RET_OK, returns search quote list str When ret != RET_OK, returns error description DataFrame fields:
Field Type Description market Market Market type code str Stock code name str Stock name sec_type SecurityType Stock type is_watched bool In watchlist
Example
from moomoo import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data = quote_ctx.get_search_quote('aapl',10)
if ret == RET_OK:
print(data)
else:
print('error:', data)
quote_ctx.close() # Remember to close the connection to avoid exhausting connection quota
2
3
4
5
6
7
8
- Output
market code name sec_type is_watched
0 US US.AAPL 苹果 STOCK True
1 US US.AAPB 2倍做多AAPL ETF-GraniteShares ETF False
2 US US.LIST2139 虚拟现实 PLATE False
3 US US.LIST2432 流媒体概念 PLATE False
4 US US.LIST2437 苹果概念 PLATE False
5 JP JP.2788 Apple International STOCK False
6 US US.AAPI APPLE ISPORTS GROUP INC STOCK False
7 SH SH.603020 爱普股份 STOCK False
8 US US.APLY AAPL期权收益策略ETF-YieldMax ETF False
9 US US.APRU APPLE RUSH COMPANY INC STOCK False
2
3
4
5
6
7
8
9
10
11
# Qot_GetSearchQuote.proto
Description
Search quotes by keyword and return a list of matched securities.
Parameters
message C2S
{
required string keyword = 1; //Search keyword
optional int32 max_count = 2; //Maximum items returned in this request, default 10, maximum 100
optional Qot_Common.QotHeader header = 100; //Quote common header
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- Return
message SearchQuote
{
optional int32 market = 1; //Qot_Common.QotMarket,Market type
optional string code = 2; //Stock code
optional string name = 3; //Stock name
optional int32 sec_type = 4; //Qot_Common.SecurityType,Stock type
optional bool is_watched = 5; //In watchlist
}
message S2C
{
repeated SearchQuote searchQuoteList = 1; //Search quote list
}
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
- Quote market: QotMarket
- Stock type: SecurityType
- API call result structure: RetType
Protocol ID
3262
uint GetSearchQuote(QotGetSearchQuote.Request req);
virtual void OnReply_GetSearchQuote(MMAPI_Conn client, uint nSerialNo, QotGetSearchQuote.Response rsp);
Description
Search quotes by keyword and return a list of matched securities.
Parameters
message C2S
{
required string keyword = 1; //Search keyword
optional int32 max_count = 2; //Maximum items returned in this request, default 10, maximum 100
optional Qot_Common.QotHeader header = 100; //Quote common header
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- Return
message SearchQuote
{
optional int32 market = 1; //Qot_Common.QotMarket,Market type
optional string code = 2; //Stock code
optional string name = 3; //Stock name
optional int32 sec_type = 4; //Qot_Common.SecurityType,Stock type
optional bool is_watched = 5; //In watchlist
}
message S2C
{
repeated SearchQuote searchQuoteList = 1; //Search quote list
}
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
- Quote market: QotMarket
- Stock type: SecurityType
- API call result structure: RetType
- Example
- Output
int getSearchQuote(QotGetSearchQuote.Request req);
void onReply_GetSearchQuote(MMAPI_Conn client, int nSerialNo, QotGetSearchQuote.Response rsp);
Description
Search quotes by keyword and return a list of matched securities.
Parameters
message C2S
{
required string keyword = 1; //Search keyword
optional int32 max_count = 2; //Maximum items returned in this request, default 10, maximum 100
optional Qot_Common.QotHeader header = 100; //Quote common header
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- Return
message SearchQuote
{
optional int32 market = 1; //Qot_Common.QotMarket,Market type
optional string code = 2; //Stock code
optional string name = 3; //Stock name
optional int32 sec_type = 4; //Qot_Common.SecurityType,Stock type
optional bool is_watched = 5; //In watchlist
}
message S2C
{
repeated SearchQuote searchQuoteList = 1; //Search quote list
}
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
- Quote market: QotMarket
- Stock type: SecurityType
- API call result structure: RetType
- Example
- Output
Futu::u32_t GetSearchQuote(const Qot_GetSearchQuote::Request &stReq);
virtual void OnReply_GetSearchQuote(Futu::u32_t nSerialNo, const Qot_GetSearchQuote::Response &stRsp) = 0;
Description
Search quotes by keyword and return a list of matched securities.
Parameters
message C2S
{
required string keyword = 1; //Search keyword
optional int32 max_count = 2; //Maximum items returned in this request, default 10, maximum 100
optional Qot_Common.QotHeader header = 100; //Quote common header
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- Return
message SearchQuote
{
optional int32 market = 1; //Qot_Common.QotMarket,Market type
optional string code = 2; //Stock code
optional string name = 3; //Stock name
optional int32 sec_type = 4; //Qot_Common.SecurityType,Stock type
optional bool is_watched = 5; //In watchlist
}
message S2C
{
repeated SearchQuote searchQuoteList = 1; //Search quote list
}
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
- Quote market: QotMarket
- Stock type: SecurityType
- API call result structure: RetType
- 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_GetSearchQuote::Request req;
Qot_GetSearchQuote::C2S *c2s = req.mutable_c2s();
c2s->set_keyword("lite");
c2s->set_max_count(10);
m_GetSearchQuoteSerialNo = m_pQotApi->GetSearchQuote(req);
}
virtual void OnReply_GetSearchQuote(Futu::u32_t nSerialNo, const Qot_GetSearchQuote::Response &stRsp) {
if (nSerialNo != m_GetSearchQuoteSerialNo) return;
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
FTAPI_Qot *m_pQotApi;
Futu::u32_t m_GetSearchQuoteSerialNo = 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
GetSearchQuote(req);
Description
Search quotes by keyword and return a list of matched securities.
Parameters
message C2S
{
required string keyword = 1; //Search keyword
optional int32 max_count = 2; //Maximum items returned in this request, default 10, maximum 100
optional Qot_Common.QotHeader header = 100; //Quote common header
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- Return
message SearchQuote
{
optional int32 market = 1; //Qot_Common.QotMarket,Market type
optional string code = 2; //Stock code
optional string name = 3; //Stock name
optional int32 sec_type = 4; //Qot_Common.SecurityType,Stock type
optional bool is_watched = 5; //In watchlist
}
message S2C
{
repeated SearchQuote searchQuoteList = 1; //Search quote list
}
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
- Quote market: QotMarket
- Stock type: SecurityType
- API call result structure: RetType
- Example
import mmWebsocket from "moomoo-api";
import { Common } from "moomoo-api/proto";
import beautify from "js-beautify";
function QotGetSearchQuote(){
const { RetType } = 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: {
keyword: "lite",
maxCount: 10,
},
};
websocket.GetSearchQuote(req)
.then((res) => {
let { errCode, retMsg, retType, s2c } = res
console.log("GetSearchQuote: 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);
}
QotGetSearchQuote()
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
API Restrictions
- Maximum 10 search quote requests per 30 seconds.