Skip to content

CloseGroupTrade

Info

DELETE https://{some_domain}/trade/close/group

Closes multiple open positions for a specific user in one request. You can: - close all positions, - close only profitable positions, - close only losing positions, optionally restricted by a particular symbol.

The close price is determined by the server; the client cannot pass close_price.

Authorization

All requests must include a JWT token:

Authorization: <JWT_TOKEN>

The token is issued by the authentication method (/sign/in) and contains session info (login, type, expiration).

Request

Content-Type: application/json

Body Parameters

Field Type Required Description
login int Yes User account login ID whose positions will be closed
type int Yes Close mode: 0 — all, 1 — only profitable (profit > 0), -1 — only losing (profit < 0)
symbol string No Symbol filter (e.g., EURUSD). If omitted, applies to all symbols
comment string No If provided, server sets comment to GROUP_CLOSE for affected orders

Response

Success (200)

{
  "data": "OK"
}

Error Responses

Code Error Description
400 INVALID_DATA Validation failed, missing or incorrect request fields

Note: Orders that fail internal checks (CheckCloseTrade) are silently skipped; the method still returns 200 OK for the batch.

Example

Request

DELETE https://{some_domain}/trade/close/group
Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
Content-Type: application/json
{
  "login": 1001,
  "type": 0,
  "symbol": "EURUSD",
  "comment": "any value to tag group close"
}

Examples

curl -X DELETE "https://{some_domain}/trade/close/group"       -H "Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."       -H "Content-Type: application/json"       --data-raw '{
    "login": 1001,
    "type": 1,
    "symbol": "EURUSD",
    "comment": "close profitable EURUSD"
  }'
const url = "https://{some_domain}/trade/close/group";
const jwt = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...";

async function closeGroupTrade() {
  const resp = await fetch(url, {
    method: "DELETE",
    headers: {
      "Authorization": jwt,
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      login: 1001,
      type: -1,           // close losing positions
      symbol: "XAUUSD",
      comment: "batch close losing XAU"
    })
  });

  console.log("Status:", resp.status);
  const data = await resp.json().catch(() => ({}));
  console.log("Body:", data);
}

closeGroupTrade().catch(console.error);
<?php
$url = "https://{some_domain}/trade/close/group";
$jwt = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...";

$payload = [
    "login" => 1001,
    "type" => 0,      // close all
    "symbol" => "GBPUSD",
    "comment" => "group close all GBPUSD"
];

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Authorization: " . $jwt,
    "Content-Type: application/json"
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload, JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

if ($response === false) {
    $error = curl_error($ch);
    curl_close($ch);
    throw new RuntimeException("cURL error: " . $error);
}
curl_close($ch);

header("Content-Type: application/json");
echo json_encode([
    "status" => $httpCode,
    "body" => json_decode($response, true)
], JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE);