schwab_priceHistory {schwabr} | R Documentation |
Get price history for a multiple securities
Description
Open, Close, High, Low, and Volume for one or more securities
Usage
schwab_priceHistory(
tickers = c("AAPL", "MSFT"),
startDate = Sys.Date() - 30,
endDate = Sys.Date(),
freq = c("daily", "1min", "5min", "10min", "15min", "30min"),
accessTokenList = NULL
)
Arguments
tickers |
a vector of tickers - no more than 15 will be pulled. for bigger requests, split up the request or use the 'Tiingo API', 'FMP Cloud API', or other free data providers |
startDate |
the Starting point of the data |
endDate |
the Ending point of the data |
freq |
the frequency of the interval. Can be daily, 1min, 5min, 10min, 15min, or 30min |
accessTokenList |
A valid Access Token must be set using the output from
|
Details
Pulls price history for a list of security based on the parameters that include a date range and frequency of the interval. Depending on the frequency interval, data can only be pulled back to a certain date. For example, at a one minute interval, data can only be pulled for 30-35 days. Prices are adjusted for splits but not dividends.
PLEASE NOTE: Large data requests will take time to pull back because of the looping nature. The 'Schwab API' does not allow bulk ticker request, so this is simply running each ticker individually. For faster and better historical data pulls, try the 'Tiingo API' or 'FMP Cloud API'
Value
a tibble of historical price data
Examples
## Not run:
# Set the access token and a provide a vector of one or more tickers
refreshToken = readRDS('/secure/location/')
accessToken = schwab_auth_accessToken(refreshToken, 'consumerKey')
tickHist5min = schwab_priceHistory(c('TSLA','AAPL'), freq='5min')
# The default is daily. Access token is optional once it's been set
tickHistDay = schwab_priceHistory(c('SPY','IWM'), startDate = '1990-01-01')
## End(Not run)