# 获取指标列表
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_indicator_list(search_key='', lang_type=IndicatorLangType.NONE, search_mode=IndicatorSearchMode.PARTIAL)
介绍
获取指标列表(可按关键词、语言类型、匹配方式过滤)。同名指标在 MyLang 和 Python 两种实现均存在时合并为同一条目返回。
参数
参数 类型 说明 search_key str 搜索关键词 留空则返回全部lang_type IndicatorLangType 指标脚本语言类型 默认不按语言过滤search_mode IndicatorSearchMode 匹配方式 默认部分匹配返回
参数 类型 说明 ret RET_CODE 接口调用结果 data list 当 ret == RET_OK,返回指标条目列表 str 当 ret != RET_OK,返回错误描述 指标条目字段说明:
字段 类型 说明 my_lang dict 麦语言版本指标信息(若不存在则为 None) python dict Python 版本指标信息(若不存在则为 None) 单一语言指标信息字段说明:
字段 类型 说明 short_name str 指标短名,同语言内唯一 full_name str 指标全名 inputs list 输入参数列表 outputs list 输出参数列表 script str 仅 search_mode = Exact 且 search_key 非空时返回脚本源码
Example
from futu import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data = quote_ctx.get_indicator_list(search_key='MA', lang_type=IndicatorLangType.MYLANG, search_mode=IndicatorSearchMode.PARTIAL)
if ret == RET_OK:
print(data)
else:
print('error:', data)
quote_ctx.close() # 结束后记得关闭当条连接,防止连接条数用尽
2
3
4
5
6
7
8
# Qot_GetIndicatorList.proto
介绍
获取指标列表(可按关键词、语言类型、匹配方式过滤)。
参数
message C2S
{
optional string searchKey = 1; //搜索关键词,留空则返回全部
optional int32 langType = 2; //IndicatorLangType;留空或 0 不按语言过滤
optional int32 searchMode = 3; //IndicatorSearchMode,默认部分匹配
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 返回
//单一语言下的指标信息
message IndicatorInfo
{
optional string shortName = 1; //指标短名,同语言内唯一
optional string fullName = 2; //指标全名
repeated Qot_Common.IndicatorInputParam inputs = 3; //输入参数列表
repeated Qot_Common.IndicatorOutputParam outputs = 4; //输出参数列表
optional string script = 5; //仅 searchMode = Exact 且 searchKey 非空时返回脚本源码
}
//同名指标可能同时有 MyLang / Python 两个版本,合并为同一条目返回
message IndicatorEntry
{
optional IndicatorInfo myLang = 1; //麦语言版本(无则不返回)
optional IndicatorInfo python = 2; //Python 版本(无则不返回)
}
message S2C
{
repeated IndicatorEntry indicatorList = 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
24
25
26
27
28
29
- 指标语言类型参见 IndicatorLangType
- 指标匹配方式参见 IndicatorSearchMode
- 接口调用结果,结构参见 RetType
协议 ID
3259
uint GetIndicatorList(QotGetIndicatorList.Request req);
virtual void OnReply_GetIndicatorList(FTAPI_Conn client, uint nSerialNo, QotGetIndicatorList.Response rsp);
介绍
获取指标列表(可按关键词、语言类型、匹配方式过滤)。
参数
message C2S
{
optional string searchKey = 1; //搜索关键词,留空则返回全部
optional int32 langType = 2; //IndicatorLangType;留空或 0 不按语言过滤
optional int32 searchMode = 3; //IndicatorSearchMode,默认部分匹配
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 返回
message IndicatorInfo
{
optional string shortName = 1;
optional string fullName = 2;
repeated Qot_Common.IndicatorInputParam inputs = 3;
repeated Qot_Common.IndicatorOutputParam outputs = 4;
optional string script = 5;
}
message IndicatorEntry
{
optional IndicatorInfo myLang = 1;
optional IndicatorInfo python = 2;
}
message S2C
{
repeated IndicatorEntry indicatorList = 1;
}
message Response
{
required int32 retType = 1 [default = -400];
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
- 接口调用结果,结构参见 RetType
- Example
- Output
int getIndicatorList(QotGetIndicatorList.Request req);
void onReply_GetIndicatorList(FTAPI_Conn client, int nSerialNo, QotGetIndicatorList.Response rsp);
介绍
获取指标列表(可按关键词、语言类型、匹配方式过滤)。
参数
message C2S
{
optional string searchKey = 1;
optional int32 langType = 2;
optional int32 searchMode = 3;
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 返回
message IndicatorInfo
{
optional string shortName = 1;
optional string fullName = 2;
repeated Qot_Common.IndicatorInputParam inputs = 3;
repeated Qot_Common.IndicatorOutputParam outputs = 4;
optional string script = 5;
}
message IndicatorEntry
{
optional IndicatorInfo myLang = 1;
optional IndicatorInfo python = 2;
}
message S2C
{
repeated IndicatorEntry indicatorList = 1;
}
message Response
{
required int32 retType = 1 [default = -400];
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
- 接口调用结果,结构参见 RetType
- Example
- Output
Futu::u32_t GetIndicatorList(const Qot_GetIndicatorList::Request &stReq);
virtual void OnReply_GetIndicatorList(Futu::u32_t nSerialNo, const Qot_GetIndicatorList::Response &stRsp) = 0;
介绍
获取指标列表(可按关键词、语言类型、匹配方式过滤)。
参数
message C2S
{
optional string searchKey = 1; //搜索关键词,留空则返回全部
optional int32 langType = 2; //IndicatorLangType;留空或 0 不按语言过滤
optional int32 searchMode = 3; //IndicatorSearchMode,默认部分匹配
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 返回
message IndicatorInfo
{
optional string shortName = 1;
optional string fullName = 2;
repeated Qot_Common.IndicatorInputParam inputs = 3;
repeated Qot_Common.IndicatorOutputParam outputs = 4;
optional string script = 5;
}
message IndicatorEntry
{
optional IndicatorInfo myLang = 1;
optional IndicatorInfo python = 2;
}
message S2C
{
repeated IndicatorEntry indicatorList = 1;
}
message Response
{
required int32 retType = 1 [default = -400];
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
- 接口调用结果,结构参见 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_GetIndicatorList::Request req;
Qot_GetIndicatorList::C2S *c2s = req.mutable_c2s();
c2s->set_searchkey("MA");
c2s->set_langtype(Qot_Common::IndicatorLangType_MyLang);
c2s->set_searchmode(Qot_Common::IndicatorSearchMode_Partial);
m_GetIndicatorListSerialNo = m_pQotApi->GetIndicatorList(req);
}
virtual void OnReply_GetIndicatorList(Futu::u32_t nSerialNo, const Qot_GetIndicatorList::Response &stRsp) {
if (nSerialNo != m_GetIndicatorListSerialNo) return;
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
FTAPI_Qot *m_pQotApi;
Futu::u32_t m_GetIndicatorListSerialNo = 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
GetIndicatorList(req);
介绍
获取指标列表(可按关键词、语言类型、匹配方式过滤)。
参数
message C2S
{
optional string searchKey = 1;
optional int32 langType = 2;
optional int32 searchMode = 3;
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 返回
message IndicatorInfo
{
optional string shortName = 1;
optional string fullName = 2;
repeated Qot_Common.IndicatorInputParam inputs = 3;
repeated Qot_Common.IndicatorOutputParam outputs = 4;
optional string script = 5;
}
message IndicatorEntry
{
optional IndicatorInfo myLang = 1;
optional IndicatorInfo python = 2;
}
message S2C
{
repeated IndicatorEntry indicatorList = 1;
}
message Response
{
required int32 retType = 1 [default = -400];
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
- 接口调用结果,结构参见 RetType
- Example
import ftWebsocket from "futu-api";
import { Common } from "futu-api/proto";
import beautify from "js-beautify";
function QotGetIndicatorList(){
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: {
searchKey: "MA",
langType: 1,
searchMode: 0,
},
};
websocket.GetIndicatorList(req)
.then((res) => {
let { errCode, retMsg, retType, s2c } = res
console.log("GetIndicatorList: 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);
}
QotGetIndicatorList()
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
- Output
GetIndicatorList: errCode 0, retMsg , retType 0
{
"indicatorList": [
{
"myLang": {
"shortName": "MA",
"fullName": "简单移动平均线",
"inputs": [
{ "index": 0, "name": "price", "type": 1 },
{ "index": 1, "name": "period", "type": 0 }
],
"outputs": [
{ "index": 0, "name": "MA", "type": 1 }
]
},
"python": {
"shortName": "MA",
"fullName": "简单移动平均线",
"inputs": [
{ "index": 0, "name": "close", "type": 1 },
{ "index": 1, "name": "period", "type": 0 }
],
"outputs": [
{ "index": 0, "name": "MA", "type": 1 }
]
}
},
{
"myLang": {
"shortName": "MACD",
"fullName": "指数平滑移动平均线",
"inputs": [
{ "index": 0, "name": "price", "type": 1 },
{ "index": 1, "name": "SHORT", "type": 0 },
{ "index": 2, "name": "LONG", "type": 0 },
{ "index": 3, "name": "MID", "type": 0 }
],
"outputs": [
{ "index": 0, "name": "DIF", "type": 1 },
{ "index": 1, "name": "DEA", "type": 1 },
{ "index": 2, "name": "MACD", "type": 1 }
]
}
}
]
}
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
接口限制
- 每 30 秒内最多请求 10 次获取指标列表接口。
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_indicator_list(search_key='', lang_type=IndicatorLangType.NONE, search_mode=IndicatorSearchMode.PARTIAL)
介绍
获取指标列表(可按关键词、语言类型、匹配方式过滤)。同名指标在 MyLang 和 Python 两种实现均存在时合并为同一条目返回。
参数
参数 类型 说明 search_key str 搜索关键词 留空则返回全部lang_type IndicatorLangType 指标脚本语言类型 默认不按语言过滤search_mode IndicatorSearchMode 匹配方式 默认部分匹配返回
参数 类型 说明 ret RET_CODE 接口调用结果 data list 当 ret == RET_OK,返回指标条目列表 str 当 ret != RET_OK,返回错误描述 指标条目字段说明:
字段 类型 说明 my_lang dict 麦语言版本指标信息(若不存在则为 None) python dict Python 版本指标信息(若不存在则为 None)
Example
from moomoo import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data = quote_ctx.get_indicator_list(search_key='MA', lang_type=IndicatorLangType.MYLANG, search_mode=IndicatorSearchMode.PARTIAL)
if ret == RET_OK:
print(data)
else:
print('error:', data)
quote_ctx.close() # 结束后记得关闭当条连接,防止连接条数用尽
2
3
4
5
6
7
8
# Qot_GetIndicatorList.proto
介绍
获取指标列表(可按关键词、语言类型、匹配方式过滤)。
参数
message C2S
{
optional string searchKey = 1; //搜索关键词,留空则返回全部
optional int32 langType = 2; //IndicatorLangType;留空或 0 不按语言过滤
optional int32 searchMode = 3; //IndicatorSearchMode,默认部分匹配
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 返回
message IndicatorInfo
{
optional string shortName = 1;
optional string fullName = 2;
repeated Qot_Common.IndicatorInputParam inputs = 3;
repeated Qot_Common.IndicatorOutputParam outputs = 4;
optional string script = 5;
}
message IndicatorEntry
{
optional IndicatorInfo myLang = 1;
optional IndicatorInfo python = 2;
}
message S2C
{
repeated IndicatorEntry indicatorList = 1;
}
message Response
{
required int32 retType = 1 [default = -400];
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
- 指标语言类型参见 IndicatorLangType
- 指标匹配方式参见 IndicatorSearchMode
- 接口调用结果,结构参见 RetType
协议 ID
3259
uint GetIndicatorList(QotGetIndicatorList.Request req);
virtual void OnReply_GetIndicatorList(MMAPI_Conn client, uint nSerialNo, QotGetIndicatorList.Response rsp);
介绍
获取指标列表(可按关键词、语言类型、匹配方式过滤)。
参数
message C2S
{
optional string searchKey = 1;
optional int32 langType = 2;
optional int32 searchMode = 3;
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 返回
message IndicatorEntry
{
optional IndicatorInfo myLang = 1;
optional IndicatorInfo python = 2;
}
message S2C
{
repeated IndicatorEntry indicatorList = 1;
}
message Response
{
required int32 retType = 1 [default = -400];
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
- 接口调用结果,结构参见 RetType
- Example
- Output
int getIndicatorList(QotGetIndicatorList.Request req);
void onReply_GetIndicatorList(MMAPI_Conn client, int nSerialNo, QotGetIndicatorList.Response rsp);
介绍
获取指标列表(可按关键词、语言类型、匹配方式过滤)。
参数
message C2S
{
optional string searchKey = 1;
optional int32 langType = 2;
optional int32 searchMode = 3;
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 返回
message IndicatorEntry
{
optional IndicatorInfo myLang = 1;
optional IndicatorInfo python = 2;
}
message S2C
{
repeated IndicatorEntry indicatorList = 1;
}
message Response
{
required int32 retType = 1 [default = -400];
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
- 接口调用结果,结构参见 RetType
- Example
- Output
Moomoo::u32_t GetIndicatorList(const Qot_GetIndicatorList::Request &stReq);
virtual void OnReply_GetIndicatorList(Moomoo::u32_t nSerialNo, const Qot_GetIndicatorList::Response &stRsp) = 0;
介绍
获取指标列表(可按关键词、语言类型、匹配方式过滤)。
参数
message C2S
{
optional string searchKey = 1;
optional int32 langType = 2;
optional int32 searchMode = 3;
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 返回
message IndicatorEntry
{
optional IndicatorInfo myLang = 1;
optional IndicatorInfo python = 2;
}
message S2C
{
repeated IndicatorEntry indicatorList = 1;
}
message Response
{
required int32 retType = 1 [default = -400];
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
- 接口调用结果,结构参见 RetType
- 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_GetIndicatorList::Request req;
Qot_GetIndicatorList::C2S *c2s = req.mutable_c2s();
c2s->set_searchkey("MA");
c2s->set_langtype(Qot_Common::IndicatorLangType_MyLang);
c2s->set_searchmode(Qot_Common::IndicatorSearchMode_Partial);
m_GetIndicatorListSerialNo = m_pQotApi->GetIndicatorList(req);
}
virtual void OnReply_GetIndicatorList(Moomoo::u32_t nSerialNo, const Qot_GetIndicatorList::Response &stRsp) {
if (nSerialNo != m_GetIndicatorListSerialNo) return;
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
MMAPI_Qot *m_pQotApi;
Moomoo::u32_t m_GetIndicatorListSerialNo = 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
GetIndicatorList(req);
介绍
获取指标列表(可按关键词、语言类型、匹配方式过滤)。
参数
message C2S
{
optional string searchKey = 1;
optional int32 langType = 2;
optional int32 searchMode = 3;
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 返回
message IndicatorEntry
{
optional IndicatorInfo myLang = 1;
optional IndicatorInfo python = 2;
}
message S2C
{
repeated IndicatorEntry indicatorList = 1;
}
message Response
{
required int32 retType = 1 [default = -400];
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
- 接口调用结果,结构参见 RetType
- Example
import mmWebsocket from "moomoo-api";
import { Common } from "moomoo-api/proto";
import beautify from "js-beautify";
function QotGetIndicatorList(){
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: {
searchKey: "MA",
langType: 1,
searchMode: 0,
},
};
websocket.GetIndicatorList(req)
.then((res) => {
let { errCode, retMsg, retType, s2c } = res
console.log("GetIndicatorList: 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);
}
QotGetIndicatorList()
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
- Output
GetIndicatorList: errCode 0, retMsg , retType 0
{
"indicatorList": [
{
"myLang": {
"shortName": "MA",
"fullName": "简单移动平均线",
"inputs": [
{ "index": 0, "name": "price", "type": 1 },
{ "index": 1, "name": "period", "type": 0 }
],
"outputs": [
{ "index": 0, "name": "MA", "type": 1 }
]
},
"python": {
"shortName": "MA",
"fullName": "简单移动平均线",
"inputs": [
{ "index": 0, "name": "close", "type": 1 },
{ "index": 1, "name": "period", "type": 0 }
],
"outputs": [
{ "index": 0, "name": "MA", "type": 1 }
]
}
},
{
"myLang": {
"shortName": "MACD",
"fullName": "指数平滑移动平均线",
"inputs": [
{ "index": 0, "name": "price", "type": 1 },
{ "index": 1, "name": "SHORT", "type": 0 },
{ "index": 2, "name": "LONG", "type": 0 },
{ "index": 3, "name": "MID", "type": 0 }
],
"outputs": [
{ "index": 0, "name": "DIF", "type": 1 },
{ "index": 1, "name": "DEA", "type": 1 },
{ "index": 2, "name": "MACD", "type": 1 }
]
}
}
]
}
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
接口限制
- 每 30 秒内最多请求 10 次获取指标列表接口。