Skip to content
Prev 13156 / 15274 Next

Quantmod Yahoo ticker download error

Hi Marco,

Very Strange! I update quantmod, still get this error...

Instead of downloading a lots of tickers, I tried to limit the list to
those tickers and tired to simplify the code. I get this error on the code
below:

*Error in 1:nrow(symbols) : argument of length 0*

I runned nrow(symbols) and get
nrow(symbols)
NULL

The symbols should not have any rows, right?

The For should look at the datasets for the tickers and store in to the
database, right?


*#Initialization*
*library(quantstrat)*
*library(TTR)*
*startDate <- "2010-01-01"*
*endDate <- "2013-07-31"*
*symbols = c("XLF","XLP","XLE","XLY","XLV","XLI","XLB","XLK","XLU")*
*Sys.setenv(TZ="UTC")*
*getSymbols(symbols, src="yahoo", from=startDate, to=endDate, adjust=TRUE)*

*# Save data to MySQL*

*library(RMySQL)*

*con <- dbConnect(RMySQL::MySQL(), host="localhost",
user="donedge",password="p at ssw0rd", dbname= "daily")*

*# Loop through each symbol*
*for (i in 1:nrow(symbols)){*
*  symbol <- symbols[i,]$Symbol*
*  df = data.frame(Date=index(get(symbol)), coredata(get(symbol)))*
*  setNames(df,c("Date","Open","High","Low","Close","Volume","Adjusted"))*

*  if(dbExistsTable(con, symbol)){*
*    dbRemoveTable(con, symbol)*
*  }*
*  dbWriteTable(con, name=symbol, value=df, row.names=FALSE, overwrite =
TRUE)*
*}*
On Tue, Feb 24, 2015 at 2:56 PM, Marco Sun <hs13322 at my.bristol.ac.uk> wrote: