# 到達価格アラートコールバック

on_recv_rsp(self, rsp_pb)

  • 概要

    到達価格アラート通知コールバック。設定済み到達価格アラートの通知プッシュを非同期処理します。
    リアルタイム到達価格アラート通知プッシュの受信時にこの関数がコールバックされます。派生クラスで on_recv_rsp をオーバーライドしてください。

  • パラメータ

    パラメータ 説明
    rsp_pb Qot_UpdatePriceReminder_pb2.Response 派生クラスでは直接処理不要
  • 戻り値

    パラメータ 説明
    ret RET_CODE API呼び出し結果
    data dict 当 ret == RET_OK,返す到達価格アラート
    str ret != RET_OK の場合、エラーの説明を返す
    • 到達価格アラート
      フィールド タイプ 説明
      code str 銘柄コード
      name str 銘柄名
      price float 現在の価格
      change_rate str 現在の騰落率
      market_status PriceReminderMarketStatus トリガーの時間帯
      content str 到達価格アラート文字内容
      note str 備考
      key int 到達価格アラート識別子
      reminder_type PriceReminderType 到達価格アラートのタイプ
      set_value float 用户設定したアラート値
      cur_value float アラートトリガー時の値
  • Example

import time
from futu import *

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)  # 到達価格アラート通知コールバックを設定
time.sleep(15)  # スクリプトが OpenD のプッシュを受信する時間を15秒に設定
quote_ctx.close()   # 接続をクローズすると、OpenD は1分後に対応銘柄の登録を自動解除
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
  • Output
PriceReminderTest  {'code': 'US.AAPL', 'name': '苹果', 'price': 185.750, 'change_rate': 0.11, 'market_status': 'US_PRE', 'content': '買一価高于185.500', 'note': '', 'key': 1744022257052794489, 'reminder_type': 'BID_PRICE_UP', 'set_value': 185.500, 'cur_value': 185.750}
1

ご注意