orders: Get Orders

View source: R/Orders.R

ordersR Documentation

Get Orders

Description

The orders API allows a user to monitor, place and cancel their orders with Alpaca. Times are returned as yyyy-mm-dd hh-mm-ss POSIXct, quantity and price as numeric, and all others as a string. See Orders GETfor more details.

Usage

orders(
  symbol_id = NULL,
  status = "open",
  limit = NULL,
  after = NULL,
  until = NULL,
  direction = "desc",
  client_order_id = NULL,
  nested = T,
  live = get_live()
)

Arguments

symbol_id

(character) Specify symbol, order ID, or client_order_id (must set client_order_id = TRUE).

status

(character) Order status to be queried. open, closed or all. Defaults to open as a string.

limit

(integer) The maximum number of orders in response. Defaults to 50 and max is 500.

after

(Date/character) Date in YYYY-MM-DD (ISO8601 Format) The response will include only orders submitted after this date exclusive as a timestamp object.

until

(Date/character) Date in YYYY-MM-DD (ISO8601 Format) The response will include only orders submitted before this date exclusive as a timestamp object.

direction

(character) The chronological order of response based on the submission time. 'asc' or 'desc'. Defaults to desc.

client_order_id

(logical) Whether symbol_id is a client_order_id, defaults to NULL (FALSE)

nested

(logical) If true, the result will roll up multi-leg orders under the legs field of primary order. Default TRUE.

live

(logical) TRUE / FALSE if you are connecting to a live account. Default to FALSE, so it will use the paper url if nothing was provided.

Value

Order (tibble) Order object or Array of Order Objects with the following information:

  • id(character) order id

  • client_order_id(character) client unique order id

  • created_at(POSIXct) nullable When the order was created

  • updated_at(POSIXct) nullable When the order was updated

  • submitted_at(POSIXct) nullable When the order was submitted

  • filled_at(POSIXct) nullable When the order was filled

  • expired_at(POSIXct) nullable When the order was expired

  • canceled_at(POSIXct) nullable When the order was canceled

  • failed_at(POSIXct) nullable When the order failed

  • replaced_at(POSIXct) nullable When the order was replaced

  • replaced_by(character) id of replacement order

  • replaces(character) id of the replaced order

  • asset_id(character) asset ID

  • symbol(character) Asset symbol

  • exchange(character) Asset exchange

  • asset_class(character) Asset class

  • qty(integer) Ordered quantity

  • filled_qty(integer) Filled quantity

  • filled_avg_price(numeric) Filled average price

  • order_class(character)

  • order_type(character)

  • type(character) Valid values: market, limit, stop, stop_limit

  • side(character) Valid values: buy, sell

  • time_in_force(character) time in force

  • limit_price(numeric) Limit price

  • stop_price(numeric) Stop price

  • status(character) Status of the order

  • extended_hours(logical) If true, eligible for execution outside regular trading hours.

  • legs(character) When querying non-simple order_class orders in a nested style, an array of Order entities associated with this order. Otherwise, null.

See Also

Other Orders: order_submit()

Examples

orders(live = FALSE)
orders(status = "all")
# For a specific symbol:
orders("AAPL", status = "all")

jagg19/AlpacaforR documentation built on July 3, 2023, 12:14 p.m.