# Set Price Reminder

set_price_reminder(code, op, key=None, reminder_type=None, reminder_freq=None, value=None, note=None)

  • Description

    Add, delete, modify, enable, and disable price reminders for specified stocks

  • Parameters

    Parameter Type Description
    code str Stock code
    op SetPriceReminderOp Operation type.
    key int Identification, do not need to fill in the case of adding all or deleting all.
    reminder_type PriceReminderType The type of price reminder, this input parameter will be ignored when delete, enable, or disable.
    reminder_freq PriceReminderFreq The frequency of price reminder, this input parameter will be ignored when delete, enabled, or disable.
    value float Reminder value, the input parameter will be ignored when delete, enable, or disable.
    note str The note set by the user, note supports no more than 20 Chinese characters, the input parameter will be ignored when delete, enable, or disable.
  • Return

    Field Type Description
    ret RET_CODE Interface result.
    key int If ret == RET_OK, The price reminder key of the operation is returned. When deleting all reminders of a specific stock, 0 is returned.
    str If ret != RET_OK, error description is returned.
  • 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)
        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] # Get real-time bid price
    ask_price = data['ask_price'][0] # Get real-time selling price
    # Set a reminder when the selling price is lower than (ask_price-1)
    ret_ask, ask_data = quote_ctx.set_price_reminder(code='HK.HSImain', op=SetPriceReminderOp.ADD, key=None, reminder_type=PriceReminderTypeASK_PRICE_DOWN, reminder_freq=PriceReminderFreq.ALWAYS, value=(ask_price-1) ')
    if ret_ask == RET_OK:
        print('When the selling price is lower than (ask_price-1), remind that the setting is successful:', ask_data)
    else:
        print('error:', ask_data)
    # Set a reminder when the bid price is higher than (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('When the bid price is higher than (bid_price+1), the reminder is set successfully: ', 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
When the selling price is lower than (ask_price-1), the reminder is set successfully: 158815356110052101
When the bid price is higher than (bid_price+1), the reminder is set successfully: 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

Tips

  • Trading volume in API is based on shares. A-shares are shown in lots in Futubull Client.

  • The type of price alert has minimum precision, as follows:

    TURNOVER_UP: The minimum precision of the turnover is 10 (Yuan, Hong Kong dollar, US dollar). The value passed in will be automatically rounded down to an integer multiple of the minimum precision. If you set 00700 transaction volume 102 yuan reminder, you will get 00700 transaction volume 100 yuan reminder. After setting; if you set 00700 transaction volume 8 yuan reminder, you will get 00700 transaction volume 0 yuan reminder after setting.

    VOLUME_UP: The minimum accuracy of A-share trading volume is 1000 shares, and the minimum accuracy of other market stock trading volume is 10 shares. The value passed in will be automatically rounded down to an integer multiple of the minimum precision.

    BID_VOL_UP, ASK_VOL_UP: The minimum precision for buying and selling of A-shares is 100 shares. The value passed in will be automatically rounded down to an integer multiple of the minimum precision.

    The precision of the remaining price alert types supports up to 3 decimal places

Interface Limitations

  • A maximum of 60 requests per 30 seconds
  • The upper limit of reminders that can be set for each type of each stock is 10