v1

latestOpenAPI 3.0.02026-07-26166415635.8 KB
Trading

Close All Positions for an Account

Closes (liquidates) all of the account's open long and short positions. A response will be provided for each order that is attempted to be cancelled. If an order is no longer cancelable, the server will respond with status 500 and reject the request.

delete/v1/trading/accounts/{account_id}/positions

Query parameters

cancel_ordersboolean

If true is specified, cancel all open orders before liquidating all positions.

Response

HTTP 207 Multi-Status with body; an array of objects that include the order id and http status code for each status request.

statusinteger required

Http status code for the attempt to close this position

symbolstring required

Symbol name of the asset

Example response

[
  {
    "body": {
      "asset_id": "61e69015-8549-4bfd-b9c3-01e75843f47d",
      "cancel_requested_at": "2021-03-16T18:38:01.942282Z",
      "canceled_at": "2021-03-16T18:38:01.942282Z",
      "client_order_id": "61e69015-8549-4bfd-b9c3-01e75843f47d",
      "commission": "3.14",
      "commission_bps": "10",
      "commission_type": "qty",
      "created_at": "2021-03-16T18:38:01.942282Z",
      "expired_at": "2021-03-16T18:38:01.942282Z",
      "extended_hours": true,
      "failed_at": "2021-03-16T18:38:01.942282Z",
      "filled_at": "2021-03-16T18:38:01.942282Z",
      "filled_avg_price": "4.2",
      "filled_qty": "4.2",
      "hwm": "3.14",
      "id": "61e69015-8549-4bfd-b9c3-01e75843f47d",
      "legs": [
        {
          "asset_id": "61e69015-8549-4bfd-b9c3-01e75843f47d",
          "canceled_at": "2021-03-16T18:38:01.942282Z",
          "client_order_id": "61e69015-8549-4bfd-b9c3-01e75843f47d",
          "commission": "3.14",
          "commission_bps": "10",
          "commission_type": "qty",
          "created_at": "2021-03-16T18:38:01.942282Z",
          "expired_at": "2021-03-16T18:38:01.942282Z",
          "extended_hours": true,
          "failed_at": "2021-03-16T18:38:01.942282Z",
          "filled_at": "2021-03-16T18:38:01.942282Z",
          "filled_avg_price": "4.2",
          "filled_qty": "4.2",
          "hwm": "3.14",
          "id": "61e69015-8549-4bfd-b9c3-01e75843f47d",
          "limit_price": "3.14",
          "notional": "4.2",
          "order_type": "market",
          "position_intent": "buy_to_open",
          "qty": "4.2",
          "replaced_at": "2021-03-16T18:38:01.942282Z",
          "replaced_by": "61e69015-8549-4bfd-b9c3-01e75843f47d",
          "replaces": "61e69015-8549-4bfd-b9c3-01e75843f47d",
          "side": "buy",
          "status": "filled",
          "stop_price": "3.14",
          "submitted_at": "2021-03-16T18:38:01.942282Z",
          "symbol": "AALP",
          "time_in_force": "gtc",
          "trail_percent": "5.0",
          "trail_price": "3.14",
          "type": "market",
          "updated_at": "2021-03-16T18:38:01.942282Z"
        }
      ],
      "limit_price": "3.14",
      "notional": "4.2",
      "order_type": "market",
      "position_intent": "buy_to_open",
      "qty": "4.2",
      "replaced_at": "2021-03-16T18:38:01.942282Z",
      "replaced_by": "61e69015-8549-4bfd-b9c3-01e75843f47d",
      "replaces": "61e69015-8549-4bfd-b9c3-01e75843f47d",
      "side": "buy",
      "status": "filled",
      "stop_price": "3.14",
      "submitted_at": "2021-03-16T18:38:01.942282Z",
      "symbol": "AALP",
      "time_in_force": "gtc",
      "trail_percent": "5.0",
      "trail_price": "3.14",
      "type": "market",
      "updated_at": "2021-03-16T18:38:01.942282Z"
    }
  }
]