# Get Indicator List
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_indicator_list(search_key='', lang_type=IndicatorLangType.NONE, search_mode=IndicatorSearchMode.PARTIAL)
Description
Get the list of supported indicators. Supports filtering by keyword, indicator script language (MyLang / Python) and search mode (partial / exact).
Parameters
Parameter Type Description search_key str Search keyword. Leave empty to return all indicators lang_type IndicatorLangType Indicator script language. Leave empty or NONEto not filter by languagesearch_mode IndicatorSearchMode Search mode, default partial match Return
Parameter Type Description ret RET_CODE API call result data pd.DataFrame When ret == RET_OK, returns indicator list str When ret != RET_OK, returns error description DataFrame fields:
Field Type Description short_name str Indicator short name, unique within the same language full_name str Indicator full name lang_type IndicatorLangType Script language (MyLang / Python) inputs list Input parameter list, each item is an IndicatorInputParam outputs list Output parameter list, each item is an IndicatorOutputParam script str Script source code, only returned when search_mode = Exactandsearch_keyis non-empty
Example
from futu import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data = quote_ctx.get_indicator_list('MACD', IndicatorLangType.MyLang, IndicatorSearchMode.PARTIAL)
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
# Qot_GetIndicatorList.proto
Description
Get the list of supported indicators. Supports filtering by keyword, indicator script language and search mode.
Parameters
message C2S
{
optional string searchKey = 1; // Search keyword, leave empty to return all
optional int32 langType = 2; // IndicatorLangType; leave empty or 0 to not filter by language
optional int32 searchMode = 3; // IndicatorSearchMode, default partial match
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- Return
// Indicator info under a single language
message IndicatorInfo
{
optional string shortName = 1; // Indicator short name, unique within the same language
optional string fullName = 2; // Indicator full name
repeated Qot_Common.IndicatorInputParam inputs = 3; // Input parameter list
repeated Qot_Common.IndicatorOutputParam outputs = 4; // Output parameter list
optional string script = 5; // Script source code, only returned when searchMode = Exact and searchKey is non-empty
}
// Indicators with the same name may have both MyLang and Python versions, returned as one merged entry
message IndicatorEntry
{
optional IndicatorInfo myLang = 1; // MyLang version (omitted if not available)
optional IndicatorInfo python = 2; // Python version (omitted if not available)
}
message S2C
{
repeated IndicatorEntry indicatorList = 1; // Indicator 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
22
23
24
25
26
27
28
29
- Indicator script language: IndicatorLangType
- Indicator search mode: IndicatorSearchMode
- Indicator input parameter: IndicatorInputParam
- Indicator output parameter: IndicatorOutputParam
- API call result structure: RetType
Protocol ID
3259
uint GetIndicatorList(QotGetIndicatorList.Request req);
virtual void OnReply_GetIndicatorList(FTAPI_Conn client, uint nSerialNo, QotGetIndicatorList.Response rsp);
Description
Get the list of supported indicators. Supports filtering by keyword, indicator script language and search mode.
Parameters
message C2S
{
optional string searchKey = 1; // Search keyword, leave empty to return all
optional int32 langType = 2; // IndicatorLangType; leave empty or 0 to not filter by language
optional int32 searchMode = 3; // IndicatorSearchMode, default partial match
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- Return
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
- Indicator script language: IndicatorLangType
- Indicator search mode: IndicatorSearchMode
- API call result structure: RetType
Protocol ID
3259
Example
public class Program : FTSPI_Qot, FTSPI_Conn
{
FTAPI_Qot qot = new FTAPI_Qot();
public Program()
{
qot.SetClientInfo("csharp", 1);
qot.SetConnCallback(this);
qot.SetQotCallback(this);
}
public void Start()
{
qot.InitConnect("127.0.0.1", (ushort)11111, false);
}
public void OnInitConnect(FTAPI_Conn client, long errCode, String desc)
{
if (errCode != 0) return;
var c2s = QotGetIndicatorList.C2S.CreateBuilder()
.SetSearchKey("MACD")
.SetLangType((int)QotCommon.IndicatorLangType.IndicatorLangType_MyLang)
.SetSearchMode((int)QotCommon.IndicatorSearchMode.IndicatorSearchMode_Partial)
.Build();
var req = QotGetIndicatorList.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetIndicatorList(req);
Console.Write("Send GetIndicatorList: {0}\n", seqNo);
}
public void OnReply_GetIndicatorList(FTAPI_Conn client, uint nSerialNo, QotGetIndicatorList.Response rsp)
{
Console.Write("Reply: {0} {1}\n", nSerialNo, rsp.ToString());
}
public static void Main(String[] args)
{
FTAPI.Init();
new Program().Start();
while (true) Thread.Sleep(1000 * 600);
}
}
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
- Output
Send GetIndicatorList: 1
Reply: 1 {
"indicatorList": [
{
"myLang": {
"shortName": "MA",
"fullName": "Simple Moving Average",
"inputs": [
{ "index": 0, "name": "price", "type": 1 },
{ "index": 1, "name": "period", "type": 0 }
],
"outputs": [
{ "index": 0, "name": "MA", "type": 1 }
]
},
"python": {
"shortName": "MA",
"fullName": "Simple Moving Average",
"inputs": [
{ "index": 0, "name": "close", "type": 1 },
{ "index": 1, "name": "period", "type": 0 }
],
"outputs": [
{ "index": 0, "name": "MA", "type": 1 }
]
}
},
{
"myLang": {
"shortName": "MACD",
"fullName": "Moving Average Convergence Divergence",
"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
int getIndicatorList(QotGetIndicatorList.Request req);
void onReply_GetIndicatorList(FTAPI_Conn client, int nSerialNo, QotGetIndicatorList.Response rsp);
Description
Get the list of supported indicators. Supports filtering by keyword, indicator script language and search mode.
Parameters
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
- Return
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
- Indicator script language: IndicatorLangType
- Indicator search mode: IndicatorSearchMode
- API call result structure: RetType
Protocol ID
3259
Example
public class Program implements FTSPI_Qot, FTSPI_Conn {
private FTAPI_Conn_Qot qot = new FTAPI_Conn_Qot();
public Program() {
qot.setClientInfo("java", 1);
qot.setConnSpi(this);
qot.setQotSpi(this);
}
public void start() {
qot.initConnect("127.0.0.1", (short) 11111, false);
}
@Override
public void onInitConnect(FTAPI_Conn client, long errCode, String desc) {
if (errCode != 0) return;
QotGetIndicatorList.C2S c2s = QotGetIndicatorList.C2S.newBuilder()
.setSearchKey("MACD")
.setLangType(QotCommon.IndicatorLangType.IndicatorLangType_MyLang_VALUE)
.setSearchMode(QotCommon.IndicatorSearchMode.IndicatorSearchMode_Partial_VALUE)
.build();
QotGetIndicatorList.Request req = QotGetIndicatorList.Request.newBuilder()
.setC2S(c2s).build();
int seqNo = qot.getIndicatorList(req);
System.out.println("Send getIndicatorList: " + seqNo);
}
@Override
public void onReply_GetIndicatorList(FTAPI_Conn client, int nSerialNo, QotGetIndicatorList.Response rsp) {
System.out.println("Reply: " + nSerialNo + " " + rsp.toString());
}
public static void main(String[] args) {
FTAPI.init();
new Program().start();
while (true) {
try { Thread.sleep(1000 * 600); } catch (InterruptedException e) {}
}
}
}
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
- Output
Send getIndicatorList: 1
Reply: 1 {
"indicatorList": [
{
"myLang": {
"shortName": "MA",
"fullName": "Simple Moving Average",
"inputs": [
{ "index": 0, "name": "price", "type": 1 },
{ "index": 1, "name": "period", "type": 0 }
],
"outputs": [
{ "index": 0, "name": "MA", "type": 1 }
]
},
"python": {
"shortName": "MA",
"fullName": "Simple Moving Average",
"inputs": [
{ "index": 0, "name": "close", "type": 1 },
{ "index": 1, "name": "period", "type": 0 }
],
"outputs": [
{ "index": 0, "name": "MA", "type": 1 }
]
}
},
{
"myLang": {
"shortName": "MACD",
"fullName": "Moving Average Convergence Divergence",
"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
Futu::u32_t GetIndicatorList(const Qot_GetIndicatorList::Request &stReq);
virtual void OnReply_GetIndicatorList(Futu::u32_t nSerialNo, const Qot_GetIndicatorList::Response &stRsp) = 0;
Description
Get the list of supported indicators. Supports filtering by keyword, indicator script language and search mode.
Parameters
message C2S
{
optional string searchKey = 1; // Search keyword, leave empty to return all
optional int32 langType = 2; // IndicatorLangType; leave empty or 0 to not filter by language
optional int32 searchMode = 3; // IndicatorSearchMode, default partial match
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- Return
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
- Indicator script language: IndicatorLangType
- Indicator search mode: IndicatorSearchMode
- API call result structure: RetType
Protocol ID
3259
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("MACD");
c2s->set_langtype(Qot_Common::IndicatorLangType::IndicatorLangType_MyLang);
c2s->set_searchmode(Qot_Common::IndicatorSearchMode::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);
Description
Get the list of supported indicators. Supports filtering by keyword, indicator script language and search mode.
Parameters
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
- Return
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
- Indicator script language: IndicatorLangType
- Indicator search mode: IndicatorSearchMode
- API call result structure: RetType
Protocol ID
3259
Example
import ftWebsocket from "futu-api";
import { Common, Qot_Common } from "futu-api/proto";
import beautify from "js-beautify";
function QotGetIndicatorList(){
const { RetType } = Common
const { IndicatorLangType, IndicatorSearchMode } = Qot_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: "MACD",
langType: IndicatorLangType.IndicatorLangType_MyLang,
searchMode: IndicatorSearchMode.IndicatorSearchMode_Partial,
},
};
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
45
- 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
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_indicator_list(search_key='', lang_type=IndicatorLangType.NONE, search_mode=IndicatorSearchMode.PARTIAL)
Description
Get the list of supported indicators. Supports filtering by keyword, indicator script language (MyLang / Python) and search mode (partial / exact).
Parameters
Parameter Type Description search_key str Search keyword. Leave empty to return all indicators lang_type IndicatorLangType Indicator script language. Leave empty or NONEto not filter by languagesearch_mode IndicatorSearchMode Search mode, default partial match Return
Parameter Type Description ret RET_CODE API call result data pd.DataFrame When ret == RET_OK, returns indicator list str When ret != RET_OK, returns error description DataFrame fields:
Field Type Description short_name str Indicator short name, unique within the same language full_name str Indicator full name lang_type IndicatorLangType Script language (MyLang / Python) inputs list Input parameter list, each item is an IndicatorInputParam outputs list Output parameter list, each item is an IndicatorOutputParam script str Script source code, only returned when search_mode = Exactandsearch_keyis non-empty
Example
from moomoo import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data = quote_ctx.get_indicator_list('MACD', IndicatorLangType.MyLang, IndicatorSearchMode.PARTIAL)
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
# Qot_GetIndicatorList.proto
Description
Get the list of supported indicators. Supports filtering by keyword, indicator script language and search mode.
Parameters
message C2S
{
optional string searchKey = 1; // Search keyword, leave empty to return all
optional int32 langType = 2; // IndicatorLangType; leave empty or 0 to not filter by language
optional int32 searchMode = 3; // IndicatorSearchMode, default partial match
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- Return
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
- Indicator script language: IndicatorLangType
- Indicator search mode: IndicatorSearchMode
- API call result structure: RetType
Protocol ID
3259
uint GetIndicatorList(QotGetIndicatorList.Request req);
virtual void OnReply_GetIndicatorList(MMAPI_Conn client, uint nSerialNo, QotGetIndicatorList.Response rsp);
Description
Get the list of supported indicators. Supports filtering by keyword, indicator script language and search mode.
Parameters
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
- Return
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
- Indicator script language: IndicatorLangType
- Indicator search mode: IndicatorSearchMode
- API call result structure: RetType
Protocol ID
3259
Example
public class Program : MMSPI_Qot, MMSPI_Conn
{
MMAPI_Qot qot = new MMAPI_Qot();
public Program()
{
qot.SetClientInfo("csharp", 1);
qot.SetConnCallback(this);
qot.SetQotCallback(this);
}
public void Start()
{
qot.InitConnect("127.0.0.1", (ushort)11111, false);
}
public void OnInitConnect(MMAPI_Conn client, long errCode, String desc)
{
if (errCode != 0) return;
var c2s = QotGetIndicatorList.C2S.CreateBuilder()
.SetSearchKey("MACD")
.SetLangType((int)QotCommon.IndicatorLangType.IndicatorLangType_MyLang)
.SetSearchMode((int)QotCommon.IndicatorSearchMode.IndicatorSearchMode_Partial)
.Build();
var req = QotGetIndicatorList.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.GetIndicatorList(req);
Console.Write("Send GetIndicatorList: {0}\n", seqNo);
}
public void OnReply_GetIndicatorList(MMAPI_Conn client, uint nSerialNo, QotGetIndicatorList.Response rsp)
{
Console.Write("Reply: {0} {1}\n", nSerialNo, rsp.ToString());
}
public static void Main(String[] args)
{
MMAPI.Init();
new Program().Start();
while (true) Thread.Sleep(1000 * 600);
}
}
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
- Output
Send GetIndicatorList: 1
Reply: 1 {
"indicatorList": [
{
"myLang": {
"shortName": "MA",
"fullName": "Simple Moving Average",
"inputs": [
{ "index": 0, "name": "price", "type": 1 },
{ "index": 1, "name": "period", "type": 0 }
],
"outputs": [
{ "index": 0, "name": "MA", "type": 1 }
]
},
"python": {
"shortName": "MA",
"fullName": "Simple Moving Average",
"inputs": [
{ "index": 0, "name": "close", "type": 1 },
{ "index": 1, "name": "period", "type": 0 }
],
"outputs": [
{ "index": 0, "name": "MA", "type": 1 }
]
}
},
{
"myLang": {
"shortName": "MACD",
"fullName": "Moving Average Convergence Divergence",
"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
int getIndicatorList(QotGetIndicatorList.Request req);
void onReply_GetIndicatorList(MMAPI_Conn client, int nSerialNo, QotGetIndicatorList.Response rsp);
Description
Get the list of supported indicators. Supports filtering by keyword, indicator script language and search mode.
Parameters
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
- Return
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
- Indicator script language: IndicatorLangType
- Indicator search mode: IndicatorSearchMode
- API call result structure: RetType
Protocol ID
3259
Example
public class Program implements MMSPI_Qot, MMSPI_Conn {
private MMAPI_Conn_Qot qot = new MMAPI_Conn_Qot();
public Program() {
qot.setClientInfo("java", 1);
qot.setConnSpi(this);
qot.setQotSpi(this);
}
public void start() {
qot.initConnect("127.0.0.1", (short) 11111, false);
}
@Override
public void onInitConnect(MMAPI_Conn client, long errCode, String desc) {
if (errCode != 0) return;
QotGetIndicatorList.C2S c2s = QotGetIndicatorList.C2S.newBuilder()
.setSearchKey("MACD")
.setLangType(QotCommon.IndicatorLangType.IndicatorLangType_MyLang_VALUE)
.setSearchMode(QotCommon.IndicatorSearchMode.IndicatorSearchMode_Partial_VALUE)
.build();
QotGetIndicatorList.Request req = QotGetIndicatorList.Request.newBuilder()
.setC2S(c2s).build();
int seqNo = qot.getIndicatorList(req);
System.out.println("Send getIndicatorList: " + seqNo);
}
@Override
public void onReply_GetIndicatorList(MMAPI_Conn client, int nSerialNo, QotGetIndicatorList.Response rsp) {
System.out.println("Reply: " + nSerialNo + " " + rsp.toString());
}
public static void main(String[] args) {
MMAPI.init();
new Program().start();
while (true) {
try { Thread.sleep(1000 * 600); } catch (InterruptedException e) {}
}
}
}
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
- Output
Send getIndicatorList: 1
Reply: 1 {
"indicatorList": [
{
"myLang": {
"shortName": "MA",
"fullName": "Simple Moving Average",
"inputs": [
{ "index": 0, "name": "price", "type": 1 },
{ "index": 1, "name": "period", "type": 0 }
],
"outputs": [
{ "index": 0, "name": "MA", "type": 1 }
]
},
"python": {
"shortName": "MA",
"fullName": "Simple Moving Average",
"inputs": [
{ "index": 0, "name": "close", "type": 1 },
{ "index": 1, "name": "period", "type": 0 }
],
"outputs": [
{ "index": 0, "name": "MA", "type": 1 }
]
}
},
{
"myLang": {
"shortName": "MACD",
"fullName": "Moving Average Convergence Divergence",
"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
Moomoo::u32_t GetIndicatorList(const Qot_GetIndicatorList::Request &stReq);
virtual void OnReply_GetIndicatorList(Moomoo::u32_t nSerialNo, const Qot_GetIndicatorList::Response &stRsp) = 0;
Description
Get the list of supported indicators. Supports filtering by keyword, indicator script language and search mode.
Parameters
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
- Return
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
- Indicator script language: IndicatorLangType
- Indicator search mode: IndicatorSearchMode
- API call result structure: RetType
Protocol ID
3259
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("MACD");
c2s->set_langtype(Qot_Common::IndicatorLangType::IndicatorLangType_MyLang);
c2s->set_searchmode(Qot_Common::IndicatorSearchMode::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);
Description
Get the list of supported indicators. Supports filtering by keyword, indicator script language and search mode.
Parameters
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
- Return
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
- Indicator script language: IndicatorLangType
- Indicator search mode: IndicatorSearchMode
- API call result structure: RetType
Protocol ID
3259
Example
import mmWebsocket from "moomoo-api";
import { Common, Qot_Common } from "moomoo-api/proto";
import beautify from "js-beautify";
function QotGetIndicatorList(){
const { RetType } = Common
const { IndicatorLangType, IndicatorSearchMode } = Qot_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: "MACD",
langType: IndicatorLangType.IndicatorLangType_MyLang,
searchMode: IndicatorSearchMode.IndicatorSearchMode_Partial,
},
};
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
45
- 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