# 到達価格アラートの設定
- Python
- Proto
- C#
- Java
- C++
- JavaScript
set_price_reminder(code, op, key=None, reminder_type=None, reminder_freq=None, value=None, note=None, reminder_session_list=NONE)
概要
指定銘柄の到達価格アラートの追加、削除、変更、有効化、無効化
パラメータ
パラメータ 型 説明 code str 銘柄コード op SetPriceReminderOp 操作タイプ key int 識別子。新規追加およびすべて削除の場合は入力不要 reminder_type PriceReminderType 到達価格アラートのタイプ。削除・有効化・無効化の場合はこのパラメータを無視 reminder_freq PriceReminderFreq 到達価格アラートの頻度。削除・有効化・無効化の場合はこのパラメータを無視 value float アラート値。削除・有効化・無効化の場合はこのパラメータを無視 小数点以下3桁まで、超過分は切り捨てられますnote str ユーザーが設定する備考。20文字以内のみ対応。削除・有効化・無効化の場合はこのパラメータを無視 reminder_session_list list 米国株到達価格アラートの時間帯リスト。削除・有効化・無効化の場合はこのパラメータを無視 - list内の要素タイプはPriceReminderMarketStatus
- 米国株のデフォルト到達価格アラート時間帯:取引時間中+プレ/アフターマーケット
戻り値
パラメータ 型 説明 ret RET_CODE API呼び出し結果 key int ret == RET_OK の場合、操作対象の到達価格アラートのkeyを返す str ret != RET_OK の場合、エラーの説明を返す Example
from futu import *
import time
class PriceReminderTest(PriceReminderHandlerBase):
def on_recv_rsp(self, rsp_pb):
ret_code, content = super(PriceReminderTest,self).on_recv_rsp(rsp_pb)
if ret_code != RET_OK:
print("PriceReminderTest: error, msg: %s" % content)
return RET_ERROR, content
print("PriceReminderTest ", content) # PriceReminderTest 独自の処理ロジック
return RET_OK, content
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
handler = PriceReminderTest()
quote_ctx.set_handler(handler)
ret, data = quote_ctx.get_market_snapshot(['US.AAPL'])
if ret == RET_OK:
bid_price = data['bid_price'][0] # リアルタイムの最良買い気配値を取得
ask_price = data['ask_price'][0] # リアルタイムの最良売り気配値を取得
# AAPLの全時間帯で最良売り気配値が(ask_price-1)を下回った場合にアラートを設定
ret_ask, ask_data = quote_ctx.set_price_reminder(code='US.AAPL', op=SetPriceReminderOp.ADD, key=None, reminder_type=PriceReminderType.ASK_PRICE_DOWN, reminder_freq=PriceReminderFreq.ALWAYS, value=(ask_price-1), note='123', reminder_session_list=[PriceReminderMarketStatus.US_PRE, PriceReminderMarketStatus.OPEN, PriceReminderMarketStatus.US_AFTER, PriceReminderMarketStatus.US_OVERNIGHT])
if ret_ask == RET_OK:
print('売り気配値が(ask_price-1)を下回った時のリマインダー設定成功:', ask_data)
else:
print('error:', ask_data)
# AAPLの全時間帯で最良買い気配値が(bid_price+1)を上回った場合にアラートを設定
ret_bid, bid_data = quote_ctx.set_price_reminder(code='US.AAPL', op=SetPriceReminderOp.ADD, key=None, reminder_type=PriceReminderType.BID_PRICE_UP, reminder_freq=PriceReminderFreq.ALWAYS, value=(bid_price+1), note='456', reminder_session_list=[PriceReminderMarketStatus.US_PRE, PriceReminderMarketStatus.OPEN, PriceReminderMarketStatus.US_AFTER, PriceReminderMarketStatus.US_OVERNIGHT])
if ret_bid == RET_OK:
print('買い気配値が(bid_price+1)を上回った時のリマインダー設定成功:', bid_data)
else:
print('error:', bid_data)
time.sleep(15)
quote_ctx.close()
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
- Output
売り気配値が(ask_price-1)を下回った時のリマインダー設定成功: 1744022257023211123
買い気配値が(bid_price+1)を上回った時のリマインダー設定成功: 1744022257052794489
2
# Qot_SetPriceReminder.proto
概要
指定銘柄の到達価格アラートの追加、削除、変更、有効化、無効化
パラメータ
enum SetPriceReminderOp
{
SetPriceReminderOp_Unknown = 0;
SetPriceReminderOp_Add = 1; //追加
SetPriceReminderOp_Del = 2; //削除
SetPriceReminderOp_Enable = 3; //有効化
SetPriceReminderOp_Disable = 4; //無効化
SetPriceReminderOp_Modify = 5; //変更
SetPriceReminderOp_DelAll = 6; //この銘柄のすべての到達価格アラートを削除
}
message C2S
{
required Qot_Common.Security security = 1; // 株式
required int32 op = 2; // SetPriceReminderOp, 操作タイプ
optional int64 key = 3; // 到達価格アラートの識別子。GetPriceReminderプロトコルで取得可能。操作対象の到達価格アラートを指定するために使用。新規追加の場合は入力不要
optional int32 type = 4; // Qot_Common::PriceReminderType, アラートタイプ。削除・有効化・無効化の場合はこのフィールドは無視されます
optional int32 freq = 7; // Qot_Common::PriceReminderFreq, アラート頻度タイプ。削除・有効化・無効化の場合はこのフィールドは無視されます
optional double value = 5; // アラート値。削除・有効化・無効化の場合はこのフィールドを無視(小数点以下3桁まで、超過分は切り捨て)
optional string note = 6; // ユーザーが到達価格アラート設定時に付与する備考。20文字以内のみ対応。削除・有効化・無効化の場合はこのフィールドを無視
repeated int32 reminderSessionList = 8; // 到達価格アラートの時間帯リスト。削除・有効化・無効化の場合はこのパラメータを無視。列挙はQot_Common::PriceReminderMarketStatus
}
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
- 株式構造は~を参照: Security
- 提醒タイプ枚举参见 PriceReminderType
- アラート頻度の列挙値は PriceReminderFreq を参照
- 戻り値
message S2C
{
required int64 key = 1; //設定成功の場合は対応するkeyを返し、失敗の場合は0を返す
}
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
- API 呼び出し結果,構造は~を参照: RetType
プロトコル ID
3220
uint SetPriceReminder(QotSetPriceReminder.Request req);
virtual void OnReply_SetPriceReminder(FTAPI_Conn client, uint nSerialNo, QotSetPriceReminder.Response rsp);
概要
指定銘柄の到達価格アラートの追加、削除、変更、有効化、無効化
パラメータ
enum SetPriceReminderOp
{
SetPriceReminderOp_Unknown = 0;
SetPriceReminderOp_Add = 1; //追加
SetPriceReminderOp_Del = 2; //削除
SetPriceReminderOp_Enable = 3; //有効化
SetPriceReminderOp_Disable = 4; //無効化
SetPriceReminderOp_Modify = 5; //変更
SetPriceReminderOp_DelAll = 6; //この銘柄のすべての到達価格アラートを削除
}
message C2S
{
required Qot_Common.Security security = 1; // 株式
required int32 op = 2; // SetPriceReminderOp, 操作タイプ
optional int64 key = 3; // 到達価格アラートの識別子。GetPriceReminderプロトコルで取得可能。操作対象の到達価格アラートを指定するために使用。新規追加の場合は入力不要
optional int32 type = 4; // Qot_Common::PriceReminderType, アラートタイプ。削除・有効化・無効化の場合はこのフィールドは無視されます
optional int32 freq = 7; // Qot_Common::PriceReminderFreq, アラート頻度タイプ。削除・有効化・無効化の場合はこのフィールドは無視されます
optional double value = 5; // アラート値。削除・有効化・無効化の場合はこのフィールドを無視(小数点以下3桁まで、超過分は切り捨て)
optional string note = 6; // ユーザーが到達価格アラート設定時に付与する備考。20文字以内のみ対応。削除・有効化・無効化の場合はこのフィールドを無視
repeated int32 reminderSessionList = 8; // 到達価格アラートの時間帯リスト。削除・有効化・無効化の場合はこのパラメータを無視。列挙はQot_Common::PriceReminderMarketStatus
}
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
- 株式構造は~を参照: Security
- 提醒タイプ枚举参见 PriceReminderType
- アラート頻度の列挙値は PriceReminderFreq を参照
- 戻り値
message S2C
{
required int64 key = 1; //設定成功の場合は対応するkeyを返し、失敗の場合は0を返す
}
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
- API 呼び出し結果,構造は~を参照: RetType
- 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)
{
Console.Write("Qot onInitConnect: ret={0} desc={1} connID={2}\n", errCode, desc, client.GetConnectID());
if (errCode != 0)
return;
QotCommon.Security sec = QotCommon.Security.CreateBuilder()
.SetMarket((int)QotCommon.QotMarket.QotMarket_HK_Security)
.SetCode("00700")
.Build();
QotSetPriceReminder.C2S c2s = QotSetPriceReminder.C2S.CreateBuilder()
.SetSecurity(sec)
.SetOp(QotSetPriceReminder.SetPriceReminderOp.SetPriceReminderOp_Add)
.SetType((int)QotCommon.PriceReminderType.PriceReminderType_PriceUp)
.SetFreq((int)QotCommon.PriceReminderFreq.PriceReminderFreq_OnlyOnce)
.SetValue(5)
.Build();
QotSetPriceReminder.Request req = QotSetPriceReminder.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.SetPriceReminder(req);
Console.Write("Send QotSetPriceReminder: {0}\n", seqNo);
}
public void OnDisconnect(FTAPI_Conn client, long errCode) {
Console.Write("Qot onDisConnect: {0}\n", errCode);
}
public void OnReply_SetPriceReminder(FTAPI_Conn client, uint nSerialNo, QotSetPriceReminder.Response rsp)
{
Console.Write("Reply: QotSetPriceReminder: {0} {1}\n", nSerialNo, rsp.ToString());
Console.Write("key: {0} \n", rsp.S2C.Key);
}
public static void Main(String[] args) {
FTAPI.Init();
Program qot = new Program();
qot.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
- Output
Qot onInitConnect: ret=0 desc= connID=6826782725947038940
Send QotSetPriceReminder: 3
Reply: QotSetPriceReminder: 3 retType: 0
retMsg: ""
errCode: 0
s2c {
key: 162763183755472101
}
key: 162763183755472101
2
3
4
5
6
7
8
9
10
int setPriceReminder(QotSetPriceReminder.Request req);
void onReply_SetPriceReminder(FTAPI_Conn client, int nSerialNo, QotSetPriceReminder.Response rsp);
概要
指定銘柄の到達価格アラートの追加、削除、変更、有効化、無効化
パラメータ
enum SetPriceReminderOp
{
SetPriceReminderOp_Unknown = 0;
SetPriceReminderOp_Add = 1; //追加
SetPriceReminderOp_Del = 2; //削除
SetPriceReminderOp_Enable = 3; //有効化
SetPriceReminderOp_Disable = 4; //無効化
SetPriceReminderOp_Modify = 5; //変更
SetPriceReminderOp_DelAll = 6; //この銘柄のすべての到達価格アラートを削除
}
message C2S
{
required Qot_Common.Security security = 1; // 株式
required int32 op = 2; // SetPriceReminderOp, 操作タイプ
optional int64 key = 3; // 到達価格アラートの識別子。GetPriceReminderプロトコルで取得可能。操作対象の到達価格アラートを指定するために使用。新規追加の場合は入力不要
optional int32 type = 4; // Qot_Common::PriceReminderType, アラートタイプ。削除・有効化・無効化の場合はこのフィールドは無視されます
optional int32 freq = 7; // Qot_Common::PriceReminderFreq, アラート頻度タイプ。削除・有効化・無効化の場合はこのフィールドは無視されます
optional double value = 5; // アラート値。削除・有効化・無効化の場合はこのフィールドを無視(小数点以下3桁まで、超過分は切り捨て)
optional string note = 6; // ユーザーが到達価格アラート設定時に付与する備考。20文字以内のみ対応。削除・有効化・無効化の場合はこのフィールドを無視
repeated int32 reminderSessionList = 8; // 到達価格アラートの時間帯リスト。削除・有効化・無効化の場合はこのパラメータを無視。列挙はQot_Common::PriceReminderMarketStatus
}
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
- 株式構造は~を参照: Security
- 提醒タイプ枚举参见 PriceReminderType
- アラート頻度の列挙値は PriceReminderFreq を参照
- 戻り値
message S2C
{
required int64 key = 1; //設定成功の場合は対応するkeyを返し、失敗の場合は0を返す
}
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
- API 呼び出し結果,構造は~を参照: RetType
- Example
public class QotDemo implements FTSPI_Qot, FTSPI_Conn {
FTAPI_Conn_Qot qot = new FTAPI_Conn_Qot();
public QotDemo() {
qot.setClientInfo("javaclient", 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)
{
System.out.printf("Qot onInitConnect: ret=%b desc=%s connID=%d\n", errCode, desc, client.getConnectID());
if (errCode != 0)
return;
QotCommon.Security sec = QotCommon.Security.newBuilder()
.setMarket(QotCommon.QotMarket.QotMarket_HK_Security_VALUE)
.setCode("00700")
.build();
QotSetPriceReminder.C2S c2s = QotSetPriceReminder.C2S.newBuilder()
.setSecurity(sec)
.setOp(QotSetPriceReminder.SetPriceReminderOp.SetPriceReminderOp_Add_VALUE)
.setType(QotCommon.PriceReminderType.PriceReminderType_PriceUp_VALUE)
.setFreq(QotCommon.PriceReminderFreq.PriceReminderFreq_OnlyOnce_VALUE)
.setValue(5)
.build();
QotSetPriceReminder.Request req = QotSetPriceReminder.Request.newBuilder().setC2S(c2s).build();
int seqNo = qot.setPriceReminder(req);
System.out.printf("Send QotSetPriceReminder: %d\n", seqNo);
}
@Override
public void onDisconnect(FTAPI_Conn client, long errCode) {
System.out.printf("Qot onDisConnect: %d\n", errCode);
}
@Override
public void onReply_SetPriceReminder(FTAPI_Conn client, int nSerialNo, QotSetPriceReminder.Response rsp) {
if (rsp.getRetType() != 0) {
System.out.printf("QotSetPriceReminder failed: %s\n", rsp.getRetMsg());
}
else {
try {
String json = JsonFormat.printer().print(rsp);
System.out.printf("Receive QotSetPriceReminder: %s\n", json);
} catch (InvalidProtocolBufferException e) {
e.printStackTrace();
}
}
}
public static void main(String[] args) {
FTAPI.init();
QotDemo qot = new QotDemo();
qot.start();
while (true) {
try {
Thread.sleep(1000 * 600);
} catch (InterruptedException exc) {
}
}
}
}
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
- Output
Send QotSetPriceReminder: 2
Receive QotSetPriceReminder: {
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"key": "162452649832682701"
}
}
2
3
4
5
6
7
8
9
Futu::u32_t SetPriceReminder(const Qot_SetPriceReminder::Request &stReq);
virtual void OnReply_SetPriceReminder(Futu::u32_t nSerialNo, const Qot_SetPriceReminder::Response &stRsp) = 0;
概要
指定銘柄の到達価格アラートの追加、削除、変更、有効化、無効化
パラメータ
enum SetPriceReminderOp
{
SetPriceReminderOp_Unknown = 0;
SetPriceReminderOp_Add = 1; //追加
SetPriceReminderOp_Del = 2; //削除
SetPriceReminderOp_Enable = 3; //有効化
SetPriceReminderOp_Disable = 4; //無効化
SetPriceReminderOp_Modify = 5; //変更
SetPriceReminderOp_DelAll = 6; //この銘柄のすべての到達価格アラートを削除
}
message C2S
{
required Qot_Common.Security security = 1; // 株式
required int32 op = 2; // SetPriceReminderOp, 操作タイプ
optional int64 key = 3; // 到達価格アラートの識別子。GetPriceReminderプロトコルで取得可能。操作対象の到達価格アラートを指定するために使用。新規追加の場合は入力不要
optional int32 type = 4; // Qot_Common::PriceReminderType, アラートタイプ。削除・有効化・無効化の場合はこのフィールドは無視されます
optional int32 freq = 7; // Qot_Common::PriceReminderFreq, アラート頻度タイプ。削除・有効化・無効化の場合はこのフィールドは無視されます
optional double value = 5; // アラート値。削除・有効化・無効化の場合はこのフィールドを無視(小数点以下3桁まで、超過分は切り捨て)
optional string note = 6; // ユーザーが到達価格アラート設定時に付与する備考。20文字以内のみ対応。削除・有効化・無効化の場合はこのフィールドを無視
repeated int32 reminderSessionList = 8; // 到達価格アラートの時間帯リスト。削除・有効化・無効化の場合はこのパラメータを無視。列挙はQot_Common::PriceReminderMarketStatus
}
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
- 株式構造は~を参照: Security
- 提醒タイプ枚举参见 PriceReminderType
- アラート頻度の列挙値は PriceReminderFreq を参照
- 戻り値
message S2C
{
required int64 key = 1; //設定成功の場合は対応するkeyを返し、失敗の場合は0を返す
}
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
- API 呼び出し結果,構造は~を参照: RetType
- Example
class Program : public FTSPI_Qot, public FTSPI_Trd, 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) {
cout << "connect" << endl;
// パケット生成
Qot_SetPriceReminder::Request req;
Qot_SetPriceReminder::C2S *c2s = req.mutable_c2s();
Qot_Common::Security *sec = c2s->mutable_security();
sec->set_code("00700");
sec->set_market(Qot_Common::QotMarket::QotMarket_HK_Security);
c2s->set_op(1);
c2s->set_type(Qot_Common::PriceReminderType::PriceReminderType_PriceUp);
c2s->set_freq(Qot_Common::PriceReminderFreq::PriceReminderFreq_OnlyOnce);
c2s->set_value(5);
m_SetPriceReminderSerialNo = m_pQotApi->SetPriceReminder(req);
cout << "Request SetPriceReminder SerialNo: " << m_SetPriceReminderSerialNo << endl;
}
virtual void OnReply_SetPriceReminder(Futu::u32_t nSerialNo, const Qot_SetPriceReminder::Response &stRsp){
if(nSerialNo == m_SetPriceReminderSerialNo)
{
cout << "OnReply_SetPriceReminder SerialNo: " << nSerialNo << endl;
// 内部構造を解析して出力
// ProtoBufToBodyData と UTF8ToLocal 関数の定義は Sample の tool.h ファイルを参照
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
}
protected:
FTAPI_Qot *m_pQotApi;
Futu::u32_t m_SetPriceReminderSerialNo;
};
int32_t main(int32_t argc, char** argv)
{
FTAPI::Init();
{
Program program;
program.Start();
getchar();
}
protobuf::ShutdownProtobufLibrary();
FTAPI::UnInit();
return 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
- Output
connect
Request SetPriceReminder SerialNo: 3
OnReply_SetPriceReminder SerialNo: 3
{
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"key": "162320791658522901"
}
}
2
3
4
5
6
7
8
9
10
11
12
SetPriceReminder(req);
概要
指定銘柄の到達価格アラートの追加、削除、変更、有効化、無効化
パラメータ
enum SetPriceReminderOp
{
SetPriceReminderOp_Unknown = 0;
SetPriceReminderOp_Add = 1; //追加
SetPriceReminderOp_Del = 2; //削除
SetPriceReminderOp_Enable = 3; //有効化
SetPriceReminderOp_Disable = 4; //無効化
SetPriceReminderOp_Modify = 5; //変更
SetPriceReminderOp_DelAll = 6; //この銘柄のすべての到達価格アラートを削除
}
message C2S
{
required Qot_Common.Security security = 1; // 株式
required int32 op = 2; // SetPriceReminderOp, 操作タイプ
optional int64 key = 3; // 到達価格アラートの識別子。GetPriceReminderプロトコルで取得可能。操作対象の到達価格アラートを指定するために使用。新規追加の場合は入力不要
optional int32 type = 4; // Qot_Common::PriceReminderType, アラートタイプ。削除・有効化・無効化の場合はこのフィールドは無視されます
optional int32 freq = 7; // Qot_Common::PriceReminderFreq, アラート頻度タイプ。削除・有効化・無効化の場合はこのフィールドは無視されます
optional double value = 5; // アラート値。削除・有効化・無効化の場合はこのフィールドを無視(小数点以下3桁まで、超過分は切り捨て)
optional string note = 6; // ユーザーが到達価格アラート設定時に付与する備考。20文字以内のみ対応。削除・有効化・無効化の場合はこのフィールドを無視
repeated int32 reminderSessionList = 8; // 到達価格アラートの時間帯リスト。削除・有効化・無効化の場合はこのパラメータを無視。列挙はQot_Common::PriceReminderMarketStatus
}
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
- 株式構造は~を参照: Security
- 提醒タイプ枚举参见 PriceReminderType
- アラート頻度の列挙値は PriceReminderFreq を参照
- 戻り値
message S2C
{
required int64 key = 1; //設定成功の場合は対応するkeyを返し、失敗の場合は0を返す
}
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
- API 呼び出し結果,構造は~を参照: RetType
- Example
import ftWebsocket from "futu-api";
import { ftCmdID } from "futu-api";
import { Common, Qot_Common, Qot_SetPriceReminder } from "futu-api/proto";
import beautify from "js-beautify";
function QotSetPriceReminder(){
const { RetType } = Common
const { PriceReminderType, PriceReminderFreq, QotMarket } = Qot_Common
const { SetPriceReminderOp } = Qot_SetPriceReminder
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: {
security: {
market: QotMarket.QotMarket_HK_Security,
code: "00700",
},
op: SetPriceReminderOp.SetPriceReminderOp_Add,
type: PriceReminderType.PriceReminderType_PriceUp,
freq: PriceReminderFreq.PriceReminderFreq_Always,
value: 600,
},
};
websocket.SetPriceReminder(req)
.then((res) => {
let { errCode, retMsg, retType,s2c } = res
console.log("PriceReminder: 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("error", msg);
}
};
websocket.start(addr, port, enable_ssl, key);
//相場接続をクローズ。使用後は接続をクローズしてください。不要なリソース占有を防ぎます
//OpenD は最大 128 接続に制限されています
//1 ページまたは 1 プロジェクトで 1 接続を維持することも可能。ここではサンプルとしてリクエストごとに 1 接続を作成
setTimeout(()=>{
websocket.stop();
console.log("stop");
}, 5000); // 5 秒後に切断
}
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
57
- Output
PriceReminder: errCode 0, retMsg , retType 0
{
"key": "163126377342664201"
}
stop
2
3
4
5
ご注意
APIでの出来高設定はすべて株数単位です。ただしmoomooクライアントでは、A株は手(100株)単位で表示されます
到達価格アラートタイプには最小精度があります。以下の通り:
TURNOVER_UP:売買代金の最小精度は10元(人民元、香港ドル、米ドル)。入力値は自動的に最小精度の整数倍に切り捨てられます。例:【00700の売買代金102元アラート】を設定すると【00700の売買代金100元アラート】になります。【00700の売買代金8元アラート】を設定すると【00700の売買代金0元アラート】になります。
VOLUME_UP:A株の出来高の最小精度は1000株、その他の市場の株式は10株。入力値は自動的に最小精度の整数倍に切り捨てられます。
BID_VOL_UP、ASK_VOL_UP:A株の最良気配注文数量の最小精度は100株。入力値は自動的に最小精度の整数倍に切り捨てられます。
其余到達価格アラートタイプ精度対応到小数点后 3 位
APIレート制限
- 每 30 秒内最多リクエスト 60 次設定到達価格アラートAPI
- 各銘柄の各タイプで設定可能なアラートの上限は10件です
- Python
- Proto
- C#
- Java
- C++
- JavaScript
set_price_reminder(code, op, key=None, reminder_type=None, reminder_freq=None, value=None, note=None)
概要
指定銘柄の到達価格アラートの追加、削除、変更、有効化、無効化
パラメータ
パラメータ 型 説明 code str 銘柄コード op SetPriceReminderOp 操作タイプ key int 識別子。新規追加およびすべて削除の場合は入力不要 reminder_type PriceReminderType 到達価格アラートのタイプ。削除・有効化・無効化の場合はこのパラメータを無視 reminder_freq PriceReminderFreq 到達価格アラートの頻度。削除・有効化・無効化の場合はこのパラメータを無視 value float アラート値。削除・有効化・無効化の場合はこのパラメータを無視 小数点以下3桁まで、超過分は切り捨てられますnote str ユーザーが設定する備考。20文字以内のみ対応。削除・有効化・無効化の場合はこのパラメータを無視 reminder_session_list list 米国株到達価格アラートの時間帯リスト。削除・有効化・無効化の場合はこのパラメータを無視 - list内の要素タイプはPriceReminderMarketStatus
- 米国株のデフォルト到達価格アラート時間帯:取引時間中+プレ/アフターマーケット
戻り値
パラメータ 型 説明 ret RET_CODE API呼び出し結果 key int ret == RET_OK の場合、操作対象の到達価格アラートのkeyを返す str ret != RET_OK の場合、エラーの説明を返す Example
from moomoo import *
import time
class PriceReminderTest(PriceReminderHandlerBase):
def on_recv_rsp(self, rsp_pb):
ret_code, content = super(PriceReminderTest,self).on_recv_rsp(rsp_pb)
if ret_code != RET_OK:
print("PriceReminderTest: error, msg: %s" % content)
return RET_ERROR, content
print("PriceReminderTest ", content) # PriceReminderTest 独自の処理ロジック
return RET_OK, content
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
handler = PriceReminderTest()
quote_ctx.set_handler(handler)
ret, data = quote_ctx.get_market_snapshot(['US.AAPL'])
if ret == RET_OK:
bid_price = data['bid_price'][0] # リアルタイムの最良買い気配値を取得
ask_price = data['ask_price'][0] # リアルタイムの最良売り気配値を取得
# AAPLの全時間帯で最良売り気配値が(ask_price-1)を下回った場合にアラートを設定
ret_ask, ask_data = quote_ctx.set_price_reminder(code='US.AAPL', op=SetPriceReminderOp.ADD, key=None, reminder_type=PriceReminderType.ASK_PRICE_DOWN, reminder_freq=PriceReminderFreq.ALWAYS, value=(ask_price-1), note='123', reminder_session_list=[PriceReminderMarketStatus.US_PRE, PriceReminderMarketStatus.OPEN, PriceReminderMarketStatus.US_AFTER, PriceReminderMarketStatus.US_OVERNIGHT])
if ret_ask == RET_OK:
print('売り気配値が(ask_price-1)を下回った時のリマインダー設定成功:', ask_data)
else:
print('error:', ask_data)
# AAPLの全時間帯で最良買い気配値が(bid_price+1)を上回った場合にアラートを設定
ret_bid, bid_data = quote_ctx.set_price_reminder(code='US.AAPL', op=SetPriceReminderOp.ADD, key=None, reminder_type=PriceReminderType.BID_PRICE_UP, reminder_freq=PriceReminderFreq.ALWAYS, value=(bid_price+1), note='456', reminder_session_list=[PriceReminderMarketStatus.US_PRE, PriceReminderMarketStatus.OPEN, PriceReminderMarketStatus.US_AFTER, PriceReminderMarketStatus.US_OVERNIGHT])
if ret_bid == RET_OK:
print('買い気配値が(bid_price+1)を上回った時のリマインダー設定成功:', bid_data)
else:
print('error:', bid_data)
time.sleep(15)
quote_ctx.close()
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
- Output
売り気配値が(ask_price-1)を下回った時のリマインダー設定成功: 1744022257023211123
買い気配値が(bid_price+1)を上回った時のリマインダー設定成功: 1744022257052794489
2
# Qot_SetPriceReminder.proto
概要
指定銘柄の到達価格アラートの追加、削除、変更、有効化、無効化
パラメータ
enum SetPriceReminderOp
{
SetPriceReminderOp_Unknown = 0;
SetPriceReminderOp_Add = 1; //追加
SetPriceReminderOp_Del = 2; //削除
SetPriceReminderOp_Enable = 3; //有効化
SetPriceReminderOp_Disable = 4; //無効化
SetPriceReminderOp_Modify = 5; //変更
SetPriceReminderOp_DelAll = 6; //この銘柄のすべての到達価格アラートを削除
}
message C2S
{
required Qot_Common.Security security = 1; // 株式
required int32 op = 2; // SetPriceReminderOp, 操作タイプ
optional int64 key = 3; // 到達価格アラートの識別子。GetPriceReminderプロトコルで取得可能。操作対象の到達価格アラートを指定するために使用。新規追加の場合は入力不要
optional int32 type = 4; // Qot_Common::PriceReminderType, アラートタイプ。削除・有効化・無効化の場合はこのフィールドは無視されます
optional int32 freq = 7; // Qot_Common::PriceReminderFreq, アラート頻度タイプ。削除・有効化・無効化の場合はこのフィールドは無視されます
optional double value = 5; // アラート値。削除・有効化・無効化の場合はこのフィールドを無視(小数点以下3桁まで、超過分は切り捨て)
optional string note = 6; // ユーザーが到達価格アラート設定時に付与する備考。20文字以内のみ対応。削除・有効化・無効化の場合はこのフィールドを無視
repeated int32 reminderSessionList = 8; // 到達価格アラートの時間帯リスト。削除・有効化・無効化の場合はこのパラメータを無視。列挙はQot_Common::PriceReminderMarketStatus
}
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
- 株式構造は~を参照: Security
- 提醒タイプ枚举参见 PriceReminderType
- アラート頻度の列挙値は PriceReminderFreq を参照
- 戻り値
message S2C
{
required int64 key = 1; //設定成功の場合は対応するkeyを返し、失敗の場合は0を返す
}
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
- API 呼び出し結果,構造は~を参照: RetType
プロトコル ID
3220
uint SetPriceReminder(QotSetPriceReminder.Request req);
virtual void OnReply_SetPriceReminder(MMAPI_Conn client, uint nSerialNo, QotSetPriceReminder.Response rsp);
概要
指定銘柄の到達価格アラートの追加、削除、変更、有効化、無効化
パラメータ
enum SetPriceReminderOp
{
SetPriceReminderOp_Unknown = 0;
SetPriceReminderOp_Add = 1; //追加
SetPriceReminderOp_Del = 2; //削除
SetPriceReminderOp_Enable = 3; //有効化
SetPriceReminderOp_Disable = 4; //無効化
SetPriceReminderOp_Modify = 5; //変更
SetPriceReminderOp_DelAll = 6; //この銘柄のすべての到達価格アラートを削除
}
message C2S
{
required Qot_Common.Security security = 1; // 株式
required int32 op = 2; // SetPriceReminderOp, 操作タイプ
optional int64 key = 3; // 到達価格アラートの識別子。GetPriceReminderプロトコルで取得可能。操作対象の到達価格アラートを指定するために使用。新規追加の場合は入力不要
optional int32 type = 4; // Qot_Common::PriceReminderType, アラートタイプ。削除・有効化・無効化の場合はこのフィールドは無視されます
optional int32 freq = 7; // Qot_Common::PriceReminderFreq, アラート頻度タイプ。削除・有効化・無効化の場合はこのフィールドは無視されます
optional double value = 5; // アラート値。削除・有効化・無効化の場合はこのフィールドを無視(小数点以下3桁まで、超過分は切り捨て)
optional string note = 6; // ユーザーが到達価格アラート設定時に付与する備考。20文字以内のみ対応。削除・有効化・無効化の場合はこのフィールドを無視
repeated int32 reminderSessionList = 8; // 到達価格アラートの時間帯リスト。削除・有効化・無効化の場合はこのパラメータを無視。列挙はQot_Common::PriceReminderMarketStatus
}
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
- 株式構造は~を参照: Security
- 提醒タイプ枚举参见 PriceReminderType
- アラート頻度の列挙値は PriceReminderFreq を参照
- 戻り値
message S2C
{
required int64 key = 1; //設定成功の場合は対応するkeyを返し、失敗の場合は0を返す
}
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
- API 呼び出し結果,構造は~を参照: RetType
- 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)
{
Console.Write("Qot onInitConnect: ret={0} desc={1} connID={2}\n", errCode, desc, client.GetConnectID());
if (errCode != 0)
return;
QotCommon.Security sec = QotCommon.Security.CreateBuilder()
.SetMarket((int)QotCommon.QotMarket.QotMarket_HK_Security)
.SetCode("00700")
.Build();
QotSetPriceReminder.C2S c2s = QotSetPriceReminder.C2S.CreateBuilder()
.SetSecurity(sec)
.SetOp(QotSetPriceReminder.SetPriceReminderOp.SetPriceReminderOp_Add)
.SetType((int)QotCommon.PriceReminderType.PriceReminderType_PriceUp)
.SetFreq((int)QotCommon.PriceReminderFreq.PriceReminderFreq_OnlyOnce)
.SetValue(5)
.Build();
QotSetPriceReminder.Request req = QotSetPriceReminder.Request.CreateBuilder().SetC2S(c2s).Build();
uint seqNo = qot.SetPriceReminder(req);
Console.Write("Send QotSetPriceReminder: {0}\n", seqNo);
}
public void OnDisconnect(MMAPI_Conn client, long errCode) {
Console.Write("Qot onDisConnect: {0}\n", errCode);
}
public void OnReply_SetPriceReminder(MMAPI_Conn client, uint nSerialNo, QotSetPriceReminder.Response rsp)
{
Console.Write("Reply: QotSetPriceReminder: {0} {1}\n", nSerialNo, rsp.ToString());
Console.Write("key: {0} \n", rsp.S2C.Key);
}
public static void Main(String[] args) {
MMAPI.Init();
Program qot = new Program();
qot.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
- Output
Qot onInitConnect: ret=0 desc= connID=6826782725947038940
Send QotSetPriceReminder: 3
Reply: QotSetPriceReminder: 3 retType: 0
retMsg: ""
errCode: 0
s2c {
key: 162763183755472101
}
key: 162763183755472101
2
3
4
5
6
7
8
9
10
int setPriceReminder(QotSetPriceReminder.Request req);
void onReply_SetPriceReminder(MMAPI_Conn client, int nSerialNo, QotSetPriceReminder.Response rsp);
概要
指定銘柄の到達価格アラートの追加、削除、変更、有効化、無効化
パラメータ
enum SetPriceReminderOp
{
SetPriceReminderOp_Unknown = 0;
SetPriceReminderOp_Add = 1; //追加
SetPriceReminderOp_Del = 2; //削除
SetPriceReminderOp_Enable = 3; //有効化
SetPriceReminderOp_Disable = 4; //無効化
SetPriceReminderOp_Modify = 5; //変更
SetPriceReminderOp_DelAll = 6; //この銘柄のすべての到達価格アラートを削除
}
message C2S
{
required Qot_Common.Security security = 1; // 株式
required int32 op = 2; // SetPriceReminderOp, 操作タイプ
optional int64 key = 3; // 到達価格アラートの識別子。GetPriceReminderプロトコルで取得可能。操作対象の到達価格アラートを指定するために使用。新規追加の場合は入力不要
optional int32 type = 4; // Qot_Common::PriceReminderType, アラートタイプ。削除・有効化・無効化の場合はこのフィールドは無視されます
optional int32 freq = 7; // Qot_Common::PriceReminderFreq, アラート頻度タイプ。削除・有効化・無効化の場合はこのフィールドは無視されます
optional double value = 5; // アラート値。削除・有効化・無効化の場合はこのフィールドを無視(小数点以下3桁まで、超過分は切り捨て)
optional string note = 6; // ユーザーが到達価格アラート設定時に付与する備考。20文字以内のみ対応。削除・有効化・無効化の場合はこのフィールドを無視
repeated int32 reminderSessionList = 8; // 到達価格アラートの時間帯リスト。削除・有効化・無効化の場合はこのパラメータを無視。列挙はQot_Common::PriceReminderMarketStatus
}
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
- 株式構造は~を参照: Security
- 提醒タイプ枚举参见 PriceReminderType
- アラート頻度の列挙値は PriceReminderFreq を参照
- 戻り値
message S2C
{
required int64 key = 1; //設定成功の場合は対応するkeyを返し、失敗の場合は0を返す
}
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
- API 呼び出し結果,構造は~を参照: RetType
- Example
public class QotDemo implements MMSPI_Qot, MMSPI_Conn {
MMAPI_Conn_Qot qot = new MMAPI_Conn_Qot();
public QotDemo() {
qot.setClientInfo("javaclient", 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)
{
System.out.printf("Qot onInitConnect: ret=%b desc=%s connID=%d\n", errCode, desc, client.getConnectID());
if (errCode != 0)
return;
QotCommon.Security sec = QotCommon.Security.newBuilder()
.setMarket(QotCommon.QotMarket.QotMarket_HK_Security_VALUE)
.setCode("00700")
.build();
QotSetPriceReminder.C2S c2s = QotSetPriceReminder.C2S.newBuilder()
.setSecurity(sec)
.setOp(QotSetPriceReminder.SetPriceReminderOp.SetPriceReminderOp_Add_VALUE)
.setType(QotCommon.PriceReminderType.PriceReminderType_PriceUp_VALUE)
.setFreq(QotCommon.PriceReminderFreq.PriceReminderFreq_OnlyOnce_VALUE)
.setValue(5)
.build();
QotSetPriceReminder.Request req = QotSetPriceReminder.Request.newBuilder().setC2S(c2s).build();
int seqNo = qot.setPriceReminder(req);
System.out.printf("Send QotSetPriceReminder: %d\n", seqNo);
}
@Override
public void onDisconnect(MMAPI_Conn client, long errCode) {
System.out.printf("Qot onDisConnect: %d\n", errCode);
}
@Override
public void onReply_SetPriceReminder(MMAPI_Conn client, int nSerialNo, QotSetPriceReminder.Response rsp) {
if (rsp.getRetType() != 0) {
System.out.printf("QotSetPriceReminder failed: %s\n", rsp.getRetMsg());
}
else {
try {
String json = JsonFormat.printer().print(rsp);
System.out.printf("Receive QotSetPriceReminder: %s\n", json);
} catch (InvalidProtocolBufferException e) {
e.printStackTrace();
}
}
}
public static void main(String[] args) {
MMAPI.init();
QotDemo qot = new QotDemo();
qot.start();
while (true) {
try {
Thread.sleep(1000 * 600);
} catch (InterruptedException exc) {
}
}
}
}
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
- Output
Send QotSetPriceReminder: 2
Receive QotSetPriceReminder: {
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"key": "162452649832682701"
}
}
2
3
4
5
6
7
8
9
moomoo::u32_t SetPriceReminder(const Qot_SetPriceReminder::Request &stReq);
virtual void OnReply_SetPriceReminder(moomoo::u32_t nSerialNo, const Qot_SetPriceReminder::Response &stRsp) = 0;
概要
指定銘柄の到達価格アラートの追加、削除、変更、有効化、無効化
パラメータ
enum SetPriceReminderOp
{
SetPriceReminderOp_Unknown = 0;
SetPriceReminderOp_Add = 1; //追加
SetPriceReminderOp_Del = 2; //削除
SetPriceReminderOp_Enable = 3; //有効化
SetPriceReminderOp_Disable = 4; //無効化
SetPriceReminderOp_Modify = 5; //変更
SetPriceReminderOp_DelAll = 6; //この銘柄のすべての到達価格アラートを削除
}
message C2S
{
required Qot_Common.Security security = 1; // 株式
required int32 op = 2; // SetPriceReminderOp, 操作タイプ
optional int64 key = 3; // 到達価格アラートの識別子。GetPriceReminderプロトコルで取得可能。操作対象の到達価格アラートを指定するために使用。新規追加の場合は入力不要
optional int32 type = 4; // Qot_Common::PriceReminderType, アラートタイプ。削除・有効化・無効化の場合はこのフィールドは無視されます
optional int32 freq = 7; // Qot_Common::PriceReminderFreq, アラート頻度タイプ。削除・有効化・無効化の場合はこのフィールドは無視されます
optional double value = 5; // アラート値。削除・有効化・無効化の場合はこのフィールドを無視(小数点以下3桁まで、超過分は切り捨て)
optional string note = 6; // ユーザーが到達価格アラート設定時に付与する備考。20文字以内のみ対応。削除・有効化・無効化の場合はこのフィールドを無視
repeated int32 reminderSessionList = 8; // 到達価格アラートの時間帯リスト。削除・有効化・無効化の場合はこのパラメータを無視。列挙はQot_Common::PriceReminderMarketStatus
}
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
- 株式構造は~を参照: Security
- 提醒タイプ枚举参见 PriceReminderType
- アラート頻度の列挙値は PriceReminderFreq を参照
- 戻り値
message S2C
{
required int64 key = 1; //設定成功の場合は対応するkeyを返し、失敗の場合は0を返す
}
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
- API 呼び出し結果,構造は~を参照: RetType
- Example
class Program : public MMSPI_Qot, public MMSPI_Trd, 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) {
cout << "connect" << endl;
// パケット生成
Qot_SetPriceReminder::Request req;
Qot_SetPriceReminder::C2S *c2s = req.mutable_c2s();
Qot_Common::Security *sec = c2s->mutable_security();
sec->set_code("00700");
sec->set_market(Qot_Common::QotMarket::QotMarket_HK_Security);
c2s->set_op(1);
c2s->set_type(Qot_Common::PriceReminderType::PriceReminderType_PriceUp);
c2s->set_freq(Qot_Common::PriceReminderFreq::PriceReminderFreq_OnlyOnce);
c2s->set_value(5);
m_SetPriceReminderSerialNo = m_pQotApi->SetPriceReminder(req);
cout << "Request SetPriceReminder SerialNo: " << m_SetPriceReminderSerialNo << endl;
}
virtual void OnReply_SetPriceReminder(moomoo::u32_t nSerialNo, const Qot_SetPriceReminder::Response &stRsp){
if(nSerialNo == m_SetPriceReminderSerialNo)
{
cout << "OnReply_SetPriceReminder SerialNo: " << nSerialNo << endl;
// 内部構造を解析して出力
// ProtoBufToBodyData と UTF8ToLocal 関数の定義は Sample の tool.h ファイルを参照
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
}
protected:
MMAPI_Qot *m_pQotApi;
moomoo::u32_t m_SetPriceReminderSerialNo;
};
int32_t main(int32_t argc, char** argv)
{
MMAPI::Init();
{
Program program;
program.Start();
getchar();
}
protobuf::ShutdownProtobufLibrary();
MMAPI::UnInit();
return 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
- Output
connect
Request SetPriceReminder SerialNo: 3
OnReply_SetPriceReminder SerialNo: 3
{
"retType": 0,
"retMsg": "",
"errCode": 0,
"s2c": {
"key": "162320791658522901"
}
}
2
3
4
5
6
7
8
9
10
11
12
SetPriceReminder(req);
概要
指定銘柄の到達価格アラートの追加、削除、変更、有効化、無効化
パラメータ
enum SetPriceReminderOp
{
SetPriceReminderOp_Unknown = 0;
SetPriceReminderOp_Add = 1; //追加
SetPriceReminderOp_Del = 2; //削除
SetPriceReminderOp_Enable = 3; //有効化
SetPriceReminderOp_Disable = 4; //無効化
SetPriceReminderOp_Modify = 5; //変更
SetPriceReminderOp_DelAll = 6; //この銘柄のすべての到達価格アラートを削除
}
message C2S
{
required Qot_Common.Security security = 1; // 株式
required int32 op = 2; // SetPriceReminderOp, 操作タイプ
optional int64 key = 3; // 到達価格アラートの識別子。GetPriceReminderプロトコルで取得可能。操作対象の到達価格アラートを指定するために使用。新規追加の場合は入力不要
optional int32 type = 4; // Qot_Common::PriceReminderType, アラートタイプ。削除・有効化・無効化の場合はこのフィールドは無視されます
optional int32 freq = 7; // Qot_Common::PriceReminderFreq, アラート頻度タイプ。削除・有効化・無効化の場合はこのフィールドは無視されます
optional double value = 5; // アラート値。削除・有効化・無効化の場合はこのフィールドを無視(小数点以下3桁まで、超過分は切り捨て)
optional string note = 6; // ユーザーが到達価格アラート設定時に付与する備考。20文字以内のみ対応。削除・有効化・無効化の場合はこのフィールドを無視
repeated int32 reminderSessionList = 8; // 到達価格アラートの時間帯リスト。削除・有効化・無効化の場合はこのパラメータを無視。列挙はQot_Common::PriceReminderMarketStatus
}
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
- 株式構造は~を参照: Security
- 提醒タイプ枚举参见 PriceReminderType
- アラート頻度の列挙値は PriceReminderFreq を参照
- 戻り値
message S2C
{
required int64 key = 1; //設定成功の場合は対応するkeyを返し、失敗の場合は0を返す
}
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
- API 呼び出し結果,構造は~を参照: RetType
- Example
import mmWebsocket from "moomoo-api";
import { mmCmdID } from "moomoo-api";
import { Common, Qot_Common, Qot_SetPriceReminder } from "moomoo-api/proto";
import beautify from "js-beautify";
function QotSetPriceReminder(){
const { RetType } = Common
const { PriceReminderType, PriceReminderFreq, QotMarket } = Qot_Common
const { SetPriceReminderOp } = Qot_SetPriceReminder
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: {
security: {
market: QotMarket.QotMarket_HK_Security,
code: "00700",
},
op: SetPriceReminderOp.SetPriceReminderOp_Add,
type: PriceReminderType.PriceReminderType_PriceUp,
freq: PriceReminderFreq.PriceReminderFreq_Always,
value: 600,
},
};
websocket.SetPriceReminder(req)
.then((res) => {
let { errCode, retMsg, retType,s2c } = res
console.log("PriceReminder: 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("error", msg);
}
};
websocket.start(addr, port, enable_ssl, key);
//相場接続をクローズ。使用後は接続をクローズしてください。不要なリソース占有を防ぎます
//OpenD は最大 128 接続に制限されています
//1 ページまたは 1 プロジェクトで 1 接続を維持することも可能。ここではサンプルとしてリクエストごとに 1 接続を作成
setTimeout(()=>{
websocket.stop();
console.log("stop");
}, 5000); // 5 秒後に切断
}
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
57
- Output
PriceReminder: errCode 0, retMsg , retType 0
{
"key": "163126377342664201"
}
stop
2
3
4
5
ご注意
APIでの出来高設定はすべて株数単位です。ただしmoomooクライアントでは、A株は手(100株)単位で表示されます
到達価格アラートタイプには最小精度があります。以下の通り:
TURNOVER_UP:売買代金の最小精度は10元(人民元、香港ドル、米ドル)。入力値は自動的に最小精度の整数倍に切り捨てられます。例:【00700の売買代金102元アラート】を設定すると【00700の売買代金100元アラート】になります。【00700の売買代金8元アラート】を設定すると【00700の売買代金0元アラート】になります。
VOLUME_UP:A株の出来高の最小精度は1000株、その他の市場の株式は10株。入力値は自動的に最小精度の整数倍に切り捨てられます。
BID_VOL_UP、ASK_VOL_UP:A株の最良気配注文数量の最小精度は100株。入力値は自動的に最小精度の整数倍に切り捨てられます。
其余到達価格アラートタイプ精度対応到小数点后 3 位
APIレート制限
- 每 30 秒内最多リクエスト 60 次設定到達価格アラートAPI
- 各銘柄の各タイプで設定可能なアラートの上限は10件です