# 相場銘柄検索
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_search_quote(keyword, max_count=10)
説明
キーワードで相場銘柄を検索し、一致する銘柄リストを返します。
パラメータ
パラメータ 型 説明 keyword str 検索キーワード max_count int 今回のリクエストで返す最大件数 デフォルト10件、最大100件戻り値
パラメータ 型 説明 ret RET_CODE API呼び出し結果 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; //検索キーワード
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; //銘柄コード
optional string name = 3; //銘柄名称
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
- API呼び出し結果の構造体: 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; //検索キーワード
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; //銘柄コード
optional string name = 3; //銘柄名称
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
- API呼び出し結果の構造体: 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; //検索キーワード
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; //銘柄コード
optional string name = 3; //銘柄名称
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
- API呼び出し結果の構造体: 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; //検索キーワード
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; //銘柄コード
optional string name = 3; //銘柄名称
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
- API呼び出し結果の構造体: 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; //検索キーワード
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; //銘柄コード
optional string name = 3; //銘柄名称
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
- API呼び出し結果の構造体: 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制限
- 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 API呼び出し結果 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; //検索キーワード
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; //銘柄コード
optional string name = 3; //銘柄名称
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
- API呼び出し結果の構造体: 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; //検索キーワード
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; //銘柄コード
optional string name = 3; //銘柄名称
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
- API呼び出し結果の構造体: 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; //検索キーワード
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; //銘柄コード
optional string name = 3; //銘柄名称
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
- API呼び出し結果の構造体: 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; //検索キーワード
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; //銘柄コード
optional string name = 3; //銘柄名称
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
- API呼び出し結果の構造体: 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; //検索キーワード
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; //銘柄コード
optional string name = 3; //銘柄名称
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
- API呼び出し結果の構造体: 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制限
- 30秒あたり相場銘柄検索は最大10回まで。
← 取引カレンダーの取得 ニュース検索 →