# 搜索行情標的
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_search_quote(keyword, max_count=10)
介紹
按關鍵詞搜索行情標的,返回匹配的標的列表。
參數
參數 類型 說明 keyword str 搜索詞 max_count int 本次請求的最大返回條數 默認10條,最大100條返回
參數 類型 說明 ret RET_CODE 接口調用結果 data pd.DataFrame 當 ret == RET_OK,返回搜索行情列表 str 當 ret != RET_OK,返回錯誤描述 DataFrame 欄位說明:
欄位 類型 說明 market Market 市場類型 code str 股票代碼 name str 股票名稱 sec_type SecurityType 股票類型 is_watched bool 是否已在自選
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() # 結束後記得關閉當條連接,防止連接條數用盡
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
介紹
按關鍵詞搜索行情標的,返回匹配的標的列表。
參數
message C2S
{
required string keyword = 1; //搜索詞,如 lite
optional int32 max_count = 2; //本次請求的最大返回條數,默認10條,最大100條
optional Qot_Common.QotHeader header = 100; //行情公共參數頭
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 返回
message SearchQuote
{
optional int32 market = 1; //Qot_Common.QotMarket,市場類型
optional string code = 2; //股票代碼,如 LITE / 01936
optional string name = 3; //股票名稱,如 Lumentum / 利特米
optional int32 sec_type = 4; //Qot_Common.SecurityType,股票類型
optional bool is_watched = 5; //是否已在自選
}
message S2C
{
repeated SearchQuote searchQuoteList = 1; //搜索行情列表
}
message Response
{
required int32 retType = 1 [default = -400]; //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
- 行情市場參見 QotMarket
- 股票類型參見 SecurityType
- 接口調用結果,結構參見 RetType
協議 ID
3262
uint GetSearchQuote(QotGetSearchQuote.Request req);
virtual void OnReply_GetSearchQuote(FTAPI_Conn client, uint nSerialNo, QotGetSearchQuote.Response rsp);
介紹
按關鍵詞搜索行情標的,返回匹配的標的列表。
參數
message C2S
{
required string keyword = 1; //搜索詞,如 lite
optional int32 max_count = 2; //本次請求的最大返回條數,默認10條,最大100條
optional Qot_Common.QotHeader header = 100; //行情公共參數頭
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 返回
message SearchQuote
{
optional int32 market = 1; //Qot_Common.QotMarket,市場類型
optional string code = 2; //股票代碼,如 LITE / 01936
optional string name = 3; //股票名稱,如 Lumentum / 利特米
optional int32 sec_type = 4; //Qot_Common.SecurityType,股票類型
optional bool is_watched = 5; //是否已在自選
}
message S2C
{
repeated SearchQuote searchQuoteList = 1; //搜索行情列表
}
message Response
{
required int32 retType = 1 [default = -400]; //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
- 行情市場參見 QotMarket
- 股票類型參見 SecurityType
- 接口調用結果,結構參見 RetType
- Example
- Output
int getSearchQuote(QotGetSearchQuote.Request req);
void onReply_GetSearchQuote(FTAPI_Conn client, int nSerialNo, QotGetSearchQuote.Response rsp);
介紹
按關鍵詞搜索行情標的,返回匹配的標的列表。
參數
message C2S
{
required string keyword = 1; //搜索詞,如 lite
optional int32 max_count = 2; //本次請求的最大返回條數,默認10條,最大100條
optional Qot_Common.QotHeader header = 100; //行情公共參數頭
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 返回
message SearchQuote
{
optional int32 market = 1; //Qot_Common.QotMarket,市場類型
optional string code = 2; //股票代碼,如 LITE / 01936
optional string name = 3; //股票名稱,如 Lumentum / 利特米
optional int32 sec_type = 4; //Qot_Common.SecurityType,股票類型
optional bool is_watched = 5; //是否已在自選
}
message S2C
{
repeated SearchQuote searchQuoteList = 1; //搜索行情列表
}
message Response
{
required int32 retType = 1 [default = -400]; //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
- 行情市場參見 QotMarket
- 股票類型參見 SecurityType
- 接口調用結果,結構參見 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;
介紹
按關鍵詞搜索行情標的,返回匹配的標的列表。
參數
message C2S
{
required string keyword = 1; //搜索詞,如 lite
optional int32 max_count = 2; //本次請求的最大返回條數,默認10條,最大100條
optional Qot_Common.QotHeader header = 100; //行情公共參數頭
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 返回
message SearchQuote
{
optional int32 market = 1; //Qot_Common.QotMarket,市場類型
optional string code = 2; //股票代碼,如 LITE / 01936
optional string name = 3; //股票名稱,如 Lumentum / 利特米
optional int32 sec_type = 4; //Qot_Common.SecurityType,股票類型
optional bool is_watched = 5; //是否已在自選
}
message S2C
{
repeated SearchQuote searchQuoteList = 1; //搜索行情列表
}
message Response
{
required int32 retType = 1 [default = -400]; //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
- 行情市場參見 QotMarket
- 股票類型參見 SecurityType
- 接口調用結果,結構參見 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);
介紹
按關鍵詞搜索行情標的,返回匹配的標的列表。
參數
message C2S
{
required string keyword = 1; //搜索詞,如 lite
optional int32 max_count = 2; //本次請求的最大返回條數,默認10條,最大100條
optional Qot_Common.QotHeader header = 100; //行情公共參數頭
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 返回
message SearchQuote
{
optional int32 market = 1; //Qot_Common.QotMarket,市場類型
optional string code = 2; //股票代碼,如 LITE / 01936
optional string name = 3; //股票名稱,如 Lumentum / 利特米
optional int32 sec_type = 4; //Qot_Common.SecurityType,股票類型
optional bool is_watched = 5; //是否已在自選
}
message S2C
{
repeated SearchQuote searchQuoteList = 1; //搜索行情列表
}
message Response
{
required int32 retType = 1 [default = -400]; //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
- 行情市場參見 QotMarket
- 股票類型參見 SecurityType
- 接口調用結果,結構參見 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
接口限制
- 每 30 秒內最多請求 10 次搜索行情標的接口。
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_search_quote(keyword, max_count=10)
介紹
按關鍵詞搜索行情標的,返回匹配的標的列表。
參數
參數 類型 說明 keyword str 搜索詞 max_count int 本次請求的最大返回條數 默認10條,最大100條返回
參數 類型 說明 ret RET_CODE 接口調用結果 data pd.DataFrame 當 ret == RET_OK,返回搜索行情列表 str 當 ret != RET_OK,返回錯誤描述 DataFrame 欄位說明:
欄位 類型 說明 market Market 市場類型 code str 股票代碼 name str 股票名稱 sec_type SecurityType 股票類型 is_watched bool 是否已在自選
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() # 結束後記得關閉當條連接,防止連接條數用盡
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
介紹
按關鍵詞搜索行情標的,返回匹配的標的列表。
參數
message C2S
{
required string keyword = 1; //搜索詞,如 lite
optional int32 max_count = 2; //本次請求的最大返回條數,默認10條,最大100條
optional Qot_Common.QotHeader header = 100; //行情公共參數頭
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 返回
message SearchQuote
{
optional int32 market = 1; //Qot_Common.QotMarket,市場類型
optional string code = 2; //股票代碼,如 LITE / 01936
optional string name = 3; //股票名稱,如 Lumentum / 利特米
optional int32 sec_type = 4; //Qot_Common.SecurityType,股票類型
optional bool is_watched = 5; //是否已在自選
}
message S2C
{
repeated SearchQuote searchQuoteList = 1; //搜索行情列表
}
message Response
{
required int32 retType = 1 [default = -400]; //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
- 行情市場參見 QotMarket
- 股票類型參見 SecurityType
- 接口調用結果,結構參見 RetType
協議 ID
3262
uint GetSearchQuote(QotGetSearchQuote.Request req);
virtual void OnReply_GetSearchQuote(MMAPI_Conn client, uint nSerialNo, QotGetSearchQuote.Response rsp);
介紹
按關鍵詞搜索行情標的,返回匹配的標的列表。
參數
message C2S
{
required string keyword = 1; //搜索詞,如 lite
optional int32 max_count = 2; //本次請求的最大返回條數,默認10條,最大100條
optional Qot_Common.QotHeader header = 100; //行情公共參數頭
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 返回
message SearchQuote
{
optional int32 market = 1; //Qot_Common.QotMarket,市場類型
optional string code = 2; //股票代碼,如 LITE / 01936
optional string name = 3; //股票名稱,如 Lumentum / 利特米
optional int32 sec_type = 4; //Qot_Common.SecurityType,股票類型
optional bool is_watched = 5; //是否已在自選
}
message S2C
{
repeated SearchQuote searchQuoteList = 1; //搜索行情列表
}
message Response
{
required int32 retType = 1 [default = -400]; //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
- 行情市場參見 QotMarket
- 股票類型參見 SecurityType
- 接口調用結果,結構參見 RetType
- Example
- Output
int getSearchQuote(QotGetSearchQuote.Request req);
void onReply_GetSearchQuote(MMAPI_Conn client, int nSerialNo, QotGetSearchQuote.Response rsp);
介紹
按關鍵詞搜索行情標的,返回匹配的標的列表。
參數
message C2S
{
required string keyword = 1; //搜索詞,如 lite
optional int32 max_count = 2; //本次請求的最大返回條數,默認10條,最大100條
optional Qot_Common.QotHeader header = 100; //行情公共參數頭
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 返回
message SearchQuote
{
optional int32 market = 1; //Qot_Common.QotMarket,市場類型
optional string code = 2; //股票代碼,如 LITE / 01936
optional string name = 3; //股票名稱,如 Lumentum / 利特米
optional int32 sec_type = 4; //Qot_Common.SecurityType,股票類型
optional bool is_watched = 5; //是否已在自選
}
message S2C
{
repeated SearchQuote searchQuoteList = 1; //搜索行情列表
}
message Response
{
required int32 retType = 1 [default = -400]; //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
- 行情市場參見 QotMarket
- 股票類型參見 SecurityType
- 接口調用結果,結構參見 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;
介紹
按關鍵詞搜索行情標的,返回匹配的標的列表。
參數
message C2S
{
required string keyword = 1; //搜索詞,如 lite
optional int32 max_count = 2; //本次請求的最大返回條數,默認10條,最大100條
optional Qot_Common.QotHeader header = 100; //行情公共參數頭
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 返回
message SearchQuote
{
optional int32 market = 1; //Qot_Common.QotMarket,市場類型
optional string code = 2; //股票代碼,如 LITE / 01936
optional string name = 3; //股票名稱,如 Lumentum / 利特米
optional int32 sec_type = 4; //Qot_Common.SecurityType,股票類型
optional bool is_watched = 5; //是否已在自選
}
message S2C
{
repeated SearchQuote searchQuoteList = 1; //搜索行情列表
}
message Response
{
required int32 retType = 1 [default = -400]; //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
- 行情市場參見 QotMarket
- 股票類型參見 SecurityType
- 接口調用結果,結構參見 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);
介紹
按關鍵詞搜索行情標的,返回匹配的標的列表。
參數
message C2S
{
required string keyword = 1; //搜索詞,如 lite
optional int32 max_count = 2; //本次請求的最大返回條數,默認10條,最大100條
optional Qot_Common.QotHeader header = 100; //行情公共參數頭
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 返回
message SearchQuote
{
optional int32 market = 1; //Qot_Common.QotMarket,市場類型
optional string code = 2; //股票代碼,如 LITE / 01936
optional string name = 3; //股票名稱,如 Lumentum / 利特米
optional int32 sec_type = 4; //Qot_Common.SecurityType,股票類型
optional bool is_watched = 5; //是否已在自選
}
message S2C
{
repeated SearchQuote searchQuoteList = 1; //搜索行情列表
}
message Response
{
required int32 retType = 1 [default = -400]; //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
- 行情市場參見 QotMarket
- 股票類型參見 SecurityType
- 接口調用結果,結構參見 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
接口限制
- 每 30 秒內最多請求 10 次搜索行情標的接口。