Orders API

The orders API allows a user to monitor, place and cancel their orders with Alpaca. Each order has a unique identifier provided by the client. This client-side unique order ID will be automatically generated by the system if not provided by the client, and will be returned as part of the order object along with the rest of the fields described below. Once an order is placed, it can be queried using the client-side order ID to check the status. Updates on open orders at Alpaca will also be sent over the streaming interface, which is the recommended method of maintaining order state.

For details of orders, see Order page

[GET] Get a list of orders

GET/v1/orders
Retrieves a list of orders for the account, filtered by the supplied query parameters.

Parameters

Query Parameters

status
string
Order status to be queried. open, closed or all. Defaults to open.
limit
int
The maximum number of orders in response. Defaults to 50 and max is 500.
after
timestamp
The response will include only ones submitted after this timestamp (exclusive.)
until
timestamp
The response will include only ones submitted until this timestamp (exclusive.)
direction
string
The chronological order of response based on the submission time. asc or desc. Defaults to desc.

Response

An array of Order object

[POST] Request a new order

POST/v1/orders
Places a new order for the given account. An order request may be rejected if the account is not authorized for trading, or if the tradable balance is insufficient to fill the order.

Parameters

Body Parameters

symbol
stringRequired
symbol or asset ID to identify the asset to trade
qty
string<int>Required
number of shares to trade
side
stringRequired
buy or sell
type
stringRequired
market, limit, stop, or stop_limit
time_in_force
stringRequired
day, gtc, opg. See order page
limit_price
string<number>Required
required if type is limit or stop_limit
stop_price
string<number>Required
required if type is stop or stop_limit
client_order_id
string (<= 48 characters)
A unique identifier for the order. Automatically generated if not sent.

Response

The new Order object

Errors

403 Forbidden
Buying power or shares is not sufficient.
422 Unprocessable
Input parameters are not recognized.

[GET] Get an order

GET/v1/orders/{order_id}
Retrieves a single order for the given order_id.

Parameters

Path Parameters

order_id
string<uuid>
Order ID

Response

The requested Order object

Errors

404 Not found
Order is not found.

[GET] Get an order by client order id

GET/v1/orders:by_client_order_id
Retrieves a single order for the given client_order_id.

Response

The requested Order object

Errors

404 Not found
Order is not found.

[DELETE] Cancel an order

DELETE/v1/orders/{order_id}
Attempts to cancel an open order. If the order is no longer cancelable (example: status=order_filled), the server will respond with status 422, and reject the request.

Parameters

Path Parameters

order_id
string<uuid>
Order ID

Response

Errors

404 Not found
Order is not found.
422 Unprocessable
The order status is not cancelable.

Order Entity

Example

{
  "id": "904837e3-3b76-47ec-b432-046db621571b",
  "client_order_id": "904837e3-3b76-47ec-b432-046db621571b",
  "created_at": "2018-10-05T05:48:59Z",
  "updated_at": "2018-10-05T05:48:59Z",
  "submitted_at": "2018-10-05T05:48:59Z",
  "filled_at": "2018-10-05T05:48:59Z",
  "expired_at": "2018-10-05T05:48:59Z",
  "canceled_at": "2018-10-05T05:48:59Z",
  "failed_at": "2018-10-05T05:48:59Z",
  "asset_id": "904837e3-3b76-47ec-b432-046db621571b",
  "symbol": "AAPL",
  "exchange": "NASDAQ",
  "asset_class": "us_equity",
  "qty": "15",
  "filled_qty": "0",
  "type": "market",
  "side": "buy",
  "time_in_force": "day",
  "limit_price": "107.00",
  "stop_price": "106.00",
  "filled_avg_price": "106.00",
  "status": "accepted"
}

Properties

id
string<uuid>
order id
client_order_id
string
client unique order id
created_at
string<timestamp>
updated_at
string<timestamp> (Nullable)
submitted_at
string<timestamp> (Nullable)
filled_at
string<timestamp> (Nullable)
expired_at
string<timestamp> (Nullable)
canceled_at
string<timestamp> (Nullable)
asset_id
string<uuid>
asset ID
symbol
string
Asset symbol
exchange
string
Asset exchange
asset_class
string
Asset class
qty
string<number>
Ordered quantity
filled_qty
string<number>
Filled quantity
type
string<order_type>
Valid values: market, limit, stop, stop_limit
side
string<side>
Valid values: buy, sell
time_in_force
string<time_in_force>
limit_price
string<number> (Nullable)
Limit price
stop_price
string<number> (Nullable)
Stop price
status
string<order_status>