Orders#
The order endpoints allow you to create and manage orders made on your brokerage account.
Create a New Order#
- TradingClient.submit_order(order_data: OrderRequest) Union[Order, Dict[str, Any]] #
Creates an order to buy or sell an asset.
- Parameters:
order_data (alpaca.trading.requests.OrderRequest) – The request data for creating a new order.
- Returns:
The resulting submitted order.
- Return type:
Get Orders#
- TradingClient.get_orders(filter: Optional[GetOrdersRequest] = None) Union[List[Order], Dict[str, Any]] #
Returns all orders. Orders can be filtered by parameters.
- Parameters:
filter (Optional[GetOrdersRequest]) – The parameters to filter the orders with.
- Returns:
The queried orders.
- Return type:
Get Order By Id#
- TradingClient.get_order_by_id(order_id: Union[UUID, str], filter: Optional[GetOrderByIdRequest] = None) Union[Order, Dict[str, Any]] #
Returns a specific order by its order id.
- Parameters:
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:
Replace Order By Id#
- TradingClient.replace_order_by_id(order_id: Union[UUID, str], order_data: Optional[ReplaceOrderRequest] = None) Union[Order, Dict[str, Any]] #
Updates an order with new parameters.
- Parameters:
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:
Cancel All Orders#
- TradingClient.cancel_orders() Union[List[CancelOrderResponse], Dict[str, Any]] #
Cancels all orders.
- Returns:
The list of HTTP statuses for each order attempted to be cancelled.
- Return type:
List[CancelOrderResponse]
Cancel Order By Id#
- TradingClient.cancel_order_by_id(order_id: Union[UUID, str]) None #
Cancels a specific order by its order id.
- Parameters:
order_id (Union[UUID, str]) – The unique uuid identifier of the order being cancelled.
- Returns:
The HTTP response from the cancel request.
- Return type: