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) Order#

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

alpaca.trading.models.Order

Get Orders#

TradingClient.get_orders(filter: Optional[GetOrdersRequest] = None) List[Order]#

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

List[alpaca.trading.models.Order]

Get Order By Id#

TradingClient.get_order_by_id(order_id: Union[UUID, str], filter: Optional[GetOrderByIdRequest] = None) Order#

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

alpaca.trading.models.Order

Replace Order By Id#

TradingClient.replace_order_by_id(order_id: Union[UUID, str], order_data: Optional[ReplaceOrderRequest] = None) Order#

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

alpaca.trading.models.Order

Cancel All Orders#

TradingClient.cancel_orders() List[CancelOrderResponse]#

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

CancelOrderResponse