Setup
The examples are in Python with three packages:1. Find your account
status active and one of its connectorCodes. The rest of this guide uses Binance USD-M futures:
2. Read the instrument’s rules
The order data stream sends the instrument’s price and quantity steps in its first frame. Read it and close the stream:price.step and keep every quantity at or above quantity.min, in steps of quantity.step. quantityUnit says what the quantity counts: the base asset (BTC here), lots or the quote asset.
3. Open the events stream
Open it before placing the order, so you see every change. The first frame is asnapshot of the account: balances, working orders and open positions.
label limits the order and execution frames to orders tagged quickstart, so your other orders stay out of this script’s view.
4. Place a limit order
Place a buy far below the market.Idempotency-Key makes the request safe to retry: a repeat with the same key returns the first order instead of placing a second.
202 Accepted: the order was taken for processing, not yet placed. The events stream tells you what the exchange did:
order frame with a working status, such as placed, means the order is on the book. A commandError frame means the request failed, and says why.
5. Move it
An amend sends the order’s full desired state, not a change: repeat the quantity and the time in force, with the new price.kind is replaced. From then on the order lives under replacementOrderId. Unlike placing, an amend isn’t safe to retry: check the events stream before sending it again.
6. Cancel it
order frame with order.status canceled. Close the stream when you’re done:
Next steps
- Events stream and Order data stream list every frame.
- Credits and limits covers what each request and stream costs.