# 到價提醒回呼

on_recv_rsp(self, rsp_pb)

  • 介紹

    到價提醒通知回呼,非同步處理已設定到價提醒的通知推送。
    在收到實時到價提醒通知推送後會回呼到該函數,您需要在衍生類別中覆寫 on_recv_rsp。

  • 參數

    參數 類型 説明
    rsp_pb Qot_UpdatePriceReminder_pb2.Response 衍生類別中不需要直接處理該參數
  • 返回

    參數 類型 説明
    ret RET_CODE 介面呼叫結果
    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

提示