myGetSymbols {BatchGetSymbols} | R Documentation |
An improved version of function getSymbols
from quantmod
Description
This is a helper function to BatchGetSymbols
and it should normaly not be called directly. The purpose of this function is to download financial data based on a ticker and a time period.
The main difference from getSymbols
is that it imports the data as a dataframe with proper named columns and saves data locally with the caching system.
Usage
myGetSymbols(
ticker,
i.ticker,
length.tickers,
src = "yahoo",
first.date,
last.date,
do.cache = TRUE,
cache.folder = file.path(tempdir(), "BGS_Cache"),
df.bench = NULL,
be.quiet = FALSE,
thresh.bad.data
)
Arguments
ticker |
A single ticker to download data |
i.ticker |
A index for the stock that is downloading (for cat() purposes) |
length.tickers |
total number of stocks being downloaded (also for cat() purposes) |
src |
The source of the data ('google' or'yahoo') |
first.date |
The first date to download data (date or char as YYYY-MM-DD) |
last.date |
The last date to download data (date or char as YYYY-MM-DD) |
do.cache |
Use cache system? (default = TRUE) |
cache.folder |
Where to save cache files? (default = file.path(tempdir(), 'BGS_Cache') ) |
df.bench |
Data for bechmark ticker |
be.quiet |
Logical for printing statements (default = FALSE) |
thresh.bad.data |
A percentage threshold for defining bad data. The dates of the benchmark ticker are compared to each asset. If the percentage of non-missing dates with respect to the benchmark ticker is lower than thresh.bad.data, the function will ignore the asset (default = 0.75) |
Value
A dataframe with the financial data
See Also
getSymbols for the base function
Examples
ticker <- 'FB'
first.date <- Sys.Date()-30
last.date <- Sys.Date()
## Not run:
df.ticker <- myGetSymbols(ticker,
first.date = first.date,
last.date = last.date)
## End(Not run)