Learn R Programming

charlesschwabapi (version 1.0.5)

get_orders: Get Orders

Description

Given the tokens object from the `get_authentication_tokens` function, return a data frame containing the orders for all accounts related to the authenticated user. By default, it will return all orders (default max is 3000) from the last 60 days. This can be adjusted through additional function parameters, but the maximum date range is one year.

Usage

get_orders(
  tokens,
  from_entered_datetime = strftime(Sys.time() - lubridate::days(60), format =
    "%Y-%m-%dT%H:%M:%S.000Z"),
  to_entered_datetime = strftime(Sys.time(), format = "%Y-%m-%dT%H:%M:%S.000Z"),
  max_results = NULL,
  status = NULL
)

Value

Returns a data frame containing order information for all accounts affiliated with authorized user.

Arguments

tokens

token object from `get_authentication_tokens` function (list).

from_entered_datetime

start of time range for orders that should be gathered - default is current datetime less 60 days (string).

to_entered_datetime

end of time range for orders that should be gathered - default is current datetime (string).

max_results

maximum number of results to be returned - default is NULL, which is 3000 (numeric).

status

only orders of this status should be returned. Default is NULL, which is all statuses. Valid values are "AWAITING_PARENT_ORDER", "AWAITING_CONDITION", "AWAITING_STOP_CONDITION", "AWAITING_MANUAL_REVIEW", "ACCEPTED", "AWAITING_UR_OUT", "PENDING_ACTIVATION", "QUEUED", "WORKING", "REJECTED", "PENDING_CANCEL", "CANCELED", "PENDING_REPLACE", "REPLACED", "FILLED", "EXPIRED", "NEW", "AWAITING_RELEASE_TIME", "PENDING_ACKNOWLEDGEMENT", "PENDING_RECALL", and "UNKNOWN" (string).

Author

Nick Bultman, njbultman74@gmail.com, July 2024

Details

The easiest way to enter the right strings in the start/end times is to begin with `Sys.time()`, use the `lubridate` package to adjust it, and then format it as ` date less 30 days, you can use: `strftime(Sys.time() - lubridate::days(30), format = " The defaults for this function illustrate the appropriate usage for the API.