Skip to main content

Place, modify and cancel a pending order

A pending order waits until the market reaches its price. It uses no margin until it fills.

1. Token​

TOKEN="<access_token>" # see Open & close a position, step 1

2. Place a Buy Limit​

Pending types: 1 Buy Limit, 2 Buy Stop, 3 Sell Limit, 4 Sell Stop. The side comes from the type, so side isn't needed. order_price is the trigger; a Buy Limit must be below the current ask.

curl -X POST https://api.onlytradeplatform.com/api/v1/orders/accounts/me \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"symbol_id": 26100001,
"type": 1,
"volume": 0.10,
"order_price": 1.07500,
"stop_loss": 1.07000,
"take_profit": 1.09000,
"expiration_policy": 0,
"comment": "recipe-2"
}'

To expire it automatically, use "expiration_policy": 2 with "expiry_at" set to a Unix time in milliseconds, at least 5 minutes ahead.

3. Find the order​

curl https://api.onlytradeplatform.com/api/v1/orders/accounts/me \
-H "Authorization: Bearer $TOKEN"

Active orders are returned by default. Find "comment": "recipe-2" and note its id (e.g. 260610013). status: 1 means it's placed and waiting.

4. Move it​

Modifying replaces the order, so send every field you want to keep. The price field here is order_limit_price:

curl -X PUT https://api.onlytradeplatform.com/api/v1/orders/260610013/accounts/me \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"type": 1,
"order_limit_price": 1.07400,
"volume": 0.10,
"stop_loss": 1.06900,
"take_profit": 1.08900,
"expiration_policy": 0,
"comment": "recipe-2"
}'

5. Cancel it​

A POST to the order, with no body:

curl -X POST https://api.onlytradeplatform.com/api/v1/orders/260610013/accounts/me \
-H "Authorization: Bearer $TOKEN"

The WebSocket shows order_cancel. If the order already filled, you get you can't update the order at this point — manage it as a position instead.