Skip to content

Trading Sync completion and response fields

This contract applies to MngOpenTradeSync, MngCloseTradeSync, MngUpdateOpenTradeSync, MngUpdateTradeSync, MngUpdateCloseTradeSync and MngUpdatePendingTradeSync over TCP. Each command page documents its request fields and access requirements.

Completion semantics

TCP creates a request-local completion latch before running the authenticated handler. The trade operation retains that latch through its internal operation context. Only the applied snapshot or explicit failure of that operation completes it. No order-wide cached event, unrelated request or ordinary valuation update can satisfy it. A result that arrives before response registration is retained.

Normal trade-event broadcasts still use their existing recipient access checks. Sync completion neither subscribes a session to events nor broadens command permissions. The response uses the existing trade-event data schema; internal correlation metadata is not exposed as new public fields.

Success means the operation's trade snapshot was applied in the authoritative trade manager. It is not a guarantee that every account snapshot or asynchronous persistence/reporting consumer has caught up at that instant. Use financial reconciliation when those relationships are required.

For partial close the response contains the original ticket with reduced volume. The child history ticket is separate. Known execution failures return their mapped error, rather than timing out.

The default deadline is five seconds from TCP worker dispatch. Delivery uses the completion sweep, which runs every 500 ms, so a recorded result may be delivered on the next sweep. A result completing after the deadline is reported as a timeout. Disconnect or server shutdown discards the waiter, not the admitted trade operation.

Response envelope

Field Type Meaning
extID string Original TCP request identifier
status integer 200 for success; mapped command/execution error status; 504 for missing completion
data object Applied trade snapshot on success, or error information

Success data fields

All fields below are emitted by the trade response formatter. No event envelope or event type is included in the command response.

Field Type Meaning
order integer Original trade ticket
login integer Account login
cmd integer Trade command
state integer Applied trade state
symbol string Instrument name
reason integer Trade reason
cashier_transaction_id integer Cashier transaction identifier, or zero
volume integer Position/history volume in platform minimal-volume units
parent_order integer Parent ticket, or zero
closed_volume integer Recorded closed volume
partial_close_volume integer Partial-close request volume; normally zero after settlement
open_time integer Open timestamp in Unix seconds
close_time integer Close timestamp in Unix seconds; zero for an open position
open_price number Entry price
close_price number Closing or valuation price
sl number Stop Loss; zero when unset
tp number Take Profit; zero when unset
profit number Applied profit
commission number Signed commission
storage number Signed storage/swap
comment string Trade comment
digits integer Instrument precision
expiration integer Expiration timestamp in Unix seconds; zero when unset
update_time integer Trade update timestamp in Unix seconds

Complete success examples are provided on each command page.

Execution error

Deferred execution failures contain error, message, kind and order. error is the mapped runtime return-code name; message is its human-readable description; kind is trade; order identifies the affected ticket. Status is mapped from the runtime return code. For example, a generic execution failure is:

{
  "extID": "sync-1",
  "status": 500,
  "data": {
    "error": "RET_ERROR",
    "message": "Common error",
    "kind": "trade",
    "order": 1001234
  }
}

Validation/access/admission failures occur before deferral and retain their command-specific error schema.

Timeout and safe retry

Timeout data contains error, kind and order; it does not include message:

{
  "extID": "sync-1",
  "status": 504,
  "data": {
    "error": "SYNC_TIMEOUT",
    "kind": "trade",
    "order": 1001234
  }
}

A timeout is an unknown outcome, not a rollback or cancellation. Inspect current trade state and operation traces before retrying. Repeating an open command can allocate a new ticket; Sync does not add idempotency to commands.