Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
## daily stock market data from Yahoo
getStockMarketData <- function(symbol = "VOW4.DE"){
require(stringr)
if(str_detect(symbol, ":")){
symbol <- paste(str_split_fixed(symbol, ":", 2)[,2], str_split_fixed(symbol, ":", 2)[,1], sep=".")
}
URL <- paste("http://ichart.finance.yahoo.com/table.csv?ignore=.csv&s=",symbol)
dat <- read.csv(URL)
dat$Date <- as.Date(dat$Date, "%Y-%m-%d")
return(dat)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment