# インジケーター計算リクエスト
- Python
- Proto
- C#
- Java
- C++
- JavaScript
request_indicator_calc_async(short_name, lang_type, code, kl_type, klines, num=None, input_params=None)
説明
インジケーター計算を非同期で起動します。リクエスト送信後、サーバーは
calc_idを返却し、計算結果は push-indicator-calc コールバックで通知されます。パラメータ
パラメータ 型 説明 short_name str インジケーター短縮名 lang_type IndicatorLangType 言語タイプ code str 銘柄コード。例: HK.00700kl_type KLType K線タイプ klines pd.DataFrame または list[dict] K線データ。 request_history_kline/get_cur_klineの戻り値num int または None 最大 N 本の K 線を使用。None は全件 input_params list[dict] または None 入参上書き {"index": int, "value": str}。空の場合はデフォルト戻り値
パラメータ 型 説明 ret RET_CODE API呼び出し結果 data str ret == RET_OK の場合、計算タスクID(calcId)を返します str ret != RET_OK の場合、エラー説明を返します
# Qot_RequestIndicatorCalc.proto
説明
インジケーター計算を非同期で起動します。リクエスト送信後、サーバーは
calcIdを返却し、計算結果はQot_PushIndicatorCalcプッシュで通知されます。パラメータ
//単一入力パラメータの上書き項目
message IndicatorInputItem
{
required int32 index = 1; //入力パラメータの添字、IndicatorInfo.inputs の index に対応、0 から開始
optional string value = 2; //入力パラメータ値(文字列形式、省略時はデフォルト値を使用)
}
//計算に必要な標的とK線データ
message IndicatorCalcData
{
required Qot_Common.Security security = 1; //標的
required Qot_Common.KLType klType = 2; //K線周期
repeated Qot_Common.KLine kLine = 3; //K線データ
}
message C2S
{
required string shortName = 1; //インジケーター短縮名
required Qot_Common.IndicatorLangType langType = 2; //言語タイプ
required IndicatorCalcData data = 3; //計算に必要なデータ
optional int32 num = 4; //前 N 本のK線のみを使用、未指定の場合は全K線を使用
repeated IndicatorInputItem inputs = 5; //入力パラメータの上書き(空可、空時はクラウド設定を使用)
}
message Request
{
required C2S c2s = 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
- 戻り値
message S2C
{
required string calcId = 1; //計算タスクID、プッシュ結果と紐付け
}
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
- API呼び出し結果の構造体: RetType
プロトコル ID
3260
uint RequestIndicatorCalc(QotRequestIndicatorCalc.Request req);
virtual void OnReply_RequestIndicatorCalc(FTAPI_Conn client, uint nSerialNo, QotRequestIndicatorCalc.Response rsp);
説明
インジケーター計算を非同期で起動します。リクエスト送信後、サーバーは
calcIdを返却し、計算結果はQot_PushIndicatorCalcプッシュで通知されます。パラメータ
message IndicatorInputItem
{
required int32 index = 1;
optional string value = 2;
}
message IndicatorCalcData
{
required Qot_Common.Security security = 1;
required Qot_Common.KLType klType = 2;
repeated Qot_Common.KLine kLine = 3;
}
message C2S
{
required string shortName = 1;
required Qot_Common.IndicatorLangType langType = 2;
required IndicatorCalcData data = 3;
optional int32 num = 4;
repeated IndicatorInputItem inputs = 5;
}
message Request
{
required C2S c2s = 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
- 戻り値
message S2C
{
required string calcId = 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
- API呼び出し結果の構造体: RetType
- Example
- Output
int requestIndicatorCalc(QotRequestIndicatorCalc.Request req);
void onReply_RequestIndicatorCalc(FTAPI_Conn client, int nSerialNo, QotRequestIndicatorCalc.Response rsp);
説明
インジケーター計算を非同期で起動します。リクエスト送信後、サーバーは
calcIdを返却し、計算結果はQot_PushIndicatorCalcプッシュで通知されます。パラメータ
message IndicatorInputItem
{
required int32 index = 1;
optional string value = 2;
}
message IndicatorCalcData
{
required Qot_Common.Security security = 1;
required Qot_Common.KLType klType = 2;
repeated Qot_Common.KLine kLine = 3;
}
message C2S
{
required string shortName = 1;
required Qot_Common.IndicatorLangType langType = 2;
required IndicatorCalcData data = 3;
optional int32 num = 4;
repeated IndicatorInputItem inputs = 5;
}
message Request
{
required C2S c2s = 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
- 戻り値
message S2C
{
required string calcId = 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
- API呼び出し結果の構造体: RetType
- Example
- Output
Futu::u32_t RequestIndicatorCalc(const Qot_RequestIndicatorCalc::Request &stReq);
virtual void OnReply_RequestIndicatorCalc(Futu::u32_t nSerialNo, const Qot_RequestIndicatorCalc::Response &stRsp) = 0;
説明
インジケーター計算を非同期で起動します。リクエスト送信後、サーバーは
calcIdを返却し、計算結果はQot_PushIndicatorCalcプッシュで通知されます。パラメータ
message IndicatorInputItem
{
required int32 index = 1;
optional string value = 2;
}
message IndicatorCalcData
{
required Qot_Common.Security security = 1;
required Qot_Common.KLType klType = 2;
repeated Qot_Common.KLine kLine = 3;
}
message C2S
{
required string shortName = 1;
required Qot_Common.IndicatorLangType langType = 2;
required IndicatorCalcData data = 3;
optional int32 num = 4;
repeated IndicatorInputItem inputs = 5;
}
message Request
{
required C2S c2s = 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
- 戻り値
message S2C
{
required string calcId = 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
- 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_RequestIndicatorCalc::Request req;
Qot_RequestIndicatorCalc::C2S *c2s = req.mutable_c2s();
c2s->set_shortname("MA");
c2s->set_langtype(Qot_Common::IndicatorLangType_MyLang);
Qot_RequestIndicatorCalc::IndicatorCalcData *data = c2s->mutable_data();
Qot_Common::Security *sec = data->mutable_security();
sec->set_market(Qot_Common::QotMarket_US_Security);
sec->set_code("AAPL");
data->set_kltype(Qot_Common::KLType_Day);
// ここに data->add_kline() で計算対象のK線データを追加します
m_RequestIndicatorCalcSerialNo = m_pQotApi->RequestIndicatorCalc(req);
}
virtual void OnReply_RequestIndicatorCalc(Futu::u32_t nSerialNo, const Qot_RequestIndicatorCalc::Response &stRsp) {
if (nSerialNo != m_RequestIndicatorCalcSerialNo) return;
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
// 計算結果は OnPush_PushIndicatorCalc で受信
virtual void OnPush_PushIndicatorCalc(const Qot_PushIndicatorCalc::Response &stRsp) {
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
FTAPI_Qot *m_pQotApi;
Futu::u32_t m_RequestIndicatorCalcSerialNo = 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
RequestIndicatorCalc(req);
説明
インジケーター計算を非同期で起動します。リクエスト送信後、サーバーは
calcIdを返却し、計算結果はQot_PushIndicatorCalcプッシュで通知されます。パラメータ
message IndicatorInputItem
{
required int32 index = 1;
optional string value = 2;
}
message IndicatorCalcData
{
required Qot_Common.Security security = 1;
required Qot_Common.KLType klType = 2;
repeated Qot_Common.KLine kLine = 3;
}
message C2S
{
required string shortName = 1;
required Qot_Common.IndicatorLangType langType = 2;
required IndicatorCalcData data = 3;
optional int32 num = 4;
repeated IndicatorInputItem inputs = 5;
}
message Request
{
required C2S c2s = 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
- 戻り値
message S2C
{
required string calcId = 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
- API呼び出し結果の構造体: RetType
- Example
import ftWebsocket from "futu-api";
import { Common, Qot_Common } from "futu-api/proto";
import beautify from "js-beautify";
function QotRequestIndicatorCalc(){
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: {
shortName: "MA",
langType: 1,
data: {
security: { market: 11, code: "AAPL" },
klType: 2,
kLine: [],
},
},
};
websocket.RequestIndicatorCalc(req)
.then((res) => {
let { errCode, retMsg, retType, s2c } = res
console.log("RequestIndicatorCalc: 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);
}
QotRequestIndicatorCalc()
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
47
48
- Output
RequestIndicatorCalc: errCode 0, retMsg , retType 0
{
"calcId": "1700000000000-0"
}
2
3
4
- Python
- Proto
- C#
- Java
- C++
- JavaScript
request_indicator_calc_async(short_name, lang_type, code, kl_type, klines, num=None, input_params=None)
説明
インジケーター計算を非同期で起動します。リクエスト送信後、サーバーは
calc_idを返却し、計算結果は push-indicator-calc コールバックで通知されます。パラメータ
パラメータ 型 説明 short_name str インジケーター短縮名 lang_type IndicatorLangType 言語タイプ code str 銘柄コード。例: HK.00700kl_type KLType K線タイプ klines pd.DataFrame または list[dict] K線データ。 request_history_kline/get_cur_klineの戻り値num int または None 最大 N 本の K 線を使用。None は全件 input_params list[dict] または None 入参上書き {"index": int, "value": str}。空の場合はデフォルト戻り値
パラメータ 型 説明 ret RET_CODE API呼び出し結果 data str ret == RET_OK の場合、計算タスクID(calcId)を返します str ret != RET_OK の場合、エラー説明を返します
# Qot_RequestIndicatorCalc.proto
説明
インジケーター計算を非同期で起動します。リクエスト送信後、サーバーは
calcIdを返却し、計算結果はQot_PushIndicatorCalcプッシュで通知されます。パラメータ
message IndicatorInputItem
{
required int32 index = 1;
optional string value = 2;
}
message IndicatorCalcData
{
required Qot_Common.Security security = 1;
required Qot_Common.KLType klType = 2;
repeated Qot_Common.KLine kLine = 3;
}
message C2S
{
required string shortName = 1;
required Qot_Common.IndicatorLangType langType = 2;
required IndicatorCalcData data = 3;
optional int32 num = 4;
repeated IndicatorInputItem inputs = 5;
}
message Request
{
required C2S c2s = 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
- 戻り値
message S2C
{
required string calcId = 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
- API呼び出し結果の構造体: RetType
プロトコル ID
3260
uint RequestIndicatorCalc(QotRequestIndicatorCalc.Request req);
virtual void OnReply_RequestIndicatorCalc(MMAPI_Conn client, uint nSerialNo, QotRequestIndicatorCalc.Response rsp);
説明
インジケーター計算を非同期で起動します。リクエスト送信後、サーバーは
calcIdを返却し、計算結果はQot_PushIndicatorCalcプッシュで通知されます。パラメータ
message IndicatorInputItem
{
required int32 index = 1;
optional string value = 2;
}
message IndicatorCalcData
{
required Qot_Common.Security security = 1;
required Qot_Common.KLType klType = 2;
repeated Qot_Common.KLine kLine = 3;
}
message C2S
{
required string shortName = 1;
required Qot_Common.IndicatorLangType langType = 2;
required IndicatorCalcData data = 3;
optional int32 num = 4;
repeated IndicatorInputItem inputs = 5;
}
message Request
{
required C2S c2s = 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
- 戻り値
message S2C
{
required string calcId = 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
- API呼び出し結果の構造体: RetType
- Example
- Output
int requestIndicatorCalc(QotRequestIndicatorCalc.Request req);
void onReply_RequestIndicatorCalc(MMAPI_Conn client, int nSerialNo, QotRequestIndicatorCalc.Response rsp);
説明
インジケーター計算を非同期で起動します。リクエスト送信後、サーバーは
calcIdを返却し、計算結果はQot_PushIndicatorCalcプッシュで通知されます。パラメータ
message IndicatorInputItem
{
required int32 index = 1;
optional string value = 2;
}
message IndicatorCalcData
{
required Qot_Common.Security security = 1;
required Qot_Common.KLType klType = 2;
repeated Qot_Common.KLine kLine = 3;
}
message C2S
{
required string shortName = 1;
required Qot_Common.IndicatorLangType langType = 2;
required IndicatorCalcData data = 3;
optional int32 num = 4;
repeated IndicatorInputItem inputs = 5;
}
message Request
{
required C2S c2s = 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
- 戻り値
message S2C
{
required string calcId = 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
- API呼び出し結果の構造体: RetType
- Example
- Output
Moomoo::u32_t RequestIndicatorCalc(const Qot_RequestIndicatorCalc::Request &stReq);
virtual void OnReply_RequestIndicatorCalc(Moomoo::u32_t nSerialNo, const Qot_RequestIndicatorCalc::Response &stRsp) = 0;
説明
インジケーター計算を非同期で起動します。リクエスト送信後、サーバーは
calcIdを返却し、計算結果はQot_PushIndicatorCalcプッシュで通知されます。パラメータ
message IndicatorInputItem
{
required int32 index = 1;
optional string value = 2;
}
message IndicatorCalcData
{
required Qot_Common.Security security = 1;
required Qot_Common.KLType klType = 2;
repeated Qot_Common.KLine kLine = 3;
}
message C2S
{
required string shortName = 1;
required Qot_Common.IndicatorLangType langType = 2;
required IndicatorCalcData data = 3;
optional int32 num = 4;
repeated IndicatorInputItem inputs = 5;
}
message Request
{
required C2S c2s = 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
- 戻り値
message S2C
{
required string calcId = 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
- API呼び出し結果の構造体: 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_RequestIndicatorCalc::Request req;
Qot_RequestIndicatorCalc::C2S *c2s = req.mutable_c2s();
c2s->set_shortname("MA");
c2s->set_langtype(Qot_Common::IndicatorLangType_MyLang);
Qot_RequestIndicatorCalc::IndicatorCalcData *data = c2s->mutable_data();
Qot_Common::Security *sec = data->mutable_security();
sec->set_market(Qot_Common::QotMarket_US_Security);
sec->set_code("AAPL");
data->set_kltype(Qot_Common::KLType_Day);
// ここに data->add_kline() で計算対象のK線データを追加します
m_RequestIndicatorCalcSerialNo = m_pQotApi->RequestIndicatorCalc(req);
}
virtual void OnReply_RequestIndicatorCalc(Moomoo::u32_t nSerialNo, const Qot_RequestIndicatorCalc::Response &stRsp) {
if (nSerialNo != m_RequestIndicatorCalcSerialNo) return;
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
// 計算結果は OnPush_PushIndicatorCalc で受信
virtual void OnPush_PushIndicatorCalc(const Qot_PushIndicatorCalc::Response &stRsp) {
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
MMAPI_Qot *m_pQotApi;
Moomoo::u32_t m_RequestIndicatorCalcSerialNo = 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
RequestIndicatorCalc(req);
説明
インジケーター計算を非同期で起動します。リクエスト送信後、サーバーは
calcIdを返却し、計算結果はQot_PushIndicatorCalcプッシュで通知されます。パラメータ
message IndicatorInputItem
{
required int32 index = 1;
optional string value = 2;
}
message IndicatorCalcData
{
required Qot_Common.Security security = 1;
required Qot_Common.KLType klType = 2;
repeated Qot_Common.KLine kLine = 3;
}
message C2S
{
required string shortName = 1;
required Qot_Common.IndicatorLangType langType = 2;
required IndicatorCalcData data = 3;
optional int32 num = 4;
repeated IndicatorInputItem inputs = 5;
}
message Request
{
required C2S c2s = 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
- 戻り値
message S2C
{
required string calcId = 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
- API呼び出し結果の構造体: RetType
- Example
import mmWebsocket from "moomoo-api";
import { Common, Qot_Common } from "moomoo-api/proto";
import beautify from "js-beautify";
function QotRequestIndicatorCalc(){
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: {
shortName: "MA",
langType: 1,
data: {
security: { market: 11, code: "AAPL" },
klType: 2,
kLine: [],
},
},
};
websocket.RequestIndicatorCalc(req)
.then((res) => {
let { errCode, retMsg, retType, s2c } = res
console.log("RequestIndicatorCalc: 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);
}
QotRequestIndicatorCalc()
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
47
48
- Output
RequestIndicatorCalc: errCode 0, retMsg , retType 0
{
"calcId": "1700000000000-0"
}
2
3
4