Skip to content

Close Trade

MngCloseTrade

Description: Allows a manager to close an existing market trade order. Supports full and partial close operations and optional close control parameters.

This method follows the common Trade Request Lifecycle. A successful response means the close request was accepted into runtime processing.

Request Parameters

Name Type Required Description
login int Yes Account login to which the trade belongs
order int Yes Order ID of the trade to close
volume int No Requested close volume. If omitted or equal to current position volume, the server performs a full close. If lower than current position volume, the server performs a partial close.
close_price double No Custom closing price
close_time int64 No Closing time
expiration int64 No Optional expiration time
comment string No Optional comment
__access object Yes Access object with manager session data

Request Example

{
  "login": 123456,
  "order": 1001234,
  "volume": 500,
  "close_price": 1.2050,
  "close_time": 1629987890,
  "expiration": 0,
  "comment": "partial close by manager",
  "__access": {
    "type": 2
  }
}

Response Parameters

Name Type Description
accepted bool Always true on successful acknowledgment
order int Order identifier being closed
state int Accepted request state. TS_CLOSE_REQUEST for full close, TS_PARTIAL_CLOSE_REQUEST for partial close.
login int Target account login
symbol string Trade symbol
cmd int Trade command
volume int Requested close volume

Response Example

{
  "accepted": true,
  "order": 1001234,
  "login": 123456,
  "symbol": "EURUSD",
  "cmd": 0,
  "volume": 500,
  "state": 19
}

Close Volume Semantics

MngCloseTrade uses the same command for full and partial close:

Request volume Runtime behavior
omitted Full close of the current remaining position volume
equal to current position volume Full close
lower than current position volume Partial close
greater than current position volume Rejected with bad volume error

For a partial close, the original position remains open with a reduced remaining volume. The server creates a separate closed history record with:

  • state = TS_CLOSED_PART
  • volume equal to the closed part
  • parent_order equal to the original position order

The original position keeps:

  • remaining volume
  • accumulated closed_volume
  • open state after runtime processing completes

Event Flow

Full close emits a close trade event for the original order.

Partial close emits:

  • update event for the original order
  • close trade event for the generated partial-close history record

Clients that need the partial-close history record should query closed/history trades by parent_order or by account history after receiving the update.