Positions#

The position endpoints allow you to view and manage your open positions.

Get All Positions#

TradingClient.get_all_positions() List[Position]#

Gets all the current open positions.

Returns

List of open positions.

Return type

List[Position]

Get Open Position#

TradingClient.get_open_position(symbol_or_asset_id: Union[UUID, str]) Position#

Gets the open position for an account for a single asset. Throws an APIError if the position does not exist.

Parameters

symbol_or_asset_id (Union[UUID, str]) – The symbol name of asset id of the position to get.

Returns

Open position of the asset.

Return type

Position

Close All Positions#

TradingClient.close_all_positions(cancel_orders: bool) List[ClosePositionResponse]#

Liquidates all positions for an account.

Places an order for each open position to liquidate.

Parameters

cancel_orders (bool) – If true is specified, cancel all open orders before liquidating all positions.

Returns

A list of responses from each closed position containing the status code and

order id.

Return type

List[ClosePositionResponse]

Close A Position#

TradingClient.close_position(symbol_or_asset_id: Union[UUID, str], close_options: Optional[ClosePositionRequest] = None) Order#

Liquidates the position for a single asset.

Places a single order to close the position for the asset.

This method will throw an error if the position does not exist!

Parameters
  • symbol_or_asset_id (Union[UUID, str]) – The symbol name of asset id of the position to close.

  • close_options – The various close position request parameters.

Returns

The order that was placed to close the position.

Return type

alpaca.trading.models.Order