Search for orders associated with a TD account over the previous 60 days. The result is a list of three objects:

  1. jsonlite formatted extract of all orders

  2. all entered orders with details

  3. a data frame of all executed orders with the executions

td_orderSearch(
  accountNumber,
  startDate = Sys.Date() - 30,
  endDate = Sys.Date(),
  maxResults = 50,
  orderStatus = "",
  accessToken = NULL
)

Arguments

accountNumber

The TD brokerage account number associated with the Access Token

startDate

Orders from a certain date with. Format yyyy-mm-dd. TD indicates there is a 60 day max, but this limit may not always apply

endDate

Filter orders that occurred before a certain date. Format yyyy-mm-dd

maxResults

the max results to return in the query

orderStatus

search by order status (ACCEPTED, FILLED, EXPIRED, CANCELED, REJECTED, etc)

accessToken

A valid Access Token must be set using td_auth_accessToken. The most recent Access Token will be used by default unless one is manually passed into the function.

Value

a list of three objects: a jsonlite formatted extract of all orders, all entered orders with details, a data frame of all executed orders with the executions

Examples

if (FALSE) {

# Get all orders run over the last 50 days (up to 500)
td_orderSearch(accountNumber = 987654321, 
             startDate = Sys.Date()-days(50),
             maxResult = 500, orderStatus = 'FILLED')

}