Positions#

Get All Open Positions For Account#

BrokerClient.get_all_positions_for_account(account_id: Union[UUID, str]) Union[List[Position], Dict[str, Any]]#

Gets all the current positions for an account.

Parameters:

account_id (Union[UUID, str]) – The ID of the Account to get the open positions for.

Returns:

List of open positions from the account.

Return type:

List[Position]

Get A Open Position For Account#

BrokerClient.get_open_position_for_account(account_id: Union[UUID, str], 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.

Parameters:
  • account_id (Union[UUID, str]) – The ID of the Account to get the open position for.

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

Returns:

Open position of the asset from the account.

Return type:

Position

Close All Positions For Account#

BrokerClient.close_all_positions_for_account(account_id: Union[UUID, str], 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.

Parameters:
  • account_id (Union[UUID, str]) – The ID of the Account to close the positions for.

  • cancel_orders (Optional[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 For Account#

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

Liquidates the position for an account for a single asset.

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

Parameters:
  • account_id (Union[UUID, str]) – The ID of the Account to close the position for.

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

  • close_options – The various close position request parameters.

Returns:

The order that was placed to close the position.

Return type:

alpaca.broker.models.Order