# Close position (TRADE)

## API Description

Closes an open position, fully or partially, at market.

## HTTP Request

```http
DELETE /v1/position
```

## Request Weight

1 (1 against `ORDERS`)

## Request Parameters

| Name | Type | Mandatory | Description |
| - | - | - | - |
| `login` | LONG | YES | |
| `positionId` | LONG | YES | |
| `volume` | DECIMAL | NO | Lots to close. Omit to close the whole position. Must be greater than `0` (`-4003`), ≤ the position's current volume (`-4024`) and, for a partial close, a multiple of `volumeStep` (`-4007`). A full close is never refused for its step. |
| `newClientOrderId` | STRING | NO | **Idempotency key.** Strongly recommended — a retried close without one can close the position twice if it was reopened in between. |
| `newOrderRespType` | ENUM | NO | `ACK` (default) or `RESULT`. |
| `recvWindow`, `timestamp`, `signature` | | | |

A partial close leaves the position open with the remaining volume and the **same** `positionId`.

## Response Example

**Response** (`RESULT`)

```json
{
  "login": 100123,
  "positionId": 44412345,
  "clientOrderId": "bot-close-1",
  "symbol": "XAUUSD",
  "side": "SELL",
  "volume": "0.10",
  "status": "FILLED",
  "orderId": 44412399,
  "dealId": 55512400,
  "price": "2331.60",
  "executedVolume": "0.10",
  "mt5RetCode": 10009,
  "transactTime": 1789012600410
}
```

`side` on the response is the side of the **closing deal** — the opposite of the position's side.
`volume` is the volume you asked to close; `executedVolume` and `price` (volume-weighted) are what
filled. With `ACK`, or while the close is unconfirmed, `orderId`, `dealId`, `price` and
`executedVolume` are absent.

The realised profit of the close is **not** on this response — the trade server books it on the
deal. Read it from the `DEAL` event's `rp` field or from
[`GET /v1/userTrades`](/account/account-trade-list.md).

`-2023` if the position does not exist or belongs to another login. `-5006` if it was already closed
(for example by its own stop loss) between your read and your close.
