# 到价提醒回调

# PriceReminderHandlerBase

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': 'HK.HSImain', 'name': '恒指主连(2307)', 'price': 24529.0, 'change_rate': 0.11, 'market_status': 'OPEN', 'content': '价格涨到24531.000', 'note': '', 'key': 158815186771390101, 'reminder_type': 'PRICE_UP', 'set_value': 24531.0, 'cur_value': 24532.0}
1

提示