const res = await fetch('https://app.trdrs.co/api/trading/replace', {
method: 'POST',
headers: {
'content-type': 'application/json',
Authorization: `Bearer ${process.env.TRDRS_API_KEY}`,
},
body: JSON.stringify({
"brokerOrderId": "234992187",
"instrument": "ESU6",
"side": "sell",
"qty": 2,
"orderType": "limit",
"price": 6497.25,
"clientOrderId": "replace-tp-1787582100"
}),
})
const data = await res.json()curl -X POST 'https://app.trdrs.co/api/trading/replace' \
-H "Authorization: Bearer $TRDRS_API_KEY" \
-H 'content-type: application/json' \
-d '{"brokerOrderId":"234992187","instrument":"ESU6","side":"sell","qty":2,"orderType":"limit","price":6497.25,"clientOrderId":"replace-tp-1787582100"}'import requests
url = "https://app.trdrs.co/api/trading/replace"
payload = {
"brokerOrderId": "234992187",
"instrument": "ESU6",
"side": "sell",
"qty": 2,
"orderType": "limit",
"price": 6497.25,
"clientOrderId": "replace-tp-1787582100"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.trdrs.co/api/trading/replace",
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([
'brokerOrderId' => '234992187',
'instrument' => 'ESU6',
'side' => 'sell',
'qty' => 2,
'orderType' => 'limit',
'price' => 6497.25,
'clientOrderId' => 'replace-tp-1787582100'
]),
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/replace"
payload := strings.NewReader("{\n \"brokerOrderId\": \"234992187\",\n \"instrument\": \"ESU6\",\n \"side\": \"sell\",\n \"qty\": 2,\n \"orderType\": \"limit\",\n \"price\": 6497.25,\n \"clientOrderId\": \"replace-tp-1787582100\"\n}")
req, _ := http.NewRequest("POST", 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.post("https://app.trdrs.co/api/trading/replace")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"brokerOrderId\": \"234992187\",\n \"instrument\": \"ESU6\",\n \"side\": \"sell\",\n \"qty\": 2,\n \"orderType\": \"limit\",\n \"price\": 6497.25,\n \"clientOrderId\": \"replace-tp-1787582100\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.trdrs.co/api/trading/replace")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"brokerOrderId\": \"234992187\",\n \"instrument\": \"ESU6\",\n \"side\": \"sell\",\n \"qty\": 2,\n \"orderType\": \"limit\",\n \"price\": 6497.25,\n \"clientOrderId\": \"replace-tp-1787582100\"\n}"
response = http.request(request)
puts response.read_body{
"outcome": "amended",
"brokerOrderId": "234992187",
"message": null
}{
"error": "invalid_instrument"
}{
"error": "invalid_instrument"
}{
"error": "invalid_instrument"
}Replace an order
Moves one resting order to a new price. One operation under one idempotency key (clientOrderId). The engine amends natively where the venue truly amends (identity preserved) and runs its typed composite everywhere else. The response outcome is the truth the caller must surface: replaced and amended are successes; restored, restored_without_bracket, gone, and order_lost are not. Send restoreBracket (the order’s current exits as you know them) on every replace of an entry with exits attached; without it a rejected re-place restores the entry without its exits. orderType must match the type the engine reports for the order (400 order_type_mismatch).
const res = await fetch('https://app.trdrs.co/api/trading/replace', {
method: 'POST',
headers: {
'content-type': 'application/json',
Authorization: `Bearer ${process.env.TRDRS_API_KEY}`,
},
body: JSON.stringify({
"brokerOrderId": "234992187",
"instrument": "ESU6",
"side": "sell",
"qty": 2,
"orderType": "limit",
"price": 6497.25,
"clientOrderId": "replace-tp-1787582100"
}),
})
const data = await res.json()curl -X POST 'https://app.trdrs.co/api/trading/replace' \
-H "Authorization: Bearer $TRDRS_API_KEY" \
-H 'content-type: application/json' \
-d '{"brokerOrderId":"234992187","instrument":"ESU6","side":"sell","qty":2,"orderType":"limit","price":6497.25,"clientOrderId":"replace-tp-1787582100"}'import requests
url = "https://app.trdrs.co/api/trading/replace"
payload = {
"brokerOrderId": "234992187",
"instrument": "ESU6",
"side": "sell",
"qty": 2,
"orderType": "limit",
"price": 6497.25,
"clientOrderId": "replace-tp-1787582100"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.trdrs.co/api/trading/replace",
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([
'brokerOrderId' => '234992187',
'instrument' => 'ESU6',
'side' => 'sell',
'qty' => 2,
'orderType' => 'limit',
'price' => 6497.25,
'clientOrderId' => 'replace-tp-1787582100'
]),
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/replace"
payload := strings.NewReader("{\n \"brokerOrderId\": \"234992187\",\n \"instrument\": \"ESU6\",\n \"side\": \"sell\",\n \"qty\": 2,\n \"orderType\": \"limit\",\n \"price\": 6497.25,\n \"clientOrderId\": \"replace-tp-1787582100\"\n}")
req, _ := http.NewRequest("POST", 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.post("https://app.trdrs.co/api/trading/replace")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"brokerOrderId\": \"234992187\",\n \"instrument\": \"ESU6\",\n \"side\": \"sell\",\n \"qty\": 2,\n \"orderType\": \"limit\",\n \"price\": 6497.25,\n \"clientOrderId\": \"replace-tp-1787582100\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.trdrs.co/api/trading/replace")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"brokerOrderId\": \"234992187\",\n \"instrument\": \"ESU6\",\n \"side\": \"sell\",\n \"qty\": 2,\n \"orderType\": \"limit\",\n \"price\": 6497.25,\n \"clientOrderId\": \"replace-tp-1787582100\"\n}"
response = http.request(request)
puts response.read_body{
"outcome": "amended",
"brokerOrderId": "234992187",
"message": null
}{
"error": "invalid_instrument"
}{
"error": "invalid_instrument"
}{
"error": "invalid_instrument"
}Authorizations
Your firm’s API key (the API calls this the tenant key; trdrs_sk_…), server-to-server only.
Body
buy, sell limit, stop, stop_limit A limit's resting price, a stop's trigger. For stop_limit, its trigger
Required for stop_limit: the limit the trigger converts to
Bracket-leg end state: null removes, object sets, omit leaves
The current bracket, for restore-on-reject