Adds price data to av_runShiny() internal data.
Arguments
- indta
(default: NULL) A data.frame with the following minimal columns:
c(symbol,timestamp,close). Other variables added could bec(adjusted_close,open,high,low,volume,dividend_amount,split_coefficient)Ifadjusted_closeis not in the dataset, it will be set toclose- assettypes
(default NULL) An optional data.frame with minimal columns
c(symbol,type,currency,name)with descriptive data for the assets given inindta. If not specified, a call toav_get_pf(.,"SYMBOL_SEARCH")is necessary to determine the asset type (one ofc("Equity","ETF","FX","Index","Crypto")) for subsequent calls toav_get_pf()- equitylist
(default NULL) If specified, function will get equity prices from
av_get_pf.indtacan be null or is otherwise ignored.- dtstr
(default
"-30y::"). Date range to download if applicable.- delay
(default 0) Seconds to delay calls to determine asset type for future AV downloads. This is unused if
assettypesis given.
Details
Add Price or Time Series Data
Entire set of columns from av_get_pf() can be added. First date column renamed to timestamp internally.
Examples
if (FALSE) { # \dontrun{
# To add known symbols outside the app
av_load_shinydata() # Make sure most recent data is loaded
av_add_px(equitylist=c("IBM","GS","JPM"))
# To add ad-hoc data from Alphavantage (e.g. Natgas spot at Henry Hub)
# Note that "symbol" in indta must match same in assettypes
asset_df <- data.frame(symbol=c("GAS_HH"),type=c("user"),currency=c("USD"), name=c("GAS_HH"))
ng_data <- av_get_pf("","NATURAL_GAS")[,.(symbol="GAS_HH",timestamp,close=value)]
av_add_px(ng_data, assettypes=asset_df)
# To data from other sources
suppressMessages(require(quantmod))
ffdta <- as.data.table(quantmod::getSymbols("FEDFUNDS",src="FRED",auto.assign=FALSE))
ffdta <- ffdta[,.(DT_ENTRY=index,close=FEDFUNDS,adjusted_close=FEDFUNDS,symbol="FEDFUNDS")]
av_add_px(ffdta)
} # }