const res = await fetch('https://app.trdrs.co/api/trading/exits/{id}', {
method: 'PUT',
headers: {
'content-type': 'application/json',
Authorization: `Bearer ${process.env.TRDRS_API_KEY}`,
},
body: JSON.stringify({
"exits": {
"unit": "ticks",
"takeProfits": [
{
"quantity": 1,
"price": 6486
}
],
"stopLosses": [
{
"quantity": 2,
"price": 6477.5,
"breakeven": {
"trigger": 8,
"plus": 0
},
"trail": [
{
"trigger": 16,
"distance": 8,
"frequencyTicks": 2
}
]
}
]
}
}),
})
const data = await res.json()curl -X PUT 'https://app.trdrs.co/api/trading/exits/{id}' \
-H "Authorization: Bearer $TRDRS_API_KEY" \
-H 'content-type: application/json' \
-d '{"exits":{"unit":"ticks","takeProfits":[{"quantity":1,"price":6486}],"stopLosses":[{"quantity":2,"price":6477.5,"breakeven":{"trigger":8,"plus":0},"trail":[{"trigger":16,"distance":8,"frequencyTicks":2}]}]}}'import requests
url = "https://app.trdrs.co/api/trading/exits/{id}"
payload = { "exits": {
"unit": "ticks",
"takeProfits": [
{
"quantity": 1,
"price": 6486
}
],
"stopLosses": [
{
"quantity": 2,
"price": 6477.5,
"breakeven": {
"trigger": 8,
"plus": 0
},
"trail": [
{
"trigger": 16,
"distance": 8,
"frequencyTicks": 2
}
]
}
]
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.trdrs.co/api/trading/exits/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'exits' => [
'unit' => 'ticks',
'takeProfits' => [
[
'quantity' => 1,
'price' => 6486
]
],
'stopLosses' => [
[
'quantity' => 2,
'price' => 6477.5,
'breakeven' => [
'trigger' => 8,
'plus' => 0
],
'trail' => [
[
'trigger' => 16,
'distance' => 8,
'frequencyTicks' => 2
]
]
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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://app.trdrs.co/api/trading/exits/{id}"
payload := strings.NewReader("{\n \"exits\": {\n \"unit\": \"ticks\",\n \"takeProfits\": [\n {\n \"quantity\": 1,\n \"price\": 6486\n }\n ],\n \"stopLosses\": [\n {\n \"quantity\": 2,\n \"price\": 6477.5,\n \"breakeven\": {\n \"trigger\": 8,\n \"plus\": 0\n },\n \"trail\": [\n {\n \"trigger\": 16,\n \"distance\": 8,\n \"frequencyTicks\": 2\n }\n ]\n }\n ]\n }\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.put("https://app.trdrs.co/api/trading/exits/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"exits\": {\n \"unit\": \"ticks\",\n \"takeProfits\": [\n {\n \"quantity\": 1,\n \"price\": 6486\n }\n ],\n \"stopLosses\": [\n {\n \"quantity\": 2,\n \"price\": 6477.5,\n \"breakeven\": {\n \"trigger\": 8,\n \"plus\": 0\n },\n \"trail\": [\n {\n \"trigger\": 16,\n \"distance\": 8,\n \"frequencyTicks\": 2\n }\n ]\n }\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.trdrs.co/api/trading/exits/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"exits\": {\n \"unit\": \"ticks\",\n \"takeProfits\": [\n {\n \"quantity\": 1,\n \"price\": 6486\n }\n ],\n \"stopLosses\": [\n {\n \"quantity\": 2,\n \"price\": 6477.5,\n \"breakeven\": {\n \"trigger\": 8,\n \"plus\": 0\n },\n \"trail\": [\n {\n \"trigger\": 16,\n \"distance\": 8,\n \"frequencyTicks\": 2\n }\n ]\n }\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"bracket": {
"id": "b41e7d2a-9c58-4f03-a6b1-2e8d5c7f0a94",
"state": "active"
},
"refused": null,
"stuck": 0
}{
"error": "invalid_instrument"
}{
"error": "invalid_instrument"
}{
"error": "invalid_instrument"
}{
"error": "invalid_instrument"
}{
"error": "invalid_instrument"
}Change a bracket
Replaces a bracket’s ladders with exits. A leg that keeps its place in its ladder keeps its id and moves. The new layout rests before the old one is cancelled, and if the provider refuses any pair, the bracket stays exactly as it was. Distances are measured from the entry: the fill’s average once the entry has filled, and the entry’s own price before. Where the position is open, every price must clear the market on the side it protects. No hold on the account refuses a change of a bracket on a position.
A bracket waiting on a resting entry changes before the fill too, its prices on their side of the entry’s own. On the paper book, which holds it inside the entry, the entry is replaced with itself carrying the new pairs in the same step that changes the bracket, and the answer’s entryOrderId names the order it rests as afterwards; a hold that refuses new entries refuses that replacement too. Where a provider holds the pairs attached to the unfilled entry itself, the bracket changes only once the entry fills.
Required key: Trading API key. A Connect app’s backend can also send it with the app’s API key, and a venue’s backend with its Venue key, which carries trader:trade, each naming one of its own traders in x-trdrs-trader: it then runs on that trader’s own accounts.
const res = await fetch('https://app.trdrs.co/api/trading/exits/{id}', {
method: 'PUT',
headers: {
'content-type': 'application/json',
Authorization: `Bearer ${process.env.TRDRS_API_KEY}`,
},
body: JSON.stringify({
"exits": {
"unit": "ticks",
"takeProfits": [
{
"quantity": 1,
"price": 6486
}
],
"stopLosses": [
{
"quantity": 2,
"price": 6477.5,
"breakeven": {
"trigger": 8,
"plus": 0
},
"trail": [
{
"trigger": 16,
"distance": 8,
"frequencyTicks": 2
}
]
}
]
}
}),
})
const data = await res.json()curl -X PUT 'https://app.trdrs.co/api/trading/exits/{id}' \
-H "Authorization: Bearer $TRDRS_API_KEY" \
-H 'content-type: application/json' \
-d '{"exits":{"unit":"ticks","takeProfits":[{"quantity":1,"price":6486}],"stopLosses":[{"quantity":2,"price":6477.5,"breakeven":{"trigger":8,"plus":0},"trail":[{"trigger":16,"distance":8,"frequencyTicks":2}]}]}}'import requests
url = "https://app.trdrs.co/api/trading/exits/{id}"
payload = { "exits": {
"unit": "ticks",
"takeProfits": [
{
"quantity": 1,
"price": 6486
}
],
"stopLosses": [
{
"quantity": 2,
"price": 6477.5,
"breakeven": {
"trigger": 8,
"plus": 0
},
"trail": [
{
"trigger": 16,
"distance": 8,
"frequencyTicks": 2
}
]
}
]
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.trdrs.co/api/trading/exits/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'exits' => [
'unit' => 'ticks',
'takeProfits' => [
[
'quantity' => 1,
'price' => 6486
]
],
'stopLosses' => [
[
'quantity' => 2,
'price' => 6477.5,
'breakeven' => [
'trigger' => 8,
'plus' => 0
],
'trail' => [
[
'trigger' => 16,
'distance' => 8,
'frequencyTicks' => 2
]
]
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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://app.trdrs.co/api/trading/exits/{id}"
payload := strings.NewReader("{\n \"exits\": {\n \"unit\": \"ticks\",\n \"takeProfits\": [\n {\n \"quantity\": 1,\n \"price\": 6486\n }\n ],\n \"stopLosses\": [\n {\n \"quantity\": 2,\n \"price\": 6477.5,\n \"breakeven\": {\n \"trigger\": 8,\n \"plus\": 0\n },\n \"trail\": [\n {\n \"trigger\": 16,\n \"distance\": 8,\n \"frequencyTicks\": 2\n }\n ]\n }\n ]\n }\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.put("https://app.trdrs.co/api/trading/exits/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"exits\": {\n \"unit\": \"ticks\",\n \"takeProfits\": [\n {\n \"quantity\": 1,\n \"price\": 6486\n }\n ],\n \"stopLosses\": [\n {\n \"quantity\": 2,\n \"price\": 6477.5,\n \"breakeven\": {\n \"trigger\": 8,\n \"plus\": 0\n },\n \"trail\": [\n {\n \"trigger\": 16,\n \"distance\": 8,\n \"frequencyTicks\": 2\n }\n ]\n }\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.trdrs.co/api/trading/exits/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"exits\": {\n \"unit\": \"ticks\",\n \"takeProfits\": [\n {\n \"quantity\": 1,\n \"price\": 6486\n }\n ],\n \"stopLosses\": [\n {\n \"quantity\": 2,\n \"price\": 6477.5,\n \"breakeven\": {\n \"trigger\": 8,\n \"plus\": 0\n },\n \"trail\": [\n {\n \"trigger\": 16,\n \"distance\": 8,\n \"frequencyTicks\": 2\n }\n ]\n }\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"bracket": {
"id": "b41e7d2a-9c58-4f03-a6b1-2e8d5c7f0a94",
"state": "active"
},
"refused": null,
"stuck": 0
}{
"error": "invalid_instrument"
}{
"error": "invalid_instrument"
}{
"error": "invalid_instrument"
}{
"error": "invalid_instrument"
}{
"error": "invalid_instrument"
}Authorizations
The Trading API key (trdrs_sk_…), for market data, orders and account state on the accounts its owner holds. Use it server-to-server, and keep it on your server. Its scope is named trading in the API.
Path Parameters
The bracket's id.
Query Parameters
The provider the account is at, such as rithmic or paper. Omit it to use your default provider. An unknown value is refused with 400, never replaced with another provider.
The account number at that provider. It must be one of your own accounts, or the call is refused with 400.
Body
The bracket's ladders as they should be.
The take profits and stop losses. A leg that keeps its place in its ladder keeps its id. Distances are measured from the entry.
Show child attributes
Show child attributes
{
"takeProfits": [{ "quantity": 1, "price": 6485.5 }],
"stopLosses": [{ "quantity": 2, "price": 6477.5 }]
}
Response
The change is made, or refused and undone: refused is the provider's reason where it refused a pair, and the bracket is as it was. stuck counts orders that would not cancel and still rest; the bracket keeps them, so the account stream shows them.
A bracket after a protection, a change or a withdrawal.
The bracket.
Show child attributes
Show child attributes
{
"id": "b41e7d2a-9c58-4f03-a6b1-2e8d5c7f0a94",
"state": "active"
}
The provider's reason where it refused a pair, or null. A change of a bracket the provider refuses leaves the bracket as it was. On a protection, the refused pair's part of the position shows as unprotected and the other pairs rest.
How many orders the change meant to cancel that would not cancel and still rest. The bracket keeps them, so the account stream shows them.
On a protection of a resting entry, and on a change or a withdrawal of a bracket waiting on one: the order the entry rests as afterwards. The paper book replaces the entry with itself to change the pairs it carries, so there the entry rests under a new id. Every other provider keeps the entry's id. Absent on every other answer.
"protect-entry-esu6-1787581560"