# Get Related Data of a Specific Security

get_referencestock_list(code, reference_type)

  • Description

    Get related data of securities, such as: obtaining warrants related to underlying stocks, obtaining contracts related to futures

  • Parameters

    Parameter Type Description
    code str Stock code.
    reference_type SecurityReferenceType Related data type to be obtained.
  • Return

    Field Type Description
    ret RET_CODE Interface result.
    data pd.DataFrame If ret == RET_OK, related data of security is returned.
    str If ret != RET_OK, error description is returned.
    • Related data of security fotmat as follows:
      Field Type Description
      code str Security code.
      lot_size int The number of shares per lot, contract multiplier for futures.
      stock_type SecurityType Security type.
      stock_name str Security name.
      list_time str Time of listing.
      wrt_valid bool Whether it is a warrant.
      wrt_type WrtType Warrant type.
      wrt_code str The underlying stock.
      future_valid bool Whether it is a future.
      future_main_contract bool Whether the future main contract.
      future_last_trade_time str Last trading time.
  • Example

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

# Get warrants related to the underlying stock
ret, data = quote_ctx.get_referencestock_list('HK.00700', SecurityReferenceType.WARRANT)
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)
print('******************************************')
# Port related contracts
ret, data = quote_ctx.get_referencestock_list('HK.A50main', SecurityReferenceType.FUTURE)
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)
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
17
18
19
20
21
  • Output
        code  lot_size stock_type stock_name   list_time  wrt_valid wrt_type  wrt_code  future_valid  future_main_contract  future_last_trade_time
0     HK.24719      1000    WARRANT     TENGXUNDONGYAJIUSIGUA  2018-07-20       True      PUT  HK.00700         False                   NaN                     NaN
...        ...       ...        ...        ...         ...        ...      ...       ...           ...                   ...                     ...
1617  HK.63402     10000    WARRANT     GS#TENCTRC2108Y  2020-11-26       True     BULL  HK.00700         False                   NaN                     NaN

[1618 rows x 11 columns]
HK.24719
['HK.24719', 'HK.27886', 'HK.28621', 'HK.14339', 'HK.27952', 'HK.18693', 'HK.20306', 'HK.53635', 'HK.47269', 'HK.27227', 
...        ...       ...        ...        ...         ...        ...      ...       ... 
'HK.63402']
******************************************
        code  lot_size stock_type         stock_name list_time  wrt_valid  wrt_type  wrt_code  future_valid  future_main_contract future_last_trade_time
0  HK.A50main      5000     FUTURE      A50 Future Main(DEC0)                False       NaN       NaN          True                  True                        
..         ...       ...        ...                ...       ...        ...       ...       ...           ...                   ...                    ...
5  HK.A502106      5000     FUTURE      A50 JUN1                False       NaN       NaN          True                 False             2021-06-29

[6 rows x 11 columns]
HK.A50main
['HK.A50main', 'HK.A502011', 'HK.A502012', 'HK.A502101', 'HK.A502103', 'HK.A502106']
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

Interface Limitations

  • A maximum of 10 requests per 30 seconds
  • When obtaining warrants related to the underlying stock, it is not subject to the above frequency restriction