Skip to content
Start Trading

Close Positions

client.V1.Positions.ClosePositions(ctx, accountID, body) (*V1PositionClosePositionsResponse, error)
DELETE/v1/accounts/{account_id}/positions

Delete all positions within an account.

Closes all positions for the specified trading account.

ParametersExpand Collapse
accountID int64
body V1PositionClosePositionsParams
CancelOrders param.Field[bool]Optional

Whether to cancel existing open orders for the position before submitting closing orders.

ReturnsExpand Collapse
type V1PositionClosePositionsResponse struct{…}
ID string

Engine-assigned unique identifier for this order (UUID).

AccountID int64

Account placing the order

formatint64
ClientOrderID string

Client-provided identifier echoed back.

CreatedAt Time

Timestamp when order was created (UTC)

formatdate-time
FilledQuantity string

Cumulative filled quantity

InstrumentID string

Instrument identifier for the traded instrument.

formatuuid
InstrumentType SecurityType

Type of security

One of the following:
const SecurityTypeCommonStock SecurityType = "COMMON_STOCK"
const SecurityTypeOption SecurityType = "OPTION"
const SecurityTypeCash SecurityType = "CASH"
LeavesQuantity string

Remaining unfilled quantity

OrderType OrderType

Type of order (MARKET, LIMIT, etc.)

One of the following:
const OrderTypeMarket OrderType = "MARKET"
const OrderTypeLimit OrderType = "LIMIT"
const OrderTypeStop OrderType = "STOP"
const OrderTypeStopLimit OrderType = "STOP_LIMIT"
const OrderTypeTrailingStop OrderType = "TRAILING_STOP"
const OrderTypeTrailingStopLimit OrderType = "TRAILING_STOP_LIMIT"
const OrderTypeOther OrderType = "OTHER"
Quantity string

Total order quantity

Side Side

Side of the order (BUY, SELL, SELL_SHORT)

One of the following:
const SideBuy Side = "BUY"
const SideSell Side = "SELL"
const SideSellShort Side = "SELL_SHORT"
const SideOther Side = "OTHER"

Current status of the order

One of the following:
const OrderStatusPendingNew OrderStatus = "PENDING_NEW"
const OrderStatusNew OrderStatus = "NEW"
const OrderStatusPartiallyFilled OrderStatus = "PARTIALLY_FILLED"
const OrderStatusFilled OrderStatus = "FILLED"
const OrderStatusCanceled OrderStatus = "CANCELED"
const OrderStatusRejected OrderStatus = "REJECTED"
const OrderStatusExpired OrderStatus = "EXPIRED"
const OrderStatusPendingCancel OrderStatus = "PENDING_CANCEL"
const OrderStatusPendingReplace OrderStatus = "PENDING_REPLACE"
const OrderStatusReplaced OrderStatus = "REPLACED"
const OrderStatusDoneForDay OrderStatus = "DONE_FOR_DAY"
const OrderStatusStopped OrderStatus = "STOPPED"
const OrderStatusSuspended OrderStatus = "SUSPENDED"
const OrderStatusCalculated OrderStatus = "CALCULATED"
const OrderStatusOther OrderStatus = "OTHER"
Symbol string

Trading symbol

TimeInForce TimeInForce

Time in force instruction

One of the following:
const TimeInForceDay TimeInForce = "DAY"
const TimeInForceGoodTillCancel TimeInForce = "GOOD_TILL_CANCEL"
const TimeInForceImmediateOrCancel TimeInForce = "IMMEDIATE_OR_CANCEL"
const TimeInForceFillOrKill TimeInForce = "FILL_OR_KILL"
const TimeInForceGoodTillDate TimeInForce = "GOOD_TILL_DATE"
const TimeInForceAtTheOpening TimeInForce = "AT_THE_OPENING"
const TimeInForceAtTheClose TimeInForce = "AT_THE_CLOSE"
const TimeInForceGoodTillCrossing TimeInForce = "GOOD_TILL_CROSSING"
const TimeInForceGoodThroughCrossing TimeInForce = "GOOD_THROUGH_CROSSING"
const TimeInForceAtCrossing TimeInForce = "AT_CROSSING"
const TimeInForceOther TimeInForce = "OTHER"
UpdatedAt Time

Timestamp of the most recent update (UTC)

formatdate-time
Venue string

MIC code of the venue where the order is routed

AverageFillPrice stringOptional

Average fill price across all executions When a null/undefined value is observed, it indicates that there is no available data.

Details []stringOptional

Contains execution, rejection or cancellation details, if any

ExpiresAt TimeOptional

Timestamp when the order will expire (UTC). Present when time_in_force is GOOD_TILL_DATE. When a null/undefined value is observed, it indicates it does not apply.

formatdate-time
ExtendedHours boolOptional

Whether the order is eligible for extended-hours trading.

LimitOffset stringOptional

Limit offset for trailing stop-limit orders (signed) When a null/undefined value is observed, it indicates it does not apply.

LimitPrice stringOptional

Limit price (for LIMIT and STOP_LIMIT orders) When a null/undefined value is observed, it indicates it does not apply.

QueueState QueueStateOptional

Parent order queue state, present when the order is awaiting release or released. When a null/undefined value is observed, it indicates it does not apply.

