Import History Trade
ImportHistoryTrade¶
Description:
Imports a historical closed market trade into the system. This method is intended for reporting backfill, corrections, or account migration. The imported record is stored as a closed trade snapshot with state TS_CLOSED_NORMAL.
Access Control¶
🛡️ Access Level Required:
SESSION_ADMIN,SESSION_MANAGER,SESSION_DEALER
Endpoint¶
This method is routed internally as ImportHistoryTrade.
Request Parameters¶
| Name | Type | Required | Description |
|---|---|---|---|
| order | int | Yes | Trade order ID |
| login | int | Yes | Login ID of the trader |
| cmd | int | Yes | Command type. Supported values: OP_BUY or OP_SELL |
| volume | int | Yes | Volume in minimal lots |
| open_time | int | Yes | Open time (Unix timestamp) |
| close_time | int | Yes | Close time (Unix timestamp) |
| open_price | double | Yes | Trade open price |
| close_price | double | Yes | Trade close price |
| profit | double | Yes | Total profit |
| commission | double | Yes | Commission applied |
| storage | double | Yes | Storage swap value |
| symbol | string | Yes | Symbol traded |
| sl | double | Yes | Stop Loss |
| tp | double | Yes | Take Profit |
| comment | string | No | Optional comment for trade |
| expiration | int64 | No | Expiration time (if any) |
| digits | int | No | Symbol precision override. If omitted, symbol digits are used |
| reason | int | No | Trade source reason. Defaults to TR_REASON_DEALER |
| taxes | double | No | Optional taxes value |
| magic | int | No | Optional magic number |
| activation | int | No | Optional activation source |
| gw_source | string | No | Optional external gateway source/provider |
| gw_uuid | string | No | Optional external gateway UUID |
Request Example¶
{
"order": 123456,
"login": 1011,
"cmd": 0,
"volume": 100,
"open_time": 1670000000,
"close_time": 1670003600,
"open_price": 1.2345,
"close_price": 1.2360,
"profit": 150.0,
"commission": -5.0,
"storage": -1.5,
"symbol": "EURUSD",
"sl": 1.2300,
"tp": 1.2400,
"comment": "Manual correction"
}
Response Example¶
{
"imported": true,
"order": 123456,
"state": 3,
"login": 1011,
"symbol": "EURUSD",
"cmd": 0,
"volume": 100,
"close_time": 1670003600
}
Error Responses¶
Account Not Found¶
{
"error": "ACCOUNT_NOT_AVAILABLE",
"message": "Account not available"
}
Validation Error¶
{
"error": "INVALID_DATA",
"message": "volume is required"
}
Trade Already Exists¶
{
"error": "RET_TRADE_EXIST",
"message": "Trade already exists"
}
Invalid Trade Semantics¶
{
"error": "RET_TRADE_BAD_CLOSE_TIME",
"message": "Bad close time"
}
Notes¶
ordermust be unique. Duplicate imports are rejected.close_timemust be greater than or equal toopen_time.- The method supports only closed
OP_BUYandOP_SELLhistory snapshots. - The method updates account balance recalculation after successful import.