Orders
Amend an order
Changes the quantity, price, trigger or attached take-profit/stop-loss of a
working order (placed, pending or partiallyFilled).
- The body is the desired state, not a patch. Send every value the
order should keep: an omitted
takeProfitorstopLossremoves the one the order has. - The order type and side cannot change:
ordersets the same one ofmarketandlimitas the order has, andside, when sent, equals its side. quantitycannot go below the quantity already filled, and cannot change at all where the connector’samendOrdercapabilities sayquantityChangeUnsupported.- The order id can change. Where the connector’s
amendOrdercapabilities sayreplacesOrder, the amend cancels the order and places a new one, which continues under a new id. The events stream announces it with anotificationframe (order.kindreplaced,order.replacementOrderId). - To move a take-profit/stop-loss order of a position, amend that order
itself: its
orderIdwith the neworder.stop.triggerPrice(plusorder.limit.pricefor a limit one), withouttakeProfit/stopLoss.
Not safe to retry. A retry after a timeout may apply the change twice or fail; check the order on the events stream first.
202 means the change was accepted for asynchronous processing; it can
still fail or be rejected by the exchange. Follow it on the events stream.
POST
/
api
/
v1
/
trading
/
order
/
amend
Amend an order
curl --request POST \
--url https://public-api.charting.com/api/v1/trading/order/amend \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--header 'X-API-SIGNATURE: <api-key>' \
--header 'X-API-TIMESTAMP: <api-key>' \
--data '
{
"accountId": "4b8e2f6a-91c3-4d57-a0e8-3f1c7b9d2e45",
"connectorCode": "binance_usdm",
"orderId": "1f2e3d4c-5b6a-4798-8a9b-0c1d2e3f4a5b",
"order": {
"quantity": "0.002",
"limit": {
"price": "59500",
"timeInForce": "gtc"
}
}
}
'import requests
url = "https://public-api.charting.com/api/v1/trading/order/amend"
payload = {
"accountId": "4b8e2f6a-91c3-4d57-a0e8-3f1c7b9d2e45",
"connectorCode": "binance_usdm",
"orderId": "1f2e3d4c-5b6a-4798-8a9b-0c1d2e3f4a5b",
"order": {
"quantity": "0.002",
"limit": {
"price": "59500",
"timeInForce": "gtc"
}
}
}
headers = {
"X-API-KEY": "<api-key>",
"X-API-TIMESTAMP": "<api-key>",
"X-API-SIGNATURE": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-API-KEY': '<api-key>',
'X-API-TIMESTAMP': '<api-key>',
'X-API-SIGNATURE': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
accountId: '4b8e2f6a-91c3-4d57-a0e8-3f1c7b9d2e45',
connectorCode: 'binance_usdm',
orderId: '1f2e3d4c-5b6a-4798-8a9b-0c1d2e3f4a5b',
order: {quantity: '0.002', limit: {price: '59500', timeInForce: 'gtc'}}
})
};
fetch('https://public-api.charting.com/api/v1/trading/order/amend', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://public-api.charting.com/api/v1/trading/order/amend",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'accountId' => '4b8e2f6a-91c3-4d57-a0e8-3f1c7b9d2e45',
'connectorCode' => 'binance_usdm',
'orderId' => '1f2e3d4c-5b6a-4798-8a9b-0c1d2e3f4a5b',
'order' => [
'quantity' => '0.002',
'limit' => [
'price' => '59500',
'timeInForce' => 'gtc'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <api-key>",
"X-API-SIGNATURE: <api-key>",
"X-API-TIMESTAMP: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://public-api.charting.com/api/v1/trading/order/amend"
payload := strings.NewReader("{\n \"accountId\": \"4b8e2f6a-91c3-4d57-a0e8-3f1c7b9d2e45\",\n \"connectorCode\": \"binance_usdm\",\n \"orderId\": \"1f2e3d4c-5b6a-4798-8a9b-0c1d2e3f4a5b\",\n \"order\": {\n \"quantity\": \"0.002\",\n \"limit\": {\n \"price\": \"59500\",\n \"timeInForce\": \"gtc\"\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-KEY", "<api-key>")
req.Header.Add("X-API-TIMESTAMP", "<api-key>")
req.Header.Add("X-API-SIGNATURE", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://public-api.charting.com/api/v1/trading/order/amend")
.header("X-API-KEY", "<api-key>")
.header("X-API-TIMESTAMP", "<api-key>")
.header("X-API-SIGNATURE", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"accountId\": \"4b8e2f6a-91c3-4d57-a0e8-3f1c7b9d2e45\",\n \"connectorCode\": \"binance_usdm\",\n \"orderId\": \"1f2e3d4c-5b6a-4798-8a9b-0c1d2e3f4a5b\",\n \"order\": {\n \"quantity\": \"0.002\",\n \"limit\": {\n \"price\": \"59500\",\n \"timeInForce\": \"gtc\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://public-api.charting.com/api/v1/trading/order/amend")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<api-key>'
request["X-API-TIMESTAMP"] = '<api-key>'
request["X-API-SIGNATURE"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"accountId\": \"4b8e2f6a-91c3-4d57-a0e8-3f1c7b9d2e45\",\n \"connectorCode\": \"binance_usdm\",\n \"orderId\": \"1f2e3d4c-5b6a-4798-8a9b-0c1d2e3f4a5b\",\n \"order\": {\n \"quantity\": \"0.002\",\n \"limit\": {\n \"price\": \"59500\",\n \"timeInForce\": \"gtc\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"requestId": "<string>"
}{
"error": {
"code": "invalid_argument",
"message": "field \"price\" is required for a limit order"
}
}{
"error": {
"code": "unauthenticated",
"message": "invalid API key or signature"
}
}{
"error": {
"code": "permission_denied",
"message": "permission denied"
}
}{
"error": {
"code": "not_found",
"message": "account not found"
}
}{
"error": {
"code": "rate_limited",
"message": "rate limit exceeded"
}
}Authorizations
Body
application/json
Was this page helpful?
⌘I
Amend an order
curl --request POST \
--url https://public-api.charting.com/api/v1/trading/order/amend \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--header 'X-API-SIGNATURE: <api-key>' \
--header 'X-API-TIMESTAMP: <api-key>' \
--data '
{
"accountId": "4b8e2f6a-91c3-4d57-a0e8-3f1c7b9d2e45",
"connectorCode": "binance_usdm",
"orderId": "1f2e3d4c-5b6a-4798-8a9b-0c1d2e3f4a5b",
"order": {
"quantity": "0.002",
"limit": {
"price": "59500",
"timeInForce": "gtc"
}
}
}
'import requests
url = "https://public-api.charting.com/api/v1/trading/order/amend"
payload = {
"accountId": "4b8e2f6a-91c3-4d57-a0e8-3f1c7b9d2e45",
"connectorCode": "binance_usdm",
"orderId": "1f2e3d4c-5b6a-4798-8a9b-0c1d2e3f4a5b",
"order": {
"quantity": "0.002",
"limit": {
"price": "59500",
"timeInForce": "gtc"
}
}
}
headers = {
"X-API-KEY": "<api-key>",
"X-API-TIMESTAMP": "<api-key>",
"X-API-SIGNATURE": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-API-KEY': '<api-key>',
'X-API-TIMESTAMP': '<api-key>',
'X-API-SIGNATURE': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
accountId: '4b8e2f6a-91c3-4d57-a0e8-3f1c7b9d2e45',
connectorCode: 'binance_usdm',
orderId: '1f2e3d4c-5b6a-4798-8a9b-0c1d2e3f4a5b',
order: {quantity: '0.002', limit: {price: '59500', timeInForce: 'gtc'}}
})
};
fetch('https://public-api.charting.com/api/v1/trading/order/amend', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://public-api.charting.com/api/v1/trading/order/amend",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'accountId' => '4b8e2f6a-91c3-4d57-a0e8-3f1c7b9d2e45',
'connectorCode' => 'binance_usdm',
'orderId' => '1f2e3d4c-5b6a-4798-8a9b-0c1d2e3f4a5b',
'order' => [
'quantity' => '0.002',
'limit' => [
'price' => '59500',
'timeInForce' => 'gtc'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <api-key>",
"X-API-SIGNATURE: <api-key>",
"X-API-TIMESTAMP: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://public-api.charting.com/api/v1/trading/order/amend"
payload := strings.NewReader("{\n \"accountId\": \"4b8e2f6a-91c3-4d57-a0e8-3f1c7b9d2e45\",\n \"connectorCode\": \"binance_usdm\",\n \"orderId\": \"1f2e3d4c-5b6a-4798-8a9b-0c1d2e3f4a5b\",\n \"order\": {\n \"quantity\": \"0.002\",\n \"limit\": {\n \"price\": \"59500\",\n \"timeInForce\": \"gtc\"\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-KEY", "<api-key>")
req.Header.Add("X-API-TIMESTAMP", "<api-key>")
req.Header.Add("X-API-SIGNATURE", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://public-api.charting.com/api/v1/trading/order/amend")
.header("X-API-KEY", "<api-key>")
.header("X-API-TIMESTAMP", "<api-key>")
.header("X-API-SIGNATURE", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"accountId\": \"4b8e2f6a-91c3-4d57-a0e8-3f1c7b9d2e45\",\n \"connectorCode\": \"binance_usdm\",\n \"orderId\": \"1f2e3d4c-5b6a-4798-8a9b-0c1d2e3f4a5b\",\n \"order\": {\n \"quantity\": \"0.002\",\n \"limit\": {\n \"price\": \"59500\",\n \"timeInForce\": \"gtc\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://public-api.charting.com/api/v1/trading/order/amend")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<api-key>'
request["X-API-TIMESTAMP"] = '<api-key>'
request["X-API-SIGNATURE"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"accountId\": \"4b8e2f6a-91c3-4d57-a0e8-3f1c7b9d2e45\",\n \"connectorCode\": \"binance_usdm\",\n \"orderId\": \"1f2e3d4c-5b6a-4798-8a9b-0c1d2e3f4a5b\",\n \"order\": {\n \"quantity\": \"0.002\",\n \"limit\": {\n \"price\": \"59500\",\n \"timeInForce\": \"gtc\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"requestId": "<string>"
}{
"error": {
"code": "invalid_argument",
"message": "field \"price\" is required for a limit order"
}
}{
"error": {
"code": "unauthenticated",
"message": "invalid API key or signature"
}
}{
"error": {
"code": "permission_denied",
"message": "permission denied"
}
}{
"error": {
"code": "not_found",
"message": "account not found"
}
}{
"error": {
"code": "rate_limited",
"message": "rate limit exceeded"
}
}