One of the following:
const QueueStateAwaitingRelease QueueState = "AWAITING_RELEASE"
const QueueStateReleased QueueState = "RELEASED"
ReleasesAt TimeOptional

Scheduled release time for orders awaiting release. When a null/undefined value is observed, it indicates it does not apply.

formatdate-time
StopPrice stringOptional

Stop price (for STOP and STOP_LIMIT orders) When a null/undefined value is observed, it indicates it does not apply.

TrailingLimitPx stringOptional

Current trailing limit price computed by the trailing strategy When a null/undefined value is observed, it indicates it does not apply.

TrailingOffset stringOptional

Trailing offset amount for trailing orders When a null/undefined value is observed, it indicates it does not apply.

TrailingOffsetType TrailingOffsetTypeOptional

Trailing offset type for trailing orders When a null/undefined value is observed, it indicates it does not apply.

One of the following:
const TrailingOffsetTypePrice TrailingOffsetType = "PRICE"
const TrailingOffsetTypeBps TrailingOffsetType = "BPS"
TrailingStopPx stringOptional

Current trailing stop price computed by the trailing strategy When a null/undefined value is observed, it indicates it does not apply.

TrailingWatermarkPx stringOptional

Trailing watermark price for trailing orders When a null/undefined value is observed, it indicates it does not apply.

TrailingWatermarkTs TimeOptional

Trailing watermark timestamp for trailing orders When a null/undefined value is observed, it indicates it does not apply.

formatdate-time
UnderlyingInstrumentID stringOptional

Instrument ID of the option’s underlying instrument. Populated only for options orders. A null means one of two things: the order is not an option, so the field does not apply; or the order is an option whose underlier has not yet been resolved. When a null/undefined value is observed, it indicates it does not apply.

formatuuid

Close Positions

package main

import (
  "context"
  "fmt"

  "github.com/clear-street/clear-street-go"
  "github.com/clear-street/clear-street-go/option"
)

func main() {
  client := clearstreet.NewClient(
    option.WithAPIKey("My API Key"),
  )
  response, err := client.V1.Positions.ClosePositions(
    context.TODO(),
    0,
    clearstreet.V1PositionClosePositionsParams{

    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response)
}
{
  "data": [
    {
      "account_id": 19816,
      "average_fill_price": null,
      "client_order_id": "close-positions-20251003-001",
      "created_at": "2025-10-03T14:01:15.000000000Z",
      "filled_quantity": "0",
      "id": "019c0b57-0850-7b0b-8a2c-5ee3fb5a5876",
      "instrument_id": "c3c4c5c6-d3d4-e3e4-f3f4-f5f6f7f8f9fa",
      "instrument_type": "COMMON_STOCK",
      "leaves_quantity": "25",
      "limit_price": null,
      "order_type": "MARKET",
      "quantity": "25",
      "side": "SELL",
      "status": "PENDING_NEW",
      "stop_price": null,
      "symbol": "GOOG",
      "time_in_force": "DAY",
      "updated_at": "2025-10-03T14:01:15.000000000Z",
      "venue": "XNMS"
    }
  ],
  "error": null,
  "metadata": {
    "request_id": "3f4a5b6c-7d8e-9f0a-1b2c-3d4e5f6a7b8c"
  }
}
{
  "error": {
    "code": 400,
    "message": "Failed to parse the request body as JSON: expected `:` at line 2 column 19"
  },
  "metadata": {
    "request_id": "93a7c482-b246-4e15-9618-bcbe0906b815"
  }
}
{
  "error": {
    "code": 403,
    "message": "The caller does not have permission to execute the specified operation"
  },
  "metadata": {
    "request_id": "5518f0c6-58ff-4b4a-81a5-701556d41206"
  }
}
Returns Examples
{
  "data": [
    {
      "account_id": 19816,
      "average_fill_price": null,
      "client_order_id": "close-positions-20251003-001",
      "created_at": "2025-10-03T14:01:15.000000000Z",
      "filled_quantity": "0",
      "id": "019c0b57-0850-7b0b-8a2c-5ee3fb5a5876",
      "instrument_id": "c3c4c5c6-d3d4-e3e4-f3f4-f5f6f7f8f9fa",
      "instrument_type": "COMMON_STOCK",
      "leaves_quantity": "25",
      "limit_price": null,
      "order_type": "MARKET",
      "quantity": "25",
      "side": "SELL",
      "status": "PENDING_NEW",
      "stop_price": null,
      "symbol": "GOOG",
      "time_in_force": "DAY",
      "updated_at": "2025-10-03T14:01:15.000000000Z",
      "venue": "XNMS"
    }
  ],
  "error": null,
  "metadata": {
    "request_id": "3f4a5b6c-7d8e-9f0a-1b2c-3d4e5f6a7b8c"
  }
}
{
  "error": {
    "code": 400,
    "message": "Failed to parse the request body as JSON: expected `:` at line 2 column 19"
  },
  "metadata": {
    "request_id": "93a7c482-b246-4e15-9618-bcbe0906b815"
  }
}
{
  "error": {
    "code": 403,
    "message": "The caller does not have permission to execute the specified operation"
  },
  "metadata": {
    "request_id": "5518f0c6-58ff-4b4a-81a5-701556d41206"
  }
}