# Get The Watchlist

get_user_security(group_name)

  • Description

    Get a list of a specified group from watchlist

  • Parameters

    Parameter Type Description
    group_name str The name of the specified group from watchlist.
  • Return

    Field Type Description
    ret RET_CODE Interface result.
    data pd.DataFrame If ret == RET_OK, watchlist is returned.
    str If ret != RET_OK, error description is returned.
    • Watchlist 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 multiplier 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 date.
      stock_id int Stock ID.
      delisting bool Whether is delisted.
      main_contract bool Whether is future main contract.
      last_trade_time str Last trading time.
  • Example

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

ret, data = quote_ctx.get_user_security("A")
if ret == RET_OK:
    print(data)
    if data.shape[0] > 0:  # If the user security list is not empty
        print(data['code'][0]) # Take the first stock code
        print(data['code'].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
  • Output
    code    name  lot_size stock_type stock_child_type stock_owner option_type strike_time strike_price suspension listing_date        stock_id  delisting  main_contract last_trade_time
0  HK.HSImain  HSI Future Main(NOV0)        50     FUTURE              N/A                                              N/A        N/A                     71000662      False           True                
1  HK.00700    Tencent Holdings       100      STOCK              N/A                                              N/A        N/A   2004-06-16  54047868453564      False          False                
HK.HSImain
['HK.HSImain', 'HK.00700']
1
2
3
4
5

Tips

The corresponding Chinese and English names of the system group are as follows

Chinese English
全部 All
沪深 CN
港股 HK
美股 US
期权 Options
港股期权 HK options
美股期权 US options
特别关注 Starred
期货 Futures

Interface Limitations

  • A maximum of 10 requests per 30 seconds
  • Does not support position (Positions), fund treasure (Mutual Fund), foreign exchange (Forex) group query