Import Open Trade
MngImportOpenTrade¶
Description: Imports an already open market position into the local trading runtime.
This method is intended for account migration, platform transition, or manual dealer-assisted transfer of open positions from another trading platform.
The imported position is created in state TS_OPEN_RESTORED.
Unlike MngOpenTrade, this method:
- does not validate available free margin before import
- allows explicitly provided
commissionandstorage - preserves the imported
open_priceandopen_time - is designed for restored external positions, not for opening a new trade at the current market
Access Control¶
Requires set_trades for manager/dealer sessions. The target account must also match the manager groups and brand scope loaded from the cached manager record. Token payload is used only for manager id and session type.
Endpoint¶
This method is routed internally as MngImportOpenTrade.
Request Parameters¶
| Name | Type | Required | Description |
|---|---|---|---|
| login | int | Yes | User login ID |
| cmd | int | Yes | Market command only: OP_BUY=0 or OP_SELL=1 |
| volume | int | Yes | Trade volume in minimal lots |
| symbol | string | Yes | Trading symbol |
| open_price | double | Yes | Imported open price |
| open_time | int64 | Yes | Imported open timestamp |
| order | int | No | Imported order identifier. If omitted, the server reserves a new order ID |
| sl | double | No | Imported Stop Loss |
| tp | double | No | Imported Take Profit |
| digits | int | No | Symbol precision override. If omitted, symbol digits are used |
| reason | int | No | Trade source reason. Defaults to TR_REASON_DEALER |
| commission | double | No | Imported commission value. Preserved as provided |
| storage | double | No | Imported swap/storage value. Preserved as provided |
| magic | int | No | Optional magic number |
| comment | string | No | Optional trade comment |
| gw_order | string | No | Optional external gateway order identifier |
| gw_source | string | No | Optional external gateway source/provider |
| gw_uuid | string | No | Optional external gateway UUID |
| last_swap_time | int64 | No | Optional imported last swap accrual time. If omitted, open_time is used |
| __access | object | Yes | Access object with type field |
Request Example¶
{
"login": 123456,
"cmd": 0,
"volume": 1000,
"symbol": "EURUSD",
"open_price": 1.08425,
"open_time": 1713206400,
"commission": -12.5,
"storage": -3.75,
"comment": "Imported from legacy platform",
"gw_source": "mt4",
"gw_uuid": "a7d6d7d4-5a8a-4cb5-9f73-b5c9e5f7d111",
"__access": {
"type": 2
}
}
Response Semantics¶
If the request is accepted:
- the payload passed validation
- account, symbol, group, and lot-step checks passed
- the position was accepted as an imported open trade
- account margin snapshot was updated immediately
- the imported trade was queued into runtime processing
The response should be treated as an acknowledgment object.
Response Parameters¶
| Name | Type | Description |
|---|---|---|
| imported | bool | Always true on successful acknowledgment |
| order | int | Imported or reserved order identifier |
| login | int | Target account login |
| symbol | string | Imported symbol |
| cmd | int | Imported market command |
| volume | int | Imported volume |
| state | int | Imported runtime state, TS_OPEN_RESTORED |
| commission | double | Imported commission value |
| storage | double | Imported storage/swap value |
Response Example¶
{
"imported": true,
"order": 1002456,
"state": 2,
"login": 123456,
"symbol": "EURUSD",
"cmd": 0,
"volume": 1000,
"commission": -12.5,
"storage": -3.75
}
Error Responses¶
Validation Error¶
{
"error": "INVALID_DATA",
"message": "open_time is required"
}
Incorrect Command¶
{
"error": "RET_TRADE_INCORRECT_CMD",
"message": "Order command is incorrect"
}
Incorrect Symbol or Account¶
{
"error": "RET_NOT_FOUND",
"message": "Record not found"
}
Duplicate Order¶
{
"error": "RET_TRADE_EXIST",
"message": "Trade exist"
}
Notes¶
- The method supports only open market positions.
- Pending orders are not supported by this import flow.
- The imported position is stored as
TS_OPEN_RESTORED. - The imported trade is created without free margin validation.
commissionandstorageare not recalculated if provided explicitly.- Current floating
profit,close_price,margin_rate, andmargin_initialare calculated by the server during import. - If
orderis omitted, the server allocates a new order ID.