[Blotter-commits] r881 - pkg/FinancialInstrument/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Dec 18 03:51:57 CET 2011


Author: gsee
Date: 2011-12-18 03:51:54 +0100 (Sun, 18 Dec 2011)
New Revision: 881

Modified:
   pkg/FinancialInstrument/R/load.instruments.R
Log:
If getSymbols.FI does not find any data, give warning and return NULL (instead of ambiguous error)

Modified: pkg/FinancialInstrument/R/load.instruments.R
===================================================================
--- pkg/FinancialInstrument/R/load.instruments.R	2011-12-15 22:49:27 UTC (rev 880)
+++ pkg/FinancialInstrument/R/load.instruments.R	2011-12-18 02:51:54 UTC (rev 881)
@@ -326,7 +326,7 @@
         ndc<-nchar(dir)
         if(substr(dir,ndc,ndc)=='/') dir <- substr(dir,1,ndc-1) #remove trailing forward slash
         ssd <- strsplit(dir,"/")[[1]]
-        if (identical(character(0), ssd) || ssd[length(ssd)] != Symbol) dir <- paste(dir,Symbol,sep="/")
+        if (identical(character(0), ssd) || (!identical(character(0), ssd) && ssd[length(ssd)] != Symbol)) dir <- paste(dir,Symbol,sep="/")
         
         if(!dir=="" && !file.exists(dir)) {
             if (verbose) cat("\ndirectory ",dir," does not exist, skipping\n")
@@ -378,7 +378,12 @@
             tmp     
         }
     }) #end loop over Symbols
-    
+
+    if (length(datl[[1]]) == 0) {
+        warning("No data found.")
+        return(NULL) 
+    }
+
     if(auto.assign) {
         invisible(lapply(datl, function(x) assign(names(x), x[[1]], pos=env)))        
         return(Symbols)



More information about the Blotter-commits mailing list