# Get open Orders

order_list_query(order_id="", status_filter_list=[], code='', start='', end='', trd_env=TrdEnv.REAL, acc_id=0, acc_index=0, refresh_cache=False)

  • Description

    Query the open order list of the specified trading account

  • Parameters

    Parameter Type Description
    order_id str Order id.
    status_filter_list list Order status filter conditions.
    code str Security symbol.
    start str Start time.
    end str End time.
    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.
  • Return

    Field Type Description
    ret RET_CODE Interface result.
    data pd.DataFrame If ret == RET_OK, order list is returned.
    str If ret != RET_OK, error description is returned.
    • Order list format as follows:
      Field Type Description
      trd_side TrdSide Trading direction.
      order_type OrderType Order type.
      order_status OrderStatus Order status.
      order_id str Order ID.
      code str Security code.
      stock_name str Security name.
      qty float Order quantity.
      price float Order price.
      currency Currency Transaction currency.
      create_time str Create time.
      updated_time str Last update time.
      dealt_qty float Deal quantity
      dealt_avg_price float Average deal price.
      last_err_msg str The last error description.
      remark str Identification of remarks when placing an order.
      time_in_force TimeInForce Valid period.
      fill_outside_rth bool Whether pre-market and after-hours are needed.
      aux_price float Traget price.
      trail_type TrailType Trailing type.
      trail_value float Trailing amount/ratio.
      trail_spread float Specify spread.
  • 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.order_list_query()
if ret == RET_OK:
    print(data)
    if data.shape[0] > 0:  # If the order list is not empty
        print(data['order_id'][0])  # Get the first order ID of the order list today
        print(data['order_id'].values.tolist())  # Convert to list
else:
    print('order_list_query error: ', data)
trd_ctx.close()
1
2
3
4
5
6
7
8
9
10
11
  • Output
        code stock_name trd_side           order_type   order_status             order_id    qty  price              create_time             updated_time  dealt_qty  dealt_avg_price last_err_msg      remark time_in_force fill_outside_rth aux_price trail_type trail_value trail_spread currency
0   HK.00700                 BUY           NORMAL  CANCELLED_ALL  6644468615272262086  100.0  520.0  2021-09-06 10:17:52.465  2021-09-07 16:10:22.806        0.0              0.0               asdfg+=@@@           GTC              N/A       560        N/A         N/A          N/A      HKD
6644468615272262086
['6644468615272262086']
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 the cache is refreshed

Tips

  • Open orders are arranged in chronological order: earlier orders return first, followed by later orders.