Skip to content

Instantly share code, notes, and snippets.

@flovv
Created December 13, 2015 13:52
Show Gist options
  • Save flovv/50ed4495911576040e34 to your computer and use it in GitHub Desktop.
Save flovv/50ed4495911576040e34 to your computer and use it in GitHub Desktop.
## 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