Skip to main content
This guide places a limit order far from the market, watches it on the events stream, moves it and cancels it, so nothing fills. It needs a trading key and its private key, and an exchange account connected to TakeProfit. These are real orders on your real account. Keep the price far from the market and the quantity at the minimum while you try things out.

Setup

The examples are in Python with three packages:
Every request is signed (see Sign every request). This helper signs a query string or a body and returns the headers:

1. Find your account

Pick an account with status active and one of its connectorCodes. The rest of this guide uses Binance USD-M futures:
Then check what the connector accepts. The answer is the same for every user, so read it once and keep it:
A field the connector doesn’t list is rejected, so check here before using stop orders, trailing stops or take-profit/stop-loss.

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:
Round every price to 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 a snapshot 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.
The answer is 202 Accepted: the order was taken for processing, not yet placed. The events stream tells you what the exchange did:
An 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.
Some connectors can’t amend in place: they cancel the order and place a new one, and the notification’s 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

The events stream sends an order frame with order.status canceled. Close the stream when you’re done:

Next steps