Close Trade Sync
MngCloseTradeSync¶
Description: Closes an existing trade and keeps the TCP request open until the matching close trade:event is broadcast by the trading runtime.
MngCloseTradeSync is useful for CRM, backoffice, dealing, and integration flows that need the final closed trade payload in the command response instead of receiving only an accepted close acknowledgment.
SEO¶
MngCloseTradeSync is the synchronous TCP close trade method for ScaleTrade manager API integrations. Use this endpoint when a CRM, dealer plugin, backoffice tool, or trading connector must close a trade and receive the resulting close trade event payload by order.
Request Parameters¶
| Name | Type | Required | Description |
|---|---|---|---|
| login | int | Yes | Account login to which the trade belongs |
| order | int | Yes | Trade order ID to close |
| volume | int | No | Volume to close for partial close |
| close_price | double | No | Optional requested close price |
| close_time | int64 | No | Optional requested close timestamp |
| expiration | int64 | No | Optional expiration value |
| comment | string | No | Optional close comment |
| __access | object | Yes | Manager/session access object |
Request Example¶
{
"command": "MngCloseTradeSync",
"extID": "close-sync-1",
"data": {
"login": 123456,
"order": 1001234,
"volume": 500,
"close_price": 1.205,
"__access": {
"type": 2
}
}
}
Runtime Flow¶
- Handler validates the same request fields as
MngCloseTrade. - Backend queues the close trade request.
- TCP stores a pending sync waiter by
order,extID, event type and active session. mainLoopprocesses the close request and emitstrade:event.- TCP matches
trade:event.data.orderand returns the matched eventdata.
Success Response¶
On success the response contains only the data object from the matching trade:event.
{
"extID": "close-sync-1",
"status": 200,
"data": {
"order": 1001234,
"login": 123456,
"symbol": "EURUSD",
"cmd": 0,
"state": 3,
"volume": 500,
"profit": 42.5
}
}
Event Matching¶
TCP waits for trade:event with type = EV_RECORD_CLOSE_TRADE and matching data.order.
Timeout¶
The default timeout is 5000 ms. If no matching trade event arrives before timeout, TCP returns status = 504 with SYNC_TIMEOUT.
Notes¶
- Full and partial close requests use the same sync flow.
- Use
MngCloseTradewhen an immediate accepted-command response is enough.