Generation

generate functionMon, 06 Mar 2023

Get historical stock prices from Yahoo API for bulk lists of ticker symbols

getSymbols <- function(Symbols, src="yahoo", from="1990-01-01", to=Sys.Date(), verbose=TRUE, auto.assign=TRUE, ...){ require(quantmod) if(missing(Symbols)){ stop("Symbols argument must be supplied to getSymbols") } if(missing(from)){ stop("from argument must be supplied to getSymbols") } if(missing(to)){ stop("to argument must be supplied to getSymbols") } if(isTRUE(verbose)){ cat("Getting data from", from, "to", to) } NewSymbols = Symbols for(i in 1:length(Symbols)){ s = getSymbols(Symbols[i], src=src, from=from, to=to, verbose=FALSE, auto.assign=FALSE, ...

Questions about programming?Chat with your personal AI assistant