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

Get All Positions#

TradingClient.get_all_positions() Union[List[Position], Dict[str, Any]]#

Gets all the current open positions.


List of open positions.

Return type:


Get Open Position#

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

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


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


Open position of the asset.

Return type:


Close All Positions#

TradingClient.close_all_positions(cancel_orders: Optional[bool] = None) Union[List[ClosePositionResponse], Dict[str, Any]]#

Liquidates all positions for an account.

Places an order for each open position to liquidate.


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


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

order id.

Return type:


Close A Position#

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

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!

  • 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.


The order that was placed to close the position.

Return type:


Exercise An Option Contract#

TradingClient.exercise_options_position(symbol_or_contract_id: Union[UUID, str]) None#

This endpoint enables users to exercise a held option contract, converting it into the underlying asset based on the specified terms. All available held shares of this option contract will be exercised. By default, Alpaca will automatically exercise in-the-money (ITM) contracts at expiry. Exercise requests will be processed immediately once received. Exercise requests submitted outside market hours will be rejected. To cancel an exercise request or to submit a Do-not-exercise (DNE) instruction, please contact our support team.


symbol_or_contract_id (Union[UUID, str]) – Option contract symbol or ID.