# Get Real-time Tick-by-Tick

get_rt_ticker(code, num=500)

  • Description

    To get real-time tick-by-tick of subscribed stocks. (Require real-time data subscription.)

  • Parameters

    Parameter Type Description
    code str Stock code.
    num int Number of recent tick-by-tick.
  • Return

    Field Type Description
    ret RET_CODE Interface result.
    data pd.DataFrame If ret == RET_OK, tick-by-tick data is returned.
    str If ret != RET_OK, error description is returned.
    • Tick-by-tick data format as follows:
      Field Type Description
      code str Stock code.
      name str Stock name.
      sequence int Sequence number.
      time str Transaction time.
      price float Transaction price.
      volume int Volume.
      turnover float Transaction amount.
      ticker_direction TickerDirect Tick-By-Tick direction.
      type TickerType Tick-By-Tick type.
  • Example

from futu import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)

ret_sub, err_message = quote_ctx.subscribe(['HK.00700'], [SubType.TICKER], subscribe_push=False)
# First subscribe to each type. After the subscription is successful, OpenD will continue to receive pushes from the server, False means that there is no need to push to the script temporarily
if ret_sub == RET_OK: # Subscription successful
     ret, data = quote_ctx.get_rt_ticker('HK.00700', 2) # Get the last 2 transactions of Hong Kong stocks 00700
     if ret == RET_OK:
         print(data)
         print(data['turnover'][0]) # Take the first transaction amount
         print(data['turnover'].values.tolist()) # Convert to list
     else:
         print('error:', data)
else:
     print('subscription failed', err_message)
quote_ctx.close() # Close the current link, 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
   code     name                 time  price   volume     turnover ticker_direction             sequence        type
0  HK.00700  TENCENT  2023-07-19 15:59:58  332.4      100      33240.0             SELL  7257436441708356760  AUTO_MATCH
1  HK.00700  TENCENT  2023-07-19 16:08:12  333.0  1667000  555111000.0          NEUTRAL  7257438563422200985     AUCTION
33240.0
[33240.0, 555111000.0]
1
2
3
4
5

Interface Limitations

  • You can get up to the latest 1000 tick-by-tick data, more historical tick-by-tick data is not yet available
  • Under the authority of LV1 HK futures and options market, tick-by-tick data is not available

Tips