# 设置到价提醒

# set_price_reminder

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 提醒值,删除、启用、禁用的情况下会忽略该入参
    note str 用户设置的备注,仅支持 20 个以内的中文字符,删除、启用、禁用的情况下会忽略该入参
  • 返回

    参数 类型 说明
    ret RET_CODE 接口调用结果
    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(['HK.HSImain'])
if ret == RET_OK:
    bid_price = data['bid_price'][0]  # 获取实时买一价
    ask_price = data['ask_price'][0]  # 获取实时卖一价
    # 设置当卖一价低于(ask_price-1)时提醒
    ret_ask, ask_data = quote_ctx.set_price_reminder(code='HK.HSImain', op=SetPriceReminderOp.ADD, key=None, reminder_type=PriceReminderType.ASK_PRICE_DOWN, reminder_freq=PriceReminderFreq.ALWAYS, value=(ask_price-1), note='123')
    if ret_ask == RET_OK:
        print('卖一价低于(ask_price-1)时提醒设置成功:', ask_data)
    else:
        print('error:', ask_data)
    # 设置当买一价高于(bid_price+1)时提醒
    ret_bid, bid_data = quote_ctx.set_price_reminder(code='HK.HSImain', op=SetPriceReminderOp.ADD, key=None, reminder_type=PriceReminderType.BID_PRICE_UP, reminder_freq=PriceReminderFreq.ALWAYS, value=(bid_price+1), note='456')
    if ret_bid == RET_OK:
        print('买一价高于(bid_price+1)时提醒设置成功:', bid_data)
    else:
        print('error:', bid_data)
time.sleep(15)
quote_ctx.close()
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
28
29
30
31
  • Output
卖一价低于(ask_price-1)时提醒设置成功: 158815356110052101
买一价高于(bid_price+1)时提醒设置成功: 158815356129980801
PriceReminderTest  {'code': 'HK.HSImain', 'price': 24532.0, 'change_rate': 0.122, 'market_status': 'OPEN', 'content': '买一价高于24533.000', 'note': '456', 'key': 158815356129980801, 'reminder_type': 'BID_PRICE_UP', 'set_value': 24533.0, 'cur_value': 24533.0}
PriceReminderTest  {'code': 'HK.HSImain', 'price': 24532.0, 'change_rate': 0.122, 'market_status': 'OPEN', 'content': '卖一价低于24533.000', 'note': '123', 'key': 158815356110052101, 'reminder_type': 'ASK_PRICE_DOWN', 'set_value': 24533.0, 'cur_value': 24533.0}
1
2
3
4

提示

  • API 中成交量设置统一以股为单位。但是牛牛客户端中,A 股是以手为单位展示

  • 到价提醒类型,存在最小精度,如下:

    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 位

接口限制

  • 每 30 秒内最多请求 60 次设置到价提醒接口
  • 每只股票每种类型可设置的提醒上限是 10 个