# 設定到價提醒

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

  • 介紹

    新增、刪除、修改、啟用、禁用指定股票的到價提醒

  • 參數

    參數 類型 説明
    code str 股票代碼
    op SetPriceReminderOp 操作類型
    key int 標識,新增和刪除全部的情況不需要填
    reminder_type PriceReminderType 到價提醒的類型,刪除、啟用、禁用的情況下會忽略該入參
    reminder_freq PriceReminderFreq 到價提醒的頻率,刪除、啟用、禁用的情況下會忽略該入參
    value float 提醒值,刪除、啟用、禁用的情況下會忽略該入參
    note str 用戶設定的備註,僅支援 20 個以內的中文字元,刪除、啟用、禁用的情況下會忽略該入參
    reminder_session_list list 美股到價提醒的時段列表,刪除、啟用、禁用的情況下會忽略該入參
  • 返回

    參數 類型 説明
    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(['US.AAPL'])
if ret == RET_OK:
    bid_price = data['bid_price'][0]  # 獲取實時買一價
    ask_price = data['ask_price'][0]  # 獲取實時賣一價
    # 設定當AAPL全時段賣一價低於(ask_price-1)時提醒
    ret_ask, ask_data = quote_ctx.set_price_reminder(code='US.AAPL', op=SetPriceReminderOp.ADD, key=None, reminder_type=PriceReminderType.ASK_PRICE_DOWN, reminder_freq=PriceReminderFreq.ALWAYS, value=(ask_price-1), note='123', reminder_session_list=[PriceReminderMarketStatus.US_PRE, PriceReminderMarketStatus.OPEN, PriceReminderMarketStatus.US_AFTER, PriceReminderMarketStatus.US_OVERNIGHT])
    if ret_ask == RET_OK:
        print('賣一價低於(ask_price-1)時提醒設定成功:', ask_data)
    else:
        print('error:', ask_data)
    # 設定當AAPL全時段買一價高於(bid_price+1)時提醒
    ret_bid, bid_data = quote_ctx.set_price_reminder(code='US.AAPL', op=SetPriceReminderOp.ADD, key=None, reminder_type=PriceReminderType.BID_PRICE_UP, reminder_freq=PriceReminderFreq.ALWAYS, value=(bid_price+1), note='456', reminder_session_list=[PriceReminderMarketStatus.US_PRE, PriceReminderMarketStatus.OPEN, PriceReminderMarketStatus.US_AFTER, PriceReminderMarketStatus.US_OVERNIGHT])
    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)時提醒設定成功: 1744022257023211123
買一價高於(bid_price+1)時提醒設定成功: 1744022257052794489
1
2

提示

  • 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 個