Skip to main content
POST
/
api
/
v1
/
trading
/
liquidate
Liquidate Positions
curl --request POST \
  --url https://api.example.com/api/v1/trading/liquidate \
  --header 'Content-Type: application/json' \
  --data '
{
  "position_id": "<string>",
  "symbol": "<string>"
}
'
{
  "status": "<string>",
  "data": {
    "count": 123,
    "positions": [
      {}
    ]
  }
}
Liquidate open positions either by position ID, symbol, or liquidate all open positions at once. Liquidation forcibly closes positions and updates their status to LIQUIDATED.
Liquidation is a destructive operation that immediately closes positions. Use with caution in production environments.

Endpoints

Liquidate Single Position

POST /api/v1/trading/liquidate Liquidate one open position by either position_id or symbol.

Liquidate All Positions

POST /api/v1/trading/liquidate_all Liquidate all open positions in a single operation.

Liquidate Single Position

Request Body

position_id
string
Unique identifier of the position to liquidate. Takes priority over symbol if both are provided.Format: pos-YYYYMMDDHHMMSS-sequenceExample: "pos-20260303120000-1"
symbol
string
Trading pair symbol. Liquidates the first open position matching this symbol.Example: "BTC/USDT"
Either position_id or symbol must be provided. If both are provided, position_id takes precedence.

Response

status
string
Response status: "success" or "error"
data
PositionRecord
Updated position details after liquidation

Error Responses

  • 400 Bad Request: Neither position_id nor symbol was provided
  • 404 Not Found: No open position found matching the criteria
  • 500 Internal Server Error: Failed to liquidate position

Example Request

Liquidate by Position ID
curl -X POST https://api.neuratrade.com/api/v1/trading/liquidate \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "position_id": "pos-20260303120000-1"
  }'
Liquidate by Symbol
curl -X POST https://api.neuratrade.com/api/v1/trading/liquidate \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "symbol": "BTC/USDT"
  }'

Example Response

200 Success
{
  "status": "success",
  "data": {
    "position_id": "pos-20260303120000-1",
    "order_id": "ord-20260303120000-1",
    "exchange": "binance",
    "symbol": "BTC/USDT",
    "side": "BUY",
    "size": "0.01",
    "entry_price": "50000.00",
    "status": "LIQUIDATED",
    "opened_at": "2026-03-03T12:00:00Z",
    "updated_at": "2026-03-03T12:10:00Z"
  }
}
404 Not Found
{
  "status": "error",
  "error": "open position not found"
}

Liquidate All Positions

Request

No request body required. All open positions will be liquidated.

Response

status
string
Response status: "success" or "error"
data
object
Container for liquidation results

Example Request

curl -X POST https://api.neuratrade.com/api/v1/trading/liquidate_all \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY"

Example Response

200 Success
{
  "status": "success",
  "data": {
    "count": 2,
    "positions": [
      {
        "position_id": "pos-20260303120000-1",
        "order_id": "ord-20260303120000-1",
        "exchange": "binance",
        "symbol": "BTC/USDT",
        "side": "BUY",
        "size": "0.01",
        "entry_price": "50000.00",
        "status": "LIQUIDATED",
        "opened_at": "2026-03-03T12:00:00Z",
        "updated_at": "2026-03-03T12:15:00Z"
      },
      {
        "position_id": "pos-20260303120000-2",
        "order_id": "ord-20260303120000-2",
        "exchange": "okx",
        "symbol": "ETH/USDT",
        "side": "SELL",
        "size": "0.5",
        "entry_price": "3000.00",
        "status": "LIQUIDATED",
        "opened_at": "2026-03-03T12:05:00Z",
        "updated_at": "2026-03-03T12:15:00Z"
      }
    ]
  }
}
200 No Open Positions
{
  "status": "success",
  "data": {
    "count": 0,
    "positions": []
  }
}

Liquidation Confirmation

When a position is liquidated:
  1. Position status is updated to LIQUIDATED
  2. Associated order status is updated to CLOSED
  3. Update timestamp is set to the liquidation time
  4. Position remains in database for historical tracking and auditing
Liquidation does NOT execute actual exchange orders. This endpoint only updates the internal position tracking state. For production use, integrate with exchange APIs to execute closing orders.

Build docs developers (and LLMs) love