# Query the Maximum Quantity that Can be Bought or Sold

acctradinginfo_query(order_type, code, price, order_id=None, adjust_limit=0, trd_env=TrdEnv.REAL, acc_id=0, acc_index=0)

  • Description

    Query the maximum quantity that can be bought or sold under a specifictrading account, and you can also query the maximum changeable quantity of a specific order under a specifictrading account.

    Cash account request options are not supported.

  • Parameters

    Parameter Type Description
    order_type OrderType Order type.
    code str Security code.
    price float Quotation.
    order_id str Order ID.
    adjust_limit float Price adjustment range.
    trd_env TrdEnv Trading environment.
    acc_id int Trading account ID.
    acc_index int The account number in the trading account list.
  • Return

    Field Type Description
    ret RET_CODE Interface result.
    data pd.DataFrame If ret == RET_OK, account list is returned.
    str If ret != RET_OK, error description is returned.
    • Account list format as follows:
      Field Type Description
      max_cash_buy float Buy on cash.
      max_cash_and_margin_buy float Buy on margin.
      max_position_sell float Sell on position.
      max_sell_short float Short sell.
      max_buy_back float Short positions.
      long_required_im float Initial margin change when buying one contract of an asset.
      short_required_im float Initial margin change when selling one contract of an asset.
  • Example

from futu import *
trd_ctx = OpenSecTradeContext(filter_trdmarket=TrdMarket.HK, host='127.0.0.1', port=11111, security_firm=SecurityFirm.FUTUSECURITIES)
ret, data = trd_ctx.acctradinginfo_query(order_type=OrderType.NORMAL, code='HK.00700', price=400)
if ret == RET_OK:
    print(data)
    print(data['max_cash_and_margin_buy'][0])  # Get maximum quantity that can be bought on margin
else:
    print('acctradinginfo_query error: ', data)
trd_ctx.close()  # Close the current connection
1
2
3
4
5
6
7
8
9
  • Output
    max_cash_buy  max_cash_and_margin_buy  max_position_sell  max_sell_short  max_buy_back long_required_im short_required_im
0           0.0                   1500.0                0.0             0.0           0.0              N/A               N/A
1500.0
1
2
3

Interface Limitations

  • A maximum of 10 requests per 30 seconds

Tips

  • The cash account does not support trading derivatives, so it is unsupported to query options through the cash account.