Orders#
Submit an Order For Account#
- BrokerClient.submit_order_for_account(account_id: UUID | str, order_data: OrderRequest) Order | Dict[str, Any]#
Creates an order to buy or sell an asset for an account.
- Parameters:
account_id (Union[UUID, str]) – The account the order will be created for.
order_data (alpaca.broker.requests.OrderRequest) – The request data for creating a new order.
- Returns:
The resulting submitted order.
- Return type:
alpaca.broker.models.OrderOrder
Get All Orders For Account#
- BrokerClient.get_orders_for_account(account_id: UUID | str, filter: GetOrdersRequest | None = None) List[Order] | Dict[str, Any]#
Returns all orders for an account. Orders can be filtered by parameters.
- Parameters:
account_id (Union[UUID, str]) – The account to get the orders for.
filter (Optional[GetOrdersRequest]) – The parameters to filter the orders with.
- Returns:
The queried orders.
- Return type:
List[alpaca.broker.models.Order]
Get an Order For Account By Id#
- BrokerClient.get_order_for_account_by_id(account_id: UUID | str, order_id: UUID | str, filter: GetOrderByIdRequest | None = None) Order | Dict[str, Any]#
Returns a specific order by its order id.
- Parameters:
account_id (Union[UUID, str]) – The account to get the order for.
order_id (Union[UUID, str]) – The unique uuid identifier for the order.
filter (Optional[GetOrderByIdRequest]) – The parameters for the query.
- Returns:
The order that was queried.
- Return type:
alpaca.broker.models.Order
Get an Order For Account By Client Id#
- BrokerClient.get_order_for_account_by_client_id(account_id: UUID | str, client_id: str) Order | Dict[str, Any]#
Returns a specific order by its client order id.
- Parameters:
account_id (Union[UUID, str]) – The account to get the order for.
client_id (str) – The client order identifier for the order.
- Returns:
The queried order.
- Return type:
alpaca.broker.models.Order
Replace an Order For Account By Id#
- BrokerClient.replace_order_for_account_by_id(account_id: UUID | str, order_id: UUID | str, order_data: ReplaceOrderRequest | None = None) Order | Dict[str, Any]#
Updates an order with new parameters.
- Parameters:
account_id (Union[UUID, str]) – The account to replace the order for.
order_id (Union[UUID, str]) – The unique uuid identifier for the order being replaced.
order_data (Optional[ReplaceOrderRequest]) – The parameters we wish to update.
- Returns:
The updated order.
- Return type:
alpaca.broker.models.Order
Cancel All Orders For Account#
- BrokerClient.cancel_orders_for_account(account_id: UUID | str) List[CancelOrderResponse] | Dict[str, Any]#
Cancels all orders.
- Parameters:
account_id (Union[UUID, str]) – The account to cancel the orders for.
- Returns:
The list of HTTP statuses for each order attempted to be cancelled.
- Return type:
List[CancelOrderResponse]
Cancel an Order For Account By Id#
- BrokerClient.cancel_order_for_account_by_id(account_id: UUID | str, order_id: UUID | str) None#
Cancels a specific order by its order id.
- Parameters:
account_id (Union[UUID, str]) – The account to cancel the order for.
order_id (Union[UUID, str]) – The unique uuid identifier of the order being cancelled.