# Price Reminder Callback

on_recv_rsp(self, rsp_pb)

  • Description

    The price reminder notification callback, asynchronously handles the notification push that has been set to the price reminder. After receiving the real-time price notification, it will call back to this function. You need to override on_recv_rsp in the derived class.

  • Parameters

    Parameter Type Description
    rsp_pb Qot_UpdatePriceReminder_pb2.Response This parameter does not need to be processed directly in the derived class.
  • Return

    Field Type Description
    ret RET_CODE Interface result.
    data dict If ret == RET_OK, price reminder is returned.
    str If ret != RET_OK, error description is returned.
    • Price reminder format as follows:
      Field Type Description
      code str Stock code.
      name str Stock name.
      price float Current price.
      change_rate str Current change rate.
      market_status PriceReminderMarketStatus The time period for triggering.
      content str Text content of price reminder.
      note str Note.
      key int Price reminder identification.
      reminder_type PriceReminderType The type of price reminder.
      set_value float The reminder value set by the user.
      cur_value float The value when the reminder was triggered.
  • 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's own processing logic
        return RET_OK, content
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
handler = PriceReminderTest()
quote_ctx.set_handler(handler) # Set price reminder notification callback
time.sleep(15) # Set the script to receive OpenD push duration to 15 seconds
quote_ctx.close() # Close the current connection, OpenD will automatically cancel the corresponding type of subscription for the corresponding stock after 1 minute
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
  • Output
PriceReminderTest  {'code': 'HK.HSImain','name':'HSI Futures Main(JUL3)' 'price': 24529.0, 'change_rate': 0.11, 'market_status': 'OPEN', 'content': 'Price rose to24531.000', 'note': '', 'key': 158815186771390101, 'reminder_type': 'PRICE_UP', 'set_value': 24531.0, 'cur_value': 24532.0}
1

Tips