R is a powerful language. It can be used to process data and communicate with database and so on. The following functions are used to automatically download historical data of a list of stocks. The argument of the generateCMD function (stocklist) is a vector of stock symbols. The function can generate CMD command strings and store them into a CMD file and then execute the CMD file. To do this, you have to install “curl” on your windows system. You can download an appropriate lastest version of the CURL application from https://curl.haxx.se/download.html.

toNumerics {
stopifnot(inherits(Date, c(“Date”, “POSIXt”)))
day month year list(year = year, month = month, day = day)

generateCMD {
cmdtext for (i in 1:length(stocklist))
stocksymbol # get today’s day, month, year information
today mydatecom day month year # download the data from the internet
cmdstr cmdtext }
cmdtext write(cmdtext, file=”dlcmd.cmd”)
system(“dlcmd.cmd”, wait=T)