# Get Account Funds

accinfo_query(trd_env=TrdEnv.REAL, acc_id=0, acc_index=0, refresh_cache=False, currency=Currency.HKD)

  • Description

    Query fund data such as net asset value, securities market value, cash, and purchasing power of trading accounts.

  • Parameters

    Parameter Type Description
    trd_env TrdEnv Trading environment
    acc_id int Trading account ID.
    acc_index int The account number in the trading account list.
    refresh_cache bool Whether to refresh the cache.
    currency Currency The display currency of the funds.
  • Return

    Field Type Description
    ret RET_CODE Interface result.
    data pd.DataFrame If ret == RET_OK, fund data is returned.
    str If ret != RET_OK, error description is returned.
    • Fund data format as follows:
      Field Type Description
      power float Maximum Buying Power.
      max_power_short float Short Buying Power.
      net_cash_power float Cash Buying Power.
      total_assets float Total Net Assets.
      securities_assets float Security Assets
      funds_assets float Fund Assets
      bonds_assets float Bond Assets
      cash float Cash.
      market_val float Securities Market Value.
      long_mv float Long Market Value.
      short_mv float Short Market Value.
      pending_asset float Asset in Transit.
      interest_charged_amount float Interest Charged Amount.
      frozen_cash float Funds on Hold.
      avl_withdrawal_cash float Withdrawable Cash.
      max_withdrawal float Maximum Withdrawal.
      currency Currency The currency used for this query.
      available_funds float Available funds.
      unrealized_pl float Unrealized gain or loss.
      realized_pl float Realized gain or loss.
      risk_level CltRiskLevel Risk control level.
      risk_status CltRiskStatus Risk status.
      initial_margin float Initial Margin.
      margin_call_margin float Margin-call Margin.
      maintenance_margin float Maintenance Margin.
      hk_cash float HKD Cash.
      hk_avl_withdrawal_cash float HKD Withdrawable Cash.
      us_cash float USD Cash.
      us_avl_withdrawal_cash float USD Withdrawable Cash.
      jp_cash float JPY Cash.
      jp_avl_withdrawal_cash float JPY Withdrawable Cash.
      pdt_seq string Day Trades Left.
      is_pdt bool Is it marked as a PDT.
      beginning_dtbp float Beginning DTBP.
      remaining_dtbp float Remaining DTBP.
      dt_call_amount float Day-trading Call Amount.
      dt_status DtStatus Day-trading Status.
      cn_cash float CNH Cash.
      cn_avl_withdrawal_cash float CNH Withdrawable Cash.
      sg_cash float SGD Cash.
      sg_avl_withdrawal_cash float SGD Withdrawable Cash.
      au_cash float AUD Cash.
      au_avl_withdrawal_cash float AUD Withdrawable Cash.
      hkd_net_cash_power float HKD Cash Buying Power.
      usd_net_cash_power float USD Cash Buying Power.
      jpy_net_cash_power float JPY Cash Buying Power.
      cnh_net_cash_power float CNH Cash Buying Power.
      sgd_net_cash_power float SGD Cash Buying Power.
      aud_net_cash_power float AUD Cash Buying Power.
  • 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.accinfo_query()
if ret == RET_OK:
    print(data)
    print(data['power'][0])  # Get the first buying power
    print(data['power'].values.tolist())  # convert to list
else:
    print('accinfo_query error: ', data)
trd_ctx.close()  # Close the current connection
1
2
3
4
5
6
7
8
9
10
  • Output

  • Output

power  max_power_short  net_cash_power  total_assets  securities_assets  fund_assets  bond_assets   cash   market_val      long_mv   short_mv  pending_asset  interest_charged_amount  frozen_cash  avl_withdrawal_cash  max_withdrawal currency available_funds unrealized_pl realized_pl risk_level risk_status  initial_margin  margin_call_margin  maintenance_margin  hk_cash  hk_avl_withdrawal_cash  hkd_net_cash_power  us_cash  us_avl_withdrawal_cash  usd_net_cash_power  cn_cash  cn_avl_withdrawal_cash  cnh_net_cash_power  jp_cash  jp_avl_withdrawal_cash  jpy_net_cash_power sg_cash sg_avl_withdrawal_cash sgd_net_cash_power au_cash au_avl_withdrawal_cash aud_net_cash_power is_pdt pdt_seq beginning_dtbp remaining_dtbp dt_call_amount dt_status
0  465453.903307    465453.903307             0.0   289932.0404        197028.2204     92903.82          0.0  25.18  289906.8648  211960.7568 -14957.712            0.0                      0.0    25.930845                  0.0             0.0      HKD             N/A           N/A         N/A        N/A      LEVEL3   219346.648525       288656.787955       181250.967601      0.0                     0.0          13225.7955     3.24                     0.0           9656.4365      0.0                     0.0                 0.0      0.0                     0.0                 0.0     N/A                    N/A                N/A     N/A                    N/A                N/A    N/A     N/A            N/A            N/A            N/A       N/A
465453.9033072
[465453.9033072]
1
2
3
4

Interface Limitations

  • A maximum of 10 requests per 30 seconds
  • It will be restricted by the frequency limit for this interface, only when refresh_cache is True