# Get Real-time Quote

get_stock_quote(code_list)

  • Description

    To get real-time quotes of subscribed securities, you must subscribe first.

  • Parameters

    Parameter Type Description
    code_list list Stock list. Data type of elements in the list is str.
  • Return

    Field Type Description
    ret RET_CODE Interface result.
    data pd.DataFrame If ret == RET_OK, quotation data is returned.
    str If ret != RET_OK, error description is returned.
    • quotation data format as follows:
      Field Type Description
      code str Stock code.
      data_date str Date.
      data_time str Time of latest price.
      last_price float Latest price.
      open_price float Open.
      high_price float High.
      low_price float Low.
      prev_close_price float Yesterday's close.
      volume int Volume.
      turnover float Turnover.
      turnover_rate float Turnover rate.
      amplitude int Amplitude.
      suspension bool Whether trading is suspended.
      listing_date str Listing date.
      price_spread float Spread.
      dark_status DarkStatus Grey market transaction status.
      sec_status SecurityStatus Stock status.
      strike_price float Strike price.
      contract_size float Contract size.
      open_interest int Number of open positions.
      implied_volatility float Implied volatility.
      premium float Premium.
      delta float Greek value Delta.
      gamma float Greek value Gamma.
      vega float Greek value Vega.
      theta float Greek value Theta.
      rho float Greek value Rho.
      index_option_type IndexOptionType Index option type.
      net_open_interest int Net open contract number.
      expiry_date_distance int The number of days from the expiry date.
      contract_nominal_value float Contract nominal amount.
      owner_lot_multiplier float Equal number of underlying stocks.
      option_area_type OptionAreaType Option type (by exercise time).
      contract_multiplier float Contract multiplier.
      pre_price float Pre-market price.
      pre_high_price float Pre-market high.
      pre_low_price float Pre-market low.
      pre_volume int Pre-market volume.
      pre_turnover float Pre-market turnover.
      pre_change_val float Pre-market change.
      pre_change_rate float Pre-market change rate.
      pre_amplitude float Pre-market amplitude.
      after_price float After-hours price.
      after_high_price float After-hours high.
      after_low_price float After-hours high.
      after_volume int After-hours volume.
      After_turnover float After-hours turnover.
      after_change_val float After-hours change.
      after_change_rate float After-hours change rate.
      after_amplitude float After-hours amplitude.
      last_settle_price float Yesterday's close.
      position float Holding position.
      position_change float Daily position change.
  • Example

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

ret_sub, err_message = quote_ctx.subscribe(['HK.00700'], [SubType.QUOTE], subscribe_push=False)
# Subscribe to the K line 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: # Subscription successful
     ret, data = quote_ctx.get_stock_quote(['HK.00700']) # Get real-time data of subscription stock quotes
     if ret == RET_OK:
         print(data)
         print(data['code'][0]) # Take the first stock code
         print(data['code'].values.tolist()) # Convert to list
     else:
         print('error:', data)
else:
     print('subscription failed', err_message)
quote_ctx.close() # Close the current connection, 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   data_date data_time  last_price  open_price  high_price  low_price  prev_close_price    volume      turnover  turnover_rate  amplitude  suspension listing_date  price_spread dark_status sec_status strike_price contract_size open_interest implied_volatility premium delta gamma vega theta  rho net_open_interest expiry_date_distance contract_nominal_value owner_lot_multiplier option_area_type contract_multiplier last_settle_price position position_change index_option_type pre_price pre_high_price pre_low_price pre_volume pre_turnover pre_change_val pre_change_rate pre_amplitude after_price after_high_price after_low_price after_volume after_turnover after_change_val after_change_rate after_amplitude
0   HK.00700  2021-01-04  16:08:49       572.5       558.0       583.0      557.5             564.0  20784101  1.196867e+10          0.217      4.521       False   2004-06-16           0.5         N/A     NORMAL          N/A           N/A           N/A                N/A     N/A   N/A   N/A  N/A   N/A  N/A               N/A                  N/A                    N/A                  N/A              N/A                 N/A               N/A      N/A             N/A               N/A       N/A            N/A           N/A        N/A          N/A            N/A             N/A           N/A         N/A              N/A             N/A          N/A            N/A              N/A               N/A             N/A
HK.00700
['HK.00700']
1
2
3
4

Tips