Skip to content

ModifyOpenTrade

Modifies SL and/or TP for an existing open market position.

PUT

https://{some_domain}/trade/modify/open

Compatibility note:

  • PUT /trade/modify is kept as a backward-compatible alias for this method

Authorization

All requests must include a JWT token:

Authorization: <JWT_TOKEN>

Copy-follower manual trading policy

For authenticated user/customer requests, an enabled copy follower's manual_trading_mode is enforced after account/order ownership checks:

  • 0 rejects all manual trade writes with HTTP 403, COPY_MANUAL_TRADING_DISABLED (Manual trading is disabled for this copy follower).
  • 1 permits writes to non-copied orders and rejects changes to copied orders with HTTP 403, COPY_COPIED_ORDER_MANUAL_FORBIDDEN (Manual changes to copied orders are disabled for this copy follower).
  • 2 permits manual writes to copied and non-copied orders.
HTTP Error Message
403 COPY_MANUAL_TRADING_DISABLED Manual trading is disabled for this copy follower
403 COPY_COPIED_ORDER_MANUAL_FORBIDDEN Manual changes to copied orders are disabled for this copy follower

This applies to opens, modifications, closes, pending-order changes, and group operations. A group operation that matches a protected copied order is rejected before any order is changed. Staff and internal requests bypass this follower policy.

Request

Content-Type: application/json

Body Parameters

Field Type Required Description
order int Yes Trade order ID
sl double No New Stop Loss
tp double No New Take Profit

At least one of sl or tp must be provided.

Both levels must be finite and non-negative. Zero removes the corresponding level; an omitted level keeps its existing value.

This method works only for open market trades with:

  • cmd = OP_BUY
  • cmd = OP_SELL

Response

Success (200)

The response acknowledges synchronous admission under the cached-order lock, not completion of the runtime calculation. Admission rejects orders that are already closing, closed, or have another update/partial close in progress.

Modification and SL/TP closing share the same admission lock. If modification wins, Core checks protection using the modified levels, including when the quote has already crossed a level. If protection closing wins, modification is rejected with HTTP 400 and RET_TRADE_INCORRECT_STATE. An accepted modification does not guarantee that the position remains open: its resulting event may be CLOSED. A delayed modification cannot reopen a finalized position or restore floating profit/margin after its result has been realized into balance.

Field Type Description
accepted boolean true when admission succeeds
order int Target order ID
state int Acknowledged request state, 14
login int Account login
symbol string Trading instrument
cmd int Market command, 0 (BUY) or 1 (SELL)
volume int Position volume in minimal lots
{
  "accepted": true,
  "order": 123456,
  "state": 14,
  "login": 1001,
  "symbol": "EURUSD",
  "cmd": 0,
  "volume": 100
}

state = 14 corresponds to TS_OPEN_UPDATE_REQUEST.

Error Responses

Code Error Description
400 INVALID_DATA Validation failed or no mutable fields were provided
401 PERMISSION_DENIED Access denied
403 MODIFY_TRADE_ERROR Order does not belong to the authenticated user
400/409 RET_TRADE_INCORRECT_CMD The target order is not an open market position
400 RET_TRADE_INCORRECT_STATE Closing/finalized order or a competing in-flight request won admission
4xx/5xx RET_* Validation/runtime error returned by trade checks
503 LICENSE_NOT_ACTIVE A v2 runtime lease is required before this risk-increasing action is admitted

Errors contain error (string code) and message (string description), with no accepted: true acknowledgment. For example:

{
  "error": "RET_TRADE_INCORRECT_STATE",
  "message": "Unknown error"
}

The message is human-readable and must not be used as a stable error identifier.