# Close Position

> Creates a market order to close an existing position (partial or full closing supported)

Source: /trader/api/trading/close-position

## `PATCH /accounts/{account_id}/positions/{position_id}`

**Close Position**

Creates a market order to close an existing position (partial or full closing supported)

Tags: `Trading`

#### Path parameters

- `account_id` (string) (required) — The account ID where position to close belongs
- `position_id` (string) (required) — Position ID to close

#### Query parameters

- `qty` (number) (required) — Quantity to close (in lots). Use position's full qty to close completely.


### Responses

#### `201` — Position close order created successfully

**Content-Type:** `application/json`

- `order_id` (string) (required) — The created closing order identifier

#### `400` — Bad request (missing or invalid fields)

**Content-Type:** `application/json`

- `error` (object) (required)
  - `type` (string) (required) — Error type code
  - `message` (string) (required) — Human-readable error message
  - `field` (string) — Field name if error is field-specific

#### `401` — Unauthorized (invalid or missing JWT token)

**Content-Type:** `application/json`



#### `403` — Forbidden (position access denied)

**Content-Type:** `application/json`



#### `404` — Position not found

**Content-Type:** `application/json`



#### `422` — Unprocessable entity (business rule violation)

**Content-Type:** `application/json`



#### `500` — Internal server error

**Content-Type:** `application/json`



