# Get Real-time Time Frame Data

get_rt_data(code)

  • Description

    Obtain real-time tick-by-tick data for a specified stock. (Require real-time data subscription.)

  • Parameters

    Parameter Type Description
    code str Stock code.
  • Return

    Field Type Description
    ret RET_CODE Interface result.
    data pd.DataFrame If ret == RET_OK, Time Frame data is returned.
    str If ret != RET_OK, error description is returned.
    • Time Frame data format as follows:
      Field Type Description
      code str Stock code.
      name str Stock name.
      time str Time.
      is_blank bool Data status.
      opened_mins int How many minutes have passed from 0 o'clock.
      cur_price float Current price.
      last_close float Yesterday's close.
      avg_price float Average price.
      volume float Volume.
      turnover float Transaction amount.
  • Example

from futu import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret_sub, err_message = quote_ctx.subscribe(['US.AAPL'], [SubType.RT_DATA], subscribe_push=False, session=Session.ALL)
# Subscribe to the Time Frame data type first. 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:   # Successfully subscribed
    ret, data = quote_ctx.get_rt_data('US.AAPL')   # Get Time Frame data once
    if ret == RET_OK:
        print(data)
    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
  • Output
code  name                 time  is_blank  opened_mins  cur_price  last_close   avg_price   volume     turnover
0    US.AAPL   APPLE  2025-04-06 20:01:00     False         1201     183.00      188.38  181.643916    9463  1718896.38
..      ...    ...                  ...       ...          ...        ...         ...         ...      ...          ...
586  US.AAPL   APPLE  2025-04-07 05:47:00     False          347     181.26      188.38  180.555673     661   119859.75

[587 rows x 10 columns]
1
2
3
4
5
6

Tips