# 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.
      acc_status TrdAccStatus Account status.
      acc_role TrdAccRole Account Structure
      jp_acc_type list JP sub account type
  • Description

    To obtain the HK Paper Trading accounts, specify filter_trdmarket as TrdMarket.HK. This will return two paper trading accounts. The account with sim_acc_type = STOCK represents a HK paper trading account, while sim_acc_type = OPTION refers to a HK stock options paper trading account, and sim_acc_type = FUTURES indicates a HK futures paper trading account.

    To obtain the US Paper Trading accounts, specify filter_trdmarket as TrdMarket.US. An account with sim_acc_type = STOCK_AND_OPTION represents the US margin paper trading account, which allows the stock and options trading. An account with sim_acc_type = FUTURES represents a US futures paper trading account.

  • Example

from moomoo import *
trd_ctx = OpenSecTradeContext(filter_trdmarket=TrdMarket.US, host='127.0.0.1', port=11111, security_firm=SecurityFirm.FUTUINC)
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    acc_status    acc_role    jp_acc_type
0  281756420273981734      REAL   MARGIN  10018561211263256   1001100530724347          FUTUINC            N/A    [HK, US, HKCC, SG, HKFUND, USFUND, JP]       ACTIVE      NORMAL             []
1             3450310  SIMULATE     CASH                N/A                N/A              N/A          STOCK                                      [HK]       ACTIVE         N/A             []
2             3548732  SIMULATE   MARGIN                N/A                N/A              N/A         OPTION                                      [HK]       ACTIVE         N/A             []
281756420273981734
[281756420273981734, 3450310, 3548732]
1
2
3
4
5
6