Skip to content

Create multi legs order#

POST https://api.pro.anboto.xyz/api/v2/trading/order/create_multiLegs

Process a new order request and return order response ApiKeyAuth required.

Body params#

client_order_id string
A custom string to identify the order
Example: ABC-12345^12-10-23
subaccount string
The sub-account under which to trade the order
algo enum required
The execution strategy for the order. — PAIR
legs array[CreateOrderLegRequest] required
The order legs
start_time string
The start time in UTC
Example: 2024-01-22T22:05:00Z
end_time string
The end time in UTC
Example: 2024-04-22T22:05:00Z
The advanced order parameters to modify the execution behavior.

Headers#

Header
X-API-KEY string required
X-TIMESTAMP int64 ms required
X-SIGN string required
X-RECV-WINDOW int, default 5000

Responses#

201 Order created successfully
401 Unauthorized, Invalid Signature
429 Rate limit exceeded, retry later

Response fields — OrderSummary#

order_id integer
The Anboto assigned order identifier
client_order_id string
A custom string to identify the order
Example: ABC-12345^12-10-23
status enum
The order status — PENDING_NEW, ACCEPTED, REJECTED, PARTIALLY_FILLED, FILLED, PENDING_CANCEL, CANCELLED, PENDING_PAUSE, … (12 values)
created_at date-time required
The time in UTC when the order was created
Example: 2024-01-22T22:05:00Z
message string
Any additional information, usually if the order was rejected
error_code enum
The error code used to describe why an order was rejected. — OTHER, QUANTITY_EXCEED, AUTHENTICATION_ERROR, INSUFFICIENT_FUNDS, RATE_LIMIT_EXCEEDED, DDOS_PROTECTION, EXCHANGE_NOT_AVAILABLE, NETWORK_ERROR, … (34 values)
Example: INVALID_ORDER
body='{
  "client_order_id": "ABC-12345^12-10-23",
  "subaccount": "string",
  "algo": "PAIR",
  "legs": [
    {
      "exchange": "BINANCE",
      "symbol": "string",
      "asset_category": "SPOT",
      "side": "BUY",
      "target_value": "12.0",
      "ccy": "USD",
      "limit_price": "2205.10",
      "strategy": "TWAP",
      "clip_size_type": "ABSOLUTE",
      "clip_size_val": "0.01",
      "params": {
        "duration_seconds": "120",
        "trading_style": "PASSIVE",
        "urgency": "LOW",
        "randomize_amount": true,
        "would": {},
        "trigger": {},
        "placement_infos": {},
        "is_leading": true
      }
    }
  ],
  "start_time": "2024-01-22T22:05:00Z",
  "end_time": "2024-04-22T22:05:00Z",
  "params": {}
}'

curl -X POST "$BASE/api/v2/trading/order/create_multiLegs" \
  -H "X-API-KEY: $API_KEY" -H "X-TIMESTAMP: $ts" \
  -H "X-SIGN: $sign" \
  -H "Content-Type: application/json" -d "$body"
payload = {
  "client_order_id": "ABC-12345^12-10-23",
  "subaccount": "string",
  "algo": "PAIR",
  "legs": [
    {
      "exchange": "BINANCE",
      "symbol": "string",
      "asset_category": "SPOT",
      "side": "BUY",
      "target_value": "12.0",
      "ccy": "USD",
      "limit_price": "2205.10",
      "strategy": "TWAP",
      "clip_size_type": "ABSOLUTE",
      "clip_size_val": "0.01",
      "params": {
        "duration_seconds": "120",
        "trading_style": "PASSIVE",
        "urgency": "LOW",
        "randomize_amount": true,
        "would": {},
        "trigger": {},
        "placement_infos": {},
        "is_leading": true
      }
    }
  ],
  "start_time": "2024-01-22T22:05:00Z",
  "end_time": "2024-04-22T22:05:00Z",
  "params": {}
}

r = requests.post(f"{BASE}/api/v2/trading/order/create_multiLegs",
    data=json.dumps(payload)
    headers=signed_headers(payload))
print(r.json())
let payload = serde_json::json!({
  "client_order_id": "ABC-12345^12-10-23",
  "subaccount": "string",
  "algo": "PAIR",
  "legs": [
    {
      "exchange": "BINANCE",
      "symbol": "string",
      "asset_category": "SPOT",
      "side": "BUY",
      "target_value": "12.0",
      "ccy": "USD",
      "limit_price": "2205.10",
      "strategy": "TWAP",
      "clip_size_type": "ABSOLUTE",
      "clip_size_val": "0.01",
      "params": {
        "duration_seconds": "120",
        "trading_style": "PASSIVE",
        "urgency": "LOW",
        "randomize_amount": true,
        "would": {},
        "trigger": {},
        "placement_infos": {},
        "is_leading": true
      }
    }
  ],
  "start_time": "2024-01-22T22:05:00Z",
  "end_time": "2024-04-22T22:05:00Z",
  "params": {}
});

let resp = client
    .post(format!("{BASE}/api/v2/trading/order/create_multiLegs"))
    .headers(signed_headers(&payload))
    .json(&payload)
    .send()?;
println!("{}", resp.text()?);
payload := map[string]any{
    "client_order_id": "ABC-12345^12-10-23",
    "subaccount": "string",
    "algo": "PAIR",
    "legs": []any{
        map[string]any{
            "exchange": "BINANCE",
            "symbol": "string",
            "asset_category": "SPOT",
            "side": "BUY",
            "target_value": "12.0",
            "ccy": "USD",
            "limit_price": "2205.10",
            "strategy": "TWAP",
            "clip_size_type": "ABSOLUTE",
            "clip_size_val": "0.01",
            "params": map[string]any{
                "duration_seconds": "120",
                "trading_style": "PASSIVE",
                "urgency": "LOW",
                "randomize_amount": true,
                "would": map[string]any{},
                "trigger": map[string]any{},
                "placement_infos": map[string]any{},
                "is_leading": true,
            },
        },
    },
    "start_time": "2024-01-22T22:05:00Z",
    "end_time": "2024-04-22T22:05:00Z",
    "params": map[string]any{},
}
body, _ := json.Marshal(payload)

req, _ := http.NewRequest("POST", BASE+"/api/v2/trading/order/create_multiLegs", bytes.NewReader(body))
for k, v := range signedHeaders(string(body)) {
    req.Header.Set(k, v)
}
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
    log.Fatal(err)
}
defer resp.Body.Close()
io.Copy(os.Stdout, resp.Body)
String jsonBody = mapper.writeValueAsString(payload);
HttpResponse<String> resp = client.send(
    signedPost("/api/v2/trading/order/create_multiLegs", jsonBody),
    HttpResponse.BodyHandlers.ofString());
const payload: CreateMultiLegsParentOrderRequest = {
  "client_order_id": "ABC-12345^12-10-23",
  "subaccount": "string",
  "algo": "PAIR",
  "legs": [
    {
      "exchange": "BINANCE",
      "symbol": "string",
      "asset_category": "SPOT",
      "side": "BUY",
      "target_value": "12.0",
      "ccy": "USD",
      "limit_price": "2205.10",
      "strategy": "TWAP",
      "clip_size_type": "ABSOLUTE",
      "clip_size_val": "0.01",
      "params": {
        "duration_seconds": "120",
        "trading_style": "PASSIVE",
        "urgency": "LOW",
        "randomize_amount": true,
        "would": {},
        "trigger": {},
        "placement_infos": {},
        "is_leading": true
      }
    }
  ],
  "start_time": "2024-01-22T22:05:00Z",
  "end_time": "2024-04-22T22:05:00Z",
  "params": {}
};

const res = await fetch(`${BASE}/api/v2/trading/order/create_multiLegs`, {
  method: "POST",
  headers: signedHeaders(payload),
  body: JSON.stringify(payload),
});
const data: OrderSummary = await res.json();
val jsonBody = mapper.writeValueAsString(payload)
val request = signedPost("/api/v2/trading/order/create_multiLegs", jsonBody)
val response = client.send(request, HttpResponse.BodyHandlers.ofString())
println(response.body())
std::string body = R"({
  "client_order_id": "ABC-12345^12-10-23",
  "subaccount": "string",
  "algo": "PAIR",
  "legs": [
    {
      "exchange": "BINANCE",
      "symbol": "string",
      "asset_category": "SPOT",
      "side": "BUY",
      "target_value": "12.0",
      "ccy": "USD",
      "limit_price": "2205.10",
      "strategy": "TWAP",
      "clip_size_type": "ABSOLUTE",
      "clip_size_val": "0.01",
      "params": {
        "duration_seconds": "120",
        "trading_style": "PASSIVE",
        "urgency": "LOW",
        "randomize_amount": true,
        "would": {},
        "trigger": {},
        "placement_infos": {},
        "is_leading": true
      }
    }
  ],
  "start_time": "2024-01-22T22:05:00Z",
  "end_time": "2024-04-22T22:05:00Z",
  "params": {}
})";

cpr::Response r = cpr::Post(
    cpr::Url{BASE + "/api/v2/trading/order/create_multiLegs"},
    signedHeaders(body),
    cpr::Header{{"Content-Type", "application/json"}},
    cpr::Body{body});
std::cout << r.text << std::endl;
const payload = {
  "client_order_id": "ABC-12345^12-10-23",
  "subaccount": "string",
  "algo": "PAIR",
  "legs": [
    {
      "exchange": "BINANCE",
      "symbol": "string",
      "asset_category": "SPOT",
      "side": "BUY",
      "target_value": "12.0",
      "ccy": "USD",
      "limit_price": "2205.10",
      "strategy": "TWAP",
      "clip_size_type": "ABSOLUTE",
      "clip_size_val": "0.01",
      "params": {
        "duration_seconds": "120",
        "trading_style": "PASSIVE",
        "urgency": "LOW",
        "randomize_amount": true,
        "would": {},
        "trigger": {},
        "placement_infos": {},
        "is_leading": true
      }
    }
  ],
  "start_time": "2024-01-22T22:05:00Z",
  "end_time": "2024-04-22T22:05:00Z",
  "params": {}
};

const res = await fetch(`${BASE}/api/v2/trading/order/create_multiLegs`, {
  method: "POST",
  headers: signedHeaders(payload),
  body: JSON.stringify(payload),
});
console.log(await res.json());

Response 201

{
  "order_id": 0,
  "client_order_id": "ABC-12345^12-10-23",
  "status": "PENDING_NEW",
  "created_at": "2024-01-22T22:05:00Z",
  "message": "string",
  "error_code": "OTHER"
}