---
updatedAt: 2026-03-26T12:27:31.000Z
agentTools:
  projectIndex: https://public-api.tradelocker.com/llms.txt
---

# Close a position

Place an order to close an existing position. Isn't guaranteed to close the positions, or close it immediately. Will attempt to place an IOC, then GTC closing order, so the execution might be delayed. If you want to fully close position set parameter `qty` to `0`, but if you want to partially close a position just set the `qty` parameter to the number of lots that you want to close. 

 NOTE: if you don't know what is the `positionId` value (you only have an `orderId` of the order that opened the position), you can use the `GET /trade/accounts/{accountId}/ordersHistory` route to get the list of all final orders and their IDs. Just match the `orderId` with the `positionId`.

# OpenAPI definition

```json
{
  "openapi": "3.0.0",
  "info": {
    "description": "Trading API",
    "version": "2.11.0",
    "title": "Trading API",
    "contact": {}
  },
  "tags": [
    {
      "name": "Trading",
      "description": "Creating, modifying and deleting orders."
    }
  ],
  "paths": {
    "/trade/positions/{positionId}": {
      "delete": {
        "tags": [
          "Trading"
        ],
        "summary": "Close a position",
        "description": "Place an order to close an existing position. Isn't guaranteed to close the positions, or close it immediately. Will attempt to place an IOC, then GTC closing order, so the execution might be delayed. If you want to fully close position set parameter `qty` to `0`, but if you want to partially close a position just set the `qty` parameter to the number of lots that you want to close. \n\n NOTE: if you don't know what is the `positionId` value (you only have an `orderId` of the order that opened the position), you can use the `GET /trade/accounts/{accountId}/ordersHistory` route to get the list of all final orders and their IDs. Just match the `orderId` with the `positionId`.",
        "operationId": "closePosition",
        "parameters": [
          {
            "name": "positionId",
            "in": "path",
            "description": "Position identifier.",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "accNum",
            "in": "header",
            "description": "Account number",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "strategyId",
            "in": "query",
            "description": "Strategy ID",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "developer-api-key",
            "in": "header",
            "description": "developer-api-key",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Close_Position"
              }
            }
          },
          "description": "Request body with parameters",
          "required": true
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "204": {
            "description": "No Content"
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden"
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ]
      }
    }
  },
  "servers": [
    {
      "url": "https://demo.tradelocker.com/backend-api"
    },
    {
      "url": "https://live.tradelocker.com/backend-api"
    }
  ],
  "components": {
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    },
    "schemas": {
      "SuccessResponse": {
        "type": "object",
        "required": [
          "s"
        ],
        "properties": {
          "s": {
            "type": "string",
            "example": "ok",
            "description": "Status will always be `ok`."
          }
        },
        "title": "SuccessResponse"
      },
      "Close_Position": {
        "type": "object",
        "properties": {
          "qty": {
            "type": "number"
          }
        },
        "title": "Close Position"
      }
    }
  }
}
```