Orders
Place an order
Places an order on one instrument of one account: a market or limit order, optionally conditional or trailing, with an optional take-profit/stop-loss.
ordersets exactly one ofmarketandlimit, and at most one ofstop(conditional order) andtrailingStop(trailing-stop order).order.takeProfit/order.stopLossattach a take-profit/stop-loss to the order; theirlimitPricemakes them limit orders on trigger. Support differs per connector: seetakeProfitand the connector’s capabilities.reduceOnlyapplies to derivatives,isLeverageto spot.labeltags the order; a bulk cancel can be narrowed to it.- Check prices and quantities against the order-data stream before sending.
Safe to retry with the same Idempotency-Key: a repeated request never
creates a second order.
202 means the order 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
/
create
Place an order
curl --request POST \
--url https://public-api.charting.com/api/v1/trading/order/create \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--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",
"instrument": {
"exchange": "CXBNCE",
"symbol": "BTC/USDT"
},
"label": "grid-btc-1",
"order": {
"side": "buy",
"quantity": "0.001",
"limit": {
"price": "60000",
"timeInForce": "gtc"
},
"takeProfit": {
"triggerPrice": "65000"
},
"stopLoss": {
"triggerPrice": "58000"
}
}
}
'import requests
url = "https://public-api.charting.com/api/v1/trading/order/create"
payload = {
"accountId": "4b8e2f6a-91c3-4d57-a0e8-3f1c7b9d2e45",
"connectorCode": "binance_usdm",
"instrument": {
"exchange": "CXBNCE",
"symbol": "BTC/USDT"
},
"label": "grid-btc-1",
"order": {
"side": "buy",
"quantity": "0.001",
"limit": {
"price": "60000",
"timeInForce": "gtc"
},
"takeProfit": { "triggerPrice": "65000" },
"stopLoss": { "triggerPrice": "58000" }
}
}
headers = {
"Idempotency-Key": "<idempotency-key>",
"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: {
'Idempotency-Key': '<idempotency-key>',
'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',
instrument: {exchange: 'CXBNCE', symbol: 'BTC/USDT'},
label: 'grid-btc-1',
order: {
side: 'buy',
quantity: '0.001',
limit: {price: '60000', timeInForce: 'gtc'},
takeProfit: {triggerPrice: '65000'},
stopLoss: {triggerPrice: '58000'}
}
})
};
fetch('https://public-api.charting.com/api/v1/trading/order/create', 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/create",
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',
'instrument' => [
'exchange' => 'CXBNCE',
'symbol' => 'BTC/USDT'
],
'label' => 'grid-btc-1',
'order' => [
'side' => 'buy',
'quantity' => '0.001',
'limit' => [
'price' => '60000',
'timeInForce' => 'gtc'
],
'takeProfit' => [
'triggerPrice' => '65000'
],
'stopLoss' => [
'triggerPrice' => '58000'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"Idempotency-Key: <idempotency-key>",
"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/create"
payload := strings.NewReader("{\n \"accountId\": \"4b8e2f6a-91c3-4d57-a0e8-3f1c7b9d2e45\",\n \"connectorCode\": \"binance_usdm\",\n \"instrument\": {\n \"exchange\": \"CXBNCE\",\n \"symbol\": \"BTC/USDT\"\n },\n \"label\": \"grid-btc-1\",\n \"order\": {\n \"side\": \"buy\",\n \"quantity\": \"0.001\",\n \"limit\": {\n \"price\": \"60000\",\n \"timeInForce\": \"gtc\"\n },\n \"takeProfit\": {\n \"triggerPrice\": \"65000\"\n },\n \"stopLoss\": {\n \"triggerPrice\": \"58000\"\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Idempotency-Key", "<idempotency-key>")
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/create")
.header("Idempotency-Key", "<idempotency-key>")
.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 \"instrument\": {\n \"exchange\": \"CXBNCE\",\n \"symbol\": \"BTC/USDT\"\n },\n \"label\": \"grid-btc-1\",\n \"order\": {\n \"side\": \"buy\",\n \"quantity\": \"0.001\",\n \"limit\": {\n \"price\": \"60000\",\n \"timeInForce\": \"gtc\"\n },\n \"takeProfit\": {\n \"triggerPrice\": \"65000\"\n },\n \"stopLoss\": {\n \"triggerPrice\": \"58000\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://public-api.charting.com/api/v1/trading/order/create")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = '<idempotency-key>'
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 \"instrument\": {\n \"exchange\": \"CXBNCE\",\n \"symbol\": \"BTC/USDT\"\n },\n \"label\": \"grid-btc-1\",\n \"order\": {\n \"side\": \"buy\",\n \"quantity\": \"0.001\",\n \"limit\": {\n \"price\": \"60000\",\n \"timeInForce\": \"gtc\"\n },\n \"takeProfit\": {\n \"triggerPrice\": \"65000\"\n },\n \"stopLoss\": {\n \"triggerPrice\": \"58000\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"orderId": "1f2e3d4c-5b6a-4798-8a9b-0c1d2e3f4a5b",
"requestId": "9a8b7c6d-5e4f-4321-8765-0fedcba98765"
}{
"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
Headers
Your unique key for this order placement, for example a UUID. It only protects against duplicates; it is not stored on the order and does not appear in order events.
- A repeated request with the same key within 24 hours never creates
a second order: it is answered with the
orderIdof the first one. Retry with the same key after a timeout or a 5xx. - Send the same body with the same key. The body of a repeated request is not compared: a reused key returns the first order even if the body differs.
- A key already used with another account is rejected with 400.
- After 24 hours the key is forgotten, and a request with it places a new order.
Minimum string length:
1Body
application/json
Was this page helpful?
⌘I
Place an order
curl --request POST \
--url https://public-api.charting.com/api/v1/trading/order/create \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--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",
"instrument": {
"exchange": "CXBNCE",
"symbol": "BTC/USDT"
},
"label": "grid-btc-1",
"order": {
"side": "buy",
"quantity": "0.001",
"limit": {
"price": "60000",
"timeInForce": "gtc"
},
"takeProfit": {
"triggerPrice": "65000"
},
"stopLoss": {
"triggerPrice": "58000"
}
}
}
'import requests
url = "https://public-api.charting.com/api/v1/trading/order/create"
payload = {
"accountId": "4b8e2f6a-91c3-4d57-a0e8-3f1c7b9d2e45",
"connectorCode": "binance_usdm",
"instrument": {
"exchange": "CXBNCE",
"symbol": "BTC/USDT"
},
"label": "grid-btc-1",
"order": {
"side": "buy",
"quantity": "0.001",
"limit": {
"price": "60000",
"timeInForce": "gtc"
},
"takeProfit": { "triggerPrice": "65000" },
"stopLoss": { "triggerPrice": "58000" }
}
}
headers = {
"Idempotency-Key": "<idempotency-key>",
"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: {
'Idempotency-Key': '<idempotency-key>',
'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',
instrument: {exchange: 'CXBNCE', symbol: 'BTC/USDT'},
label: 'grid-btc-1',
order: {
side: 'buy',
quantity: '0.001',
limit: {price: '60000', timeInForce: 'gtc'},
takeProfit: {triggerPrice: '65000'},
stopLoss: {triggerPrice: '58000'}
}
})
};
fetch('https://public-api.charting.com/api/v1/trading/order/create', 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/create",
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',
'instrument' => [
'exchange' => 'CXBNCE',
'symbol' => 'BTC/USDT'
],
'label' => 'grid-btc-1',
'order' => [
'side' => 'buy',
'quantity' => '0.001',
'limit' => [
'price' => '60000',
'timeInForce' => 'gtc'
],
'takeProfit' => [
'triggerPrice' => '65000'
],
'stopLoss' => [
'triggerPrice' => '58000'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"Idempotency-Key: <idempotency-key>",
"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/create"
payload := strings.NewReader("{\n \"accountId\": \"4b8e2f6a-91c3-4d57-a0e8-3f1c7b9d2e45\",\n \"connectorCode\": \"binance_usdm\",\n \"instrument\": {\n \"exchange\": \"CXBNCE\",\n \"symbol\": \"BTC/USDT\"\n },\n \"label\": \"grid-btc-1\",\n \"order\": {\n \"side\": \"buy\",\n \"quantity\": \"0.001\",\n \"limit\": {\n \"price\": \"60000\",\n \"timeInForce\": \"gtc\"\n },\n \"takeProfit\": {\n \"triggerPrice\": \"65000\"\n },\n \"stopLoss\": {\n \"triggerPrice\": \"58000\"\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Idempotency-Key", "<idempotency-key>")
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/create")
.header("Idempotency-Key", "<idempotency-key>")
.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 \"instrument\": {\n \"exchange\": \"CXBNCE\",\n \"symbol\": \"BTC/USDT\"\n },\n \"label\": \"grid-btc-1\",\n \"order\": {\n \"side\": \"buy\",\n \"quantity\": \"0.001\",\n \"limit\": {\n \"price\": \"60000\",\n \"timeInForce\": \"gtc\"\n },\n \"takeProfit\": {\n \"triggerPrice\": \"65000\"\n },\n \"stopLoss\": {\n \"triggerPrice\": \"58000\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://public-api.charting.com/api/v1/trading/order/create")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = '<idempotency-key>'
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 \"instrument\": {\n \"exchange\": \"CXBNCE\",\n \"symbol\": \"BTC/USDT\"\n },\n \"label\": \"grid-btc-1\",\n \"order\": {\n \"side\": \"buy\",\n \"quantity\": \"0.001\",\n \"limit\": {\n \"price\": \"60000\",\n \"timeInForce\": \"gtc\"\n },\n \"takeProfit\": {\n \"triggerPrice\": \"65000\"\n },\n \"stopLoss\": {\n \"triggerPrice\": \"58000\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"orderId": "1f2e3d4c-5b6a-4798-8a9b-0c1d2e3f4a5b",
"requestId": "9a8b7c6d-5e4f-4321-8765-0fedcba98765"
}{
"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"
}
}