# Get Stock Basic Information

get_stock_basicinfo(market, stock_type=SecurityType.STOCK, code_list=None)

  • Description

    Get Stock Basic Information

  • Parameters

    Parameter Type Description
    market Market Market type.
    stock_type SecurityType Stock type. It does not support SecurityType.DRVT.
    code_list list Stock list.

    Note: when both market and code_list exist, market is ignored and only code_list is effective.

  • Return

    Field Type Description
    ret RET_CODE Interface result.
    data pd.DataFrame If ret == RET_OK, stock static data is returned.
    str If ret != RET_OK, error description is returned.
    • Stock static data format as follows:
      Field Type Description
      code str Stock code.
      name str Stock name.
      lot_size int Number of shares per lot, number of shares per contract for options
      , contract multipliers for futures.
      stock_type SecurityType Stock type.
      stock_child_type WrtType Warrant type.
      stock_owner str The code of the underlying stock to which the warrant belongs, or the code of the underlying stock of the option.
      option_type OptionType Option type.
      strike_time str The option exercise date.
      strike_price float Option strike price.
      suspension bool Whether the option is suspended.
      listing_date str Listing time.
      stock_id int Stock ID.
      delisting bool Whether is delisted or not.
      index_option_type str Index option type.
      main_contract bool Whether is future main contract.
      last_trade_time str Last trading time.
      exchange_type ExchType Exchange Type.
  • Example

from moomoo import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data = quote_ctx.get_stock_basicinfo(Market.HK, SecurityType.STOCK)
if ret == RET_OK:
    print(data)
else:
    print('error:', data)
print('******************************************')
ret, data = quote_ctx.get_stock_basicinfo(Market.HK, SecurityType.STOCK, ['HK.06998', 'HK.00700'])
if ret == RET_OK:
    print(data)
    print(data['name'][0]) # Take the first stock name
    print(data['name'].values.tolist()) # Convert to list
else:
    print('error:', data)
quote_ctx.close() # After using the connection, remember to close it to prevent the number of connections from running out
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
  • Output
        code             name  lot_size stock_type stock_child_type stock_owner option_type strike_time strike_price suspension listing_date        stock_id  delisting index_option_type  main_contract last_trade_time exchange_type
0      HK.00001     CK Hutchison       500      STOCK              N/A                                              N/A        N/A   2015-03-18   4440996184065      False               N/A          False                  HK_MAINBOARD 
...         ...              ...       ...        ...              ...         ...         ...         ...          ...        ...          ...             ...        ...               ...            ...             ...
2592   HK.09979     GREENTOWN MANAGEMENT HOLDINGS COMPANY LIMITED      1000      STOCK              N/A                                              N/A        N/A   2020-07-10  79203491915515      False               N/A          False                  HK_MAINBOARD               

[2593 rows x 16 columns]
******************************************
        code            name  lot_size stock_type stock_child_type stock_owner option_type strike_time strike_price suspension listing_date        stock_id  delisting index_option_type  main_contract last_trade_time exchange_type
0  HK.06998     JHBP       500      STOCK              N/A                                              N/A        N/A   2020-10-07  79572859099990      False               N/A          False                  HK_MAINBOARD               
1  HK.00700     Tencent       100      STOCK              N/A                                              N/A        N/A   2004-06-16  54047868453564      False               N/A          False                  HK_MAINBOARD               
JHBP
['JHBP', 'Tencent']
1
2
3
4
5
6
7
8
9
10
11
12

Tips

  • When input stocks are not recognized by the program (including stocks that have been delisted a long time ago and non-existent stocks), this interface still returns stock information. The "delisted" field is used to indicate that the stock does exist or not. The unified processing is: the code is displayed normally, the stock name is displayed as "unknown stock", and the other fields are default values (The integer type defaults to 0, and the string defaults to an empty string.).
  • This interface is different from other market information interfaces. When other interfaces get input stocks that the program cannot recognize, they will reject the request and return the error description "unknown stock".