# Get the List of Trading Accounts

get_acc_list()

  • Description

    Get a list of trading accounts. Before calling other trading interfaces, please obtain this list first and confirm that the trading account to be operated is correct.

  • Parameters

  • Return

    Field Type Description
    ret RET_CODE Interface result.
    data pd.DataFrame If ret == RET_OK, trading account list is returned.
    str If ret != RET_OK, error description is returned.
    • Trading account list format as follows:
      Field Type Description
      acc_id int Trading account.
      trd_env TrdEnv Trading environment.
      acc_type TrdAccType Account type.
      uni_card_num str Universal account number, same as the display in the mobile terminal.
      card_num str Trading account number
      sim_acc_type SimAccType Simulate account type.
      security_firm SecurityFirm Securities firm to which the account belongs.
      trdmarket_auth list Transaction market authority.
  • Description

    After the paper trading of HK/US stock options is opened, this function will return 2 paper trading accounts when obtaining the list of HK/US trading accounts. The first one is the original account, and the second one is the option paper trading account. Currently, the US paper trading accounts from OpenAPI are different with those showed on the mobile app. Click here for more details.

  • Example

from moomoo import *
trd_ctx = OpenSecTradeContext(filter_trdmarket=TrdMarket.HK, host='127.0.0.1', port=11111, security_firm=SecurityFirm.FUTUSECURITIES)
ret, data = trd_ctx.get_acc_list()
if ret == RET_OK:
    print(data)
    print(data['acc_id'][0])  # Get the first account ID
    print(data['acc_id'].values.tolist())  # convert to list
else:
    print('get_acc_list error: ', data)
trd_ctx.close()
1
2
3
4
5
6
7
8
9
10
  • Output
               acc_id   trd_env acc_type        uni_card_num           card_num    security_firm   sim_acc_type   trdmarket_auth
0  281756420273981734      REAL   MARGIN  10018561211263256   1001100530724347   FUTUSECURITIES            N/A          [HK, US, HKCC, SG, HKFUND, USFUND, JP]
1             3450310  SIMULATE     CASH                N/A                N/A              N/A          STOCK             [HK]
2             3548732  SIMULATE   MARGIN                N/A                N/A              N/A         OPTION             [HK]
281756420273981734
[281756420273981734, 3450310, 3548732]
1
2
3
4
5
6