OpenTrade
Opens a new trade order (market or pending).
POST
https://{some_domain}/trade/open
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 |
cmd |
int |
Yes |
Trade command type (0=BUY, 1=SELL, 2=BUY_LIMIT, 3=SELL_LIMIT, etc.) |
volume |
int |
Yes |
Trade volume in minimal lots (e.g. 100, 1000) |
symbol |
string |
Yes |
Trading symbol (e.g. EURUSD) |
sl |
double |
Yes |
Stop Loss level (>= 0) |
tp |
double |
Yes |
Take Profit level (>= 0) |
open_time |
int64 |
No |
Open time (epoch timestamp) |
expiration |
int64 |
No |
Expiration time (epoch timestamp, for pending orders) |
comment |
string |
No |
Custom user comment |
Response
Success (200)
Error Responses
| Code |
Error |
Description |
| 400 |
INVALID_DATA |
Validation failed, missing or incorrect request fields |
| 401 |
PERMISSION_DENIED |
Access denied (invalid session or wrong __access.type) |
| 403 |
USER_NOT_FOUND |
User does not exist |
| 404 |
GROUP_NOT_FOUND |
User group not found |
| 500 |
OPEN_ORDER_ERROR |
Failed to check or execute trade (see message for info) |
Examples
1
2
3
4
5
6
7
8
9
10
11
12
13 | curl -X POST "https://{some_domain}/trade/open"
-H "Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
-H "Content-Type: application/json"
--data-raw '{
"login": 1001,
"cmd": 0,
"volume": 100,
"symbol": "EURUSD",
"sl": 1.0850,
"tp": 1.1000,
"open_price": 1.0900,
"comment": "Scalping order"
}'
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 | const url = "https://{some_domain}/trade/open";
const jwt = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...";
async function openTrade() {
const resp = await fetch(url, {
method: "POST",
headers: {
"Authorization": jwt,
"Content-Type": "application/json"
},
body: JSON.stringify({
login: 1001,
cmd: 0,
volume: 100,
symbol: "EURUSD",
sl: 1.0850,
tp: 1.1000,
open_price: 1.0900,
comment: "Scalping order"
})
});
console.log("Status:", resp.status);
const data = await resp.json().catch(() => ({}));
console.log("Body:", data);
}
openTrade().catch(console.error);
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39 | <?php
$url = "https://{some_domain}/trade/open";
$jwt = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...";
$payload = [
"login" => 1001,
"cmd" => 0,
"volume" => 100,
"symbol" => "EURUSD",
"sl" => 1.0850,
"tp" => 1.1000,
"open_price" => 1.0900,
"comment" => "Scalping order"
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
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);
|
Response