Trading API Overview
The trading API provides order management, account position queries, and transaction record queries, covering Hong Kong, US, A-shares (Shanghai-Hong Kong Stock Connect / Shenzhen-Hong Kong Stock Connect), Singapore, Japan, Korea, Canada, Malaysia, Australia, futures, forex, and prediction market (event contracts) markets.
API Categories
- Account & Positions — Authorized trading accounts, account funds, position list.
- Trading — Place order, modify order, cancel order, order confirm, max tradable quantity. Supports limit/market, stop/touch, trailing stop, and algo order types such as TWAP/VWAP/POV/Slicer/PEG/Iceberg.
- Orders — Open orders, historical orders, order details.
- Deals — Today's deals, historical deals.
- Cash Logs — Paginated cash logs by time range, direction, and symbol.
- Combo Trading — Query tradable combo (multi-leg) information.
- Order Fees — Query commission, tax, and other fee details for an order.
- Margin — Query margin ratios and lending information.
- Trade Push — WebSocket real-time push: auth, subscribe, heartbeat, data format, error codes.
Account Identifier
The acc_id path parameter on other trading APIs is the account_id returned by Get Authorized Trading Accounts, passed as a decimal string.
Place your first trade
Place, modify, and cancel require the OAuth scope trade:write (see Getting Started · Scopes). Calling the securities trading APIs places real trades. We recommend verifying with a small size first, and completing one full trade in this order:
- Choose an account: call Get Authorized Trading Accounts and use the returned
account_idasacc_idon later paths. If you have multiple accounts, see that page for how to choose. - Check funds and positions (optional): use Get Account Funds and Get Positions for buying power and sellable quantity; to estimate size, also call Get Max Qty.
- Place: call Place Order. On success, read the
order_idfield from the response. If confirm or a browser step is required, follow Order Confirm before continuing. - Check the result: reconcile with Open Orders. For live notifications, also connect Trade Push.
- Modify or cancel (if needed): follow Modify Order and Cancel Order, passing the
exchangereturned on the order — do not infer it from the symbol.
For combo options, margin, fills, and fees, see the matching pages under API Categories above.
Minimal success example
Fetch an account, place a US limit order, then list open orders (replace {acc_id} with the account_id from step 1):
# 1. Get authorized trading accounts
curl -X GET 'https://webapi.moomoo.com/api/v1.0/accounts/authorized_trd_accs' \
-H 'Authorization: Bearer <AccessToken>' | jq
# 2. Limit buy (example: 1 share of US.AAPL — adjust for your permissions and buying power)
curl -X POST 'https://webapi.moomoo.com/api/v1.0/accounts/{acc_id}/orders' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <AccessToken>' \
-d '{
"code": "US.AAPL",
"qty": "1",
"price": "150.00",
"side": "BUY",
"order_type": "LIMIT",
"time_in_force": "DAY"
}' | jq
# 3. List open orders
curl -X GET 'https://webapi.moomoo.com/api/v1.0/accounts/{acc_id}/orders?trd_market=US' \
-H 'Authorization: Bearer <AccessToken>' | jqIf step 2 returns need_order_confirm or jump_url, follow Order Confirm before step 3.
Trade push vs REST
| Channel | Best for | Notes |
|---|---|---|
| Trade Push | Live place / replace / cancel / fill updates | No replay while disconnected; arrival order is not strictly guaranteed |
| REST orders / fills | Checking current orders and fills; backfilling data missed while disconnected | Use Open Orders, History Orders, Today’s Deals, etc. |
Recommendation: drive UI or strategy reactions from push while online; treat REST as the source of truth for final state. After reconnect, query open orders or recent fills once, then resume listening to push.
Reference
- Naming Dictionary — Enumeration reference table containing all enum definitions used by trading APIs.
- Get Authorized Trading Accounts — How to choose
acc_idand JPsub_acc_id.