# 搜索資訊
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_search_news(keyword, max_count=10, news_sub_type=NewsSubType.ALL)
介紹
按關鍵詞搜索資訊,返回匹配的新聞、公告、評級等資訊列表。
參數
參數 類型 說明 keyword str 搜索詞 max_count int 本次請求的最大返回條數 默認10條,最大100條news_sub_type NewsSubType 資訊子類型 默認 NewsSubType.ALL返回
參數 類型 說明 ret RET_CODE 接口調用結果 data pd.DataFrame 當 ret == RET_OK,返回搜索資訊列表 str 當 ret != RET_OK,返回錯誤描述 DataFrame 欄位說明:
欄位 類型 說明 title str 標題 news_sub_type NewsSubType 資訊子類型 source str 來源 publish_time str 發佈時間 view_count int 瀏覽量 related_securities list 關聯標的列表 url str 詳情頁鏈接
Example
from futu import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data = quote_ctx.get_search_news('space', 10, news_sub_type=NewsSubType.ALL)
if ret == RET_OK:
print(data)
else:
print('error:', data)
quote_ctx.close() # 結束後記得關閉當條連接,防止連接條數用盡
2
3
4
5
6
7
8
- Output
title news_sub_type source publish_time view_count related_securities url
0 Space:2026年12月期 第一財季業績說明材料 NEWS 日本交易所 5/13 329 [] https://news.futunn.com/notice/307288728
1 Space:2026年12月期 第一財季業績簡報[日本會計準則](合併) NEWS 日本交易所 5/13 277 [] https://news.futunn.com/notice/307288725
2 SPACE CO., LTD. 第一季度盈利表現強勁,但全年利潤和股息預期下調。 NEWS TipRanks 5/13 201 [] https://news.futunn.com/post/73007255?futusour...
3 New Street Research 開始覆蓋太空經濟和基礎設施領域。 NEWS PR Newswire 5/14 6035 [] https://news.futunn.com/post/73047684?futusour...
4 Space:臨時報告書 NEWS 日本金融廳 3/27 257 [] https://news.futunn.com/notice/306761904
5 Gemini Space Station | 8-K:重大事件 NOTICE 美股SEC公告 6/16 278 [US.GEMI] https://news.futunn.com/notice/307532371?futus...
6 Extra Space Storage | 4:持股變動聲明-高管 McNeal Gwyn ... NOTICE 美股SEC公告 6/13 348 [US.EXR] https://news.futunn.com/notice/307521769?futus...
7 Space Exploration Technologies Corp:承保或代理協議 NOTICE SEDAR 6/12 400 [] https://news.futunn.com/notice/307519369?futus...
8 Space Exploration Technologies Corp:補充長期形式的預備招... NOTICE SEDAR 6/12 231 [] https://news.futunn.com/notice/307519371?futus...
9 Space Exploration Technologies Corp:補充長期形式的預備招... NOTICE SEDAR 6/12 210 [] https://news.futunn.com/notice/307519370?futus...
2
3
4
5
6
7
8
9
10
11
# Qot_GetSearchNews.proto
介紹
按關鍵詞搜索資訊。
參數
message C2S
{
required string keyword = 1; //搜索詞,如 lite
optional int32 max_count = 2; //本次請求的最大返回條數,默認10條,最大100條
optional int32 news_sub_type = 3; //NewsSubType,資訊子類型,默認 NewsSubType_ALL
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 資訊子類型枚舉參見 NewsSubType
- 返回
message SearchNews
{
optional string title = 1; //標題(含關鍵詞)
optional int32 news_sub_type = 2; //NewsSubType,資訊子類型
optional string source = 3; //來源,如 富途資訊 / MT Newswires / Benzinga
optional string publish_time = 4; //發佈時間
optional int64 view_count = 5; //瀏覽量
repeated string related_securities = 6; //關聯標的列表,如 LITE.US,用於跳轉
optional string url = 7; //詳情頁鏈接
}
message S2C
{
repeated SearchNews searchNewsList = 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
22
23
- 接口調用結果,結構參見 RetType
- 資訊子類型枚舉參見 NewsSubType
協議 ID
3263
uint GetSearchNews(QotGetSearchNews.Request req);
virtual void OnReply_GetSearchNews(FTAPI_Conn client, uint nSerialNo, QotGetSearchNews.Response rsp);
介紹
按關鍵詞搜索資訊。
參數
message C2S
{
required string keyword = 1; //搜索詞,如 lite
optional int32 max_count = 2; //本次請求的最大返回條數,默認10條,最大100條
optional int32 news_sub_type = 3; //NewsSubType,資訊子類型,默認 NewsSubType_ALL
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 資訊子類型枚舉參見 NewsSubType
- 返回
message SearchNews
{
optional string title = 1; //標題(含關鍵詞)
optional int32 news_sub_type = 2; //NewsSubType,資訊子類型
optional string source = 3; //來源,如 富途資訊 / MT Newswires / Benzinga
optional string publish_time = 4; //發佈時間
optional int64 view_count = 5; //瀏覽量
repeated string related_securities = 6; //關聯標的列表,如 LITE.US,用於跳轉
optional string url = 7; //詳情頁鏈接
}
message S2C
{
repeated SearchNews searchNewsList = 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
22
23
- 接口調用結果,結構參見 RetType
- 資訊子類型枚舉參見 NewsSubType
- Example
- Output
int getSearchNews(QotGetSearchNews.Request req);
void onReply_GetSearchNews(FTAPI_Conn client, int nSerialNo, QotGetSearchNews.Response rsp);
介紹
按關鍵詞搜索資訊。
參數
message C2S
{
required string keyword = 1; //搜索詞,如 lite
optional int32 max_count = 2; //本次請求的最大返回條數,默認10條,最大100條
optional int32 news_sub_type = 3; //NewsSubType,資訊子類型,默認 NewsSubType_ALL
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 資訊子類型枚舉參見 NewsSubType
- 返回
message SearchNews
{
optional string title = 1; //標題(含關鍵詞)
optional int32 news_sub_type = 2; //NewsSubType,資訊子類型
optional string source = 3; //來源,如 富途資訊 / MT Newswires / Benzinga
optional string publish_time = 4; //發佈時間
optional int64 view_count = 5; //瀏覽量
repeated string related_securities = 6; //關聯標的列表,如 LITE.US,用於跳轉
optional string url = 7; //詳情頁鏈接
}
message S2C
{
repeated SearchNews searchNewsList = 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
22
23
- 接口調用結果,結構參見 RetType
- 資訊子類型枚舉參見 NewsSubType
- Example
- Output
Futu::u32_t GetSearchNews(const Qot_GetSearchNews::Request &stReq);
virtual void OnReply_GetSearchNews(Futu::u32_t nSerialNo, const Qot_GetSearchNews::Response &stRsp) = 0;
介紹
按關鍵詞搜索資訊。
參數
message C2S
{
required string keyword = 1; //搜索詞,如 lite
optional int32 max_count = 2; //本次請求的最大返回條數,默認10條,最大100條
optional int32 news_sub_type = 3; //NewsSubType,資訊子類型,默認 NewsSubType_ALL
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 資訊子類型枚舉參見 NewsSubType
- 返回
message SearchNews
{
optional string title = 1; //標題(含關鍵詞)
optional int32 news_sub_type = 2; //NewsSubType,資訊子類型
optional string source = 3; //來源,如 富途資訊 / MT Newswires / Benzinga
optional string publish_time = 4; //發佈時間
optional int64 view_count = 5; //瀏覽量
repeated string related_securities = 6; //關聯標的列表,如 LITE.US,用於跳轉
optional string url = 7; //詳情頁鏈接
}
message S2C
{
repeated SearchNews searchNewsList = 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
22
23
- 接口調用結果,結構參見 RetType
- 資訊子類型枚舉參見 NewsSubType
- 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_GetSearchNews::Request req;
Qot_GetSearchNews::C2S *c2s = req.mutable_c2s();
c2s->set_keyword("space");
c2s->set_max_count(10);
c2s->set_news_sub_type(Qot_GetSearchNews::NewsSubType_ALL);
m_GetSearchNewsSerialNo = m_pQotApi->GetSearchNews(req);
}
virtual void OnReply_GetSearchNews(Futu::u32_t nSerialNo, const Qot_GetSearchNews::Response &stRsp) {
if (nSerialNo != m_GetSearchNewsSerialNo) return;
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
FTAPI_Qot *m_pQotApi;
Futu::u32_t m_GetSearchNewsSerialNo = 0;
};
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
GetSearchNews(req);
介紹
按關鍵詞搜索資訊。
參數
message C2S
{
required string keyword = 1; //搜索詞,如 lite
optional int32 max_count = 2; //本次請求的最大返回條數,默認10條,最大100條
optional int32 news_sub_type = 3; //NewsSubType,資訊子類型,默認 NewsSubType_ALL
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 資訊子類型枚舉參見 NewsSubType
- 返回
message SearchNews
{
optional string title = 1; //標題(含關鍵詞)
optional int32 news_sub_type = 2; //NewsSubType,資訊子類型
optional string source = 3; //來源,如 富途資訊 / MT Newswires / Benzinga
optional string publish_time = 4; //發佈時間
optional int64 view_count = 5; //瀏覽量
repeated string related_securities = 6; //關聯標的列表,如 LITE.US,用於跳轉
optional string url = 7; //詳情頁鏈接
}
message S2C
{
repeated SearchNews searchNewsList = 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
22
23
- 接口調用結果,結構參見 RetType
- 資訊子類型枚舉參見 NewsSubType
- Example
import ftWebsocket from "futu-api";
import { Common, Qot_GetSearchNews } from "futu-api/proto";
import beautify from "js-beautify";
function QotGetSearchNews(){
const { RetType } = Common
const { NewsSubType } = Qot_GetSearchNews
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: "space",
maxCount: 10,
newsSubType: NewsSubType.NewsSubType_ALL,
},
};
websocket.GetSearchNews(req)
.then((res) => {
let { errCode, retMsg, retType, s2c } = res
console.log("GetSearchNews: 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);
}
QotGetSearchNews()
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
接口限制
- 每 30 秒內最多請求 10 次搜索資訊接口。
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_search_news(keyword, max_count=10, news_sub_type=NewsSubType.ALL)
介紹
按關鍵詞搜索資訊,返回匹配的新聞、公告、評級等資訊列表。
參數
參數 類型 說明 keyword str 搜索詞 max_count int 本次請求的最大返回條數 默認10條,最大100條news_sub_type NewsSubType 資訊子類型 默認 NewsSubType.ALL返回
參數 類型 說明 ret RET_CODE 接口調用結果 data pd.DataFrame 當 ret == RET_OK,返回搜索資訊列表 str 當 ret != RET_OK,返回錯誤描述 DataFrame 欄位說明:
欄位 類型 說明 title str 標題 news_sub_type NewsSubType 資訊子類型 source str 來源 publish_time str 發佈時間 view_count int 瀏覽量 related_securities list 關聯標的列表 url str 詳情頁鏈接
Example
from moomoo import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data = quote_ctx.get_search_news('space', 10, news_sub_type=NewsSubType.ALL)
if ret == RET_OK:
print(data)
else:
print('error:', data)
quote_ctx.close() # 結束後記得關閉當條連接,防止連接條數用盡
2
3
4
5
6
7
8
- Output
title news_sub_type source publish_time view_count related_securities url
0 Space:2026年12月期 第一財季業績說明材料 NEWS 日本交易所 5/13 329 [] https://news.futunn.com/notice/307288728
1 Space:2026年12月期 第一財季業績簡報[日本會計準則](合併) NEWS 日本交易所 5/13 277 [] https://news.futunn.com/notice/307288725
2 SPACE CO., LTD. 第一季度盈利表現強勁,但全年利潤和股息預期下調。 NEWS TipRanks 5/13 201 [] https://news.futunn.com/post/73007255?futusour...
3 New Street Research 開始覆蓋太空經濟和基礎設施領域。 NEWS PR Newswire 5/14 6035 [] https://news.futunn.com/post/73047684?futusour...
4 Space:臨時報告書 NEWS 日本金融廳 3/27 257 [] https://news.futunn.com/notice/306761904
5 Gemini Space Station | 8-K:重大事件 NOTICE 美股SEC公告 6/16 278 [US.GEMI] https://news.futunn.com/notice/307532371?futus...
6 Extra Space Storage | 4:持股變動聲明-高管 McNeal Gwyn ... NOTICE 美股SEC公告 6/13 348 [US.EXR] https://news.futunn.com/notice/307521769?futus...
7 Space Exploration Technologies Corp:承保或代理協議 NOTICE SEDAR 6/12 400 [] https://news.futunn.com/notice/307519369?futus...
8 Space Exploration Technologies Corp:補充長期形式的預備招... NOTICE SEDAR 6/12 231 [] https://news.futunn.com/notice/307519371?futus...
9 Space Exploration Technologies Corp:補充長期形式的預備招... NOTICE SEDAR 6/12 210 [] https://news.futunn.com/notice/307519370?futus...
2
3
4
5
6
7
8
9
10
11
# Qot_GetSearchNews.proto
介紹
按關鍵詞搜索資訊。
參數
message C2S
{
required string keyword = 1; //搜索詞,如 lite
optional int32 max_count = 2; //本次請求的最大返回條數,默認10條,最大100條
optional int32 news_sub_type = 3; //NewsSubType,資訊子類型,默認 NewsSubType_ALL
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 資訊子類型枚舉參見 NewsSubType
- 返回
message SearchNews
{
optional string title = 1; //標題(含關鍵詞)
optional int32 news_sub_type = 2; //NewsSubType,資訊子類型
optional string source = 3; //來源,如 富途資訊 / MT Newswires / Benzinga
optional string publish_time = 4; //發佈時間
optional int64 view_count = 5; //瀏覽量
repeated string related_securities = 6; //關聯標的列表,如 LITE.US,用於跳轉
optional string url = 7; //詳情頁鏈接
}
message S2C
{
repeated SearchNews searchNewsList = 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
22
23
- 接口調用結果,結構參見 RetType
- 資訊子類型枚舉參見 NewsSubType
協議 ID
3263
uint GetSearchNews(QotGetSearchNews.Request req);
virtual void OnReply_GetSearchNews(MMAPI_Conn client, uint nSerialNo, QotGetSearchNews.Response rsp);
介紹
按關鍵詞搜索資訊。
參數
message C2S
{
required string keyword = 1; //搜索詞,如 lite
optional int32 max_count = 2; //本次請求的最大返回條數,默認10條,最大100條
optional int32 news_sub_type = 3; //NewsSubType,資訊子類型,默認 NewsSubType_ALL
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 資訊子類型枚舉參見 NewsSubType
- 返回
message SearchNews
{
optional string title = 1; //標題(含關鍵詞)
optional int32 news_sub_type = 2; //NewsSubType,資訊子類型
optional string source = 3; //來源,如 富途資訊 / MT Newswires / Benzinga
optional string publish_time = 4; //發佈時間
optional int64 view_count = 5; //瀏覽量
repeated string related_securities = 6; //關聯標的列表,如 LITE.US,用於跳轉
optional string url = 7; //詳情頁鏈接
}
message S2C
{
repeated SearchNews searchNewsList = 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
22
23
- 接口調用結果,結構參見 RetType
- 資訊子類型枚舉參見 NewsSubType
- Example
- Output
int getSearchNews(QotGetSearchNews.Request req);
void onReply_GetSearchNews(MMAPI_Conn client, int nSerialNo, QotGetSearchNews.Response rsp);
介紹
按關鍵詞搜索資訊。
參數
message C2S
{
required string keyword = 1; //搜索詞,如 lite
optional int32 max_count = 2; //本次請求的最大返回條數,默認10條,最大100條
optional int32 news_sub_type = 3; //NewsSubType,資訊子類型,默認 NewsSubType_ALL
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 資訊子類型枚舉參見 NewsSubType
- 返回
message SearchNews
{
optional string title = 1; //標題(含關鍵詞)
optional int32 news_sub_type = 2; //NewsSubType,資訊子類型
optional string source = 3; //來源,如 富途資訊 / MT Newswires / Benzinga
optional string publish_time = 4; //發佈時間
optional int64 view_count = 5; //瀏覽量
repeated string related_securities = 6; //關聯標的列表,如 LITE.US,用於跳轉
optional string url = 7; //詳情頁鏈接
}
message S2C
{
repeated SearchNews searchNewsList = 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
22
23
- 接口調用結果,結構參見 RetType
- 資訊子類型枚舉參見 NewsSubType
- Example
- Output
Futu::u32_t GetSearchNews(const Qot_GetSearchNews::Request &stReq);
virtual void OnReply_GetSearchNews(Futu::u32_t nSerialNo, const Qot_GetSearchNews::Response &stRsp) = 0;
介紹
按關鍵詞搜索資訊。
參數
message C2S
{
required string keyword = 1; //搜索詞,如 lite
optional int32 max_count = 2; //本次請求的最大返回條數,默認10條,最大100條
optional int32 news_sub_type = 3; //NewsSubType,資訊子類型,默認 NewsSubType_ALL
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 資訊子類型枚舉參見 NewsSubType
- 返回
message SearchNews
{
optional string title = 1; //標題(含關鍵詞)
optional int32 news_sub_type = 2; //NewsSubType,資訊子類型
optional string source = 3; //來源,如 富途資訊 / MT Newswires / Benzinga
optional string publish_time = 4; //發佈時間
optional int64 view_count = 5; //瀏覽量
repeated string related_securities = 6; //關聯標的列表,如 LITE.US,用於跳轉
optional string url = 7; //詳情頁鏈接
}
message S2C
{
repeated SearchNews searchNewsList = 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
22
23
- 接口調用結果,結構參見 RetType
- 資訊子類型枚舉參見 NewsSubType
- 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_GetSearchNews::Request req;
Qot_GetSearchNews::C2S *c2s = req.mutable_c2s();
c2s->set_keyword("space");
c2s->set_max_count(10);
c2s->set_news_sub_type(Qot_GetSearchNews::NewsSubType_ALL);
m_GetSearchNewsSerialNo = m_pQotApi->GetSearchNews(req);
}
virtual void OnReply_GetSearchNews(Futu::u32_t nSerialNo, const Qot_GetSearchNews::Response &stRsp) {
if (nSerialNo != m_GetSearchNewsSerialNo) return;
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
FTAPI_Qot *m_pQotApi;
Futu::u32_t m_GetSearchNewsSerialNo = 0;
};
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
GetSearchNews(req);
介紹
按關鍵詞搜索資訊。
參數
message C2S
{
required string keyword = 1; //搜索詞,如 lite
optional int32 max_count = 2; //本次請求的最大返回條數,默認10條,最大100條
optional int32 news_sub_type = 3; //NewsSubType,資訊子類型,默認 NewsSubType_ALL
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 資訊子類型枚舉參見 NewsSubType
- 返回
message SearchNews
{
optional string title = 1; //標題(含關鍵詞)
optional int32 news_sub_type = 2; //NewsSubType,資訊子類型
optional string source = 3; //來源,如 富途資訊 / MT Newswires / Benzinga
optional string publish_time = 4; //發佈時間
optional int64 view_count = 5; //瀏覽量
repeated string related_securities = 6; //關聯標的列表,如 LITE.US,用於跳轉
optional string url = 7; //詳情頁鏈接
}
message S2C
{
repeated SearchNews searchNewsList = 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
22
23
- 接口調用結果,結構參見 RetType
- 資訊子類型枚舉參見 NewsSubType
- Example
import mmWebsocket from "moomoo-api";
import { Common, Qot_GetSearchNews } from "moomoo-api/proto";
import beautify from "js-beautify";
function QotGetSearchNews(){
const { RetType } = Common
const { NewsSubType } = Qot_GetSearchNews
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: "space",
maxCount: 10,
newsSubType: NewsSubType.NewsSubType_ALL,
},
};
websocket.GetSearchNews(req)
.then((res) => {
let { errCode, retMsg, retType, s2c } = res
console.log("GetSearchNews: 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);
}
QotGetSearchNews()
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
接口限制
- 每 30 秒內最多請求 10 次搜索資訊接口。