[Blotter-commits] r839 - pkg/FinancialInstrument/inst/parser

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Nov 6 14:36:50 CET 2011


Author: braverock
Date: 2011-11-06 14:36:50 +0100 (Sun, 06 Nov 2011)
New Revision: 839

Modified:
   pkg/FinancialInstrument/inst/parser/TRTH_BackFill.R
Log:
- minor updates: fewer warnings, more robust to file changes, pass more options into reut2xts()

Modified: pkg/FinancialInstrument/inst/parser/TRTH_BackFill.R
===================================================================
--- pkg/FinancialInstrument/inst/parser/TRTH_BackFill.R	2011-11-06 12:24:42 UTC (rev 838)
+++ pkg/FinancialInstrument/inst/parser/TRTH_BackFill.R	2011-11-06 13:36:50 UTC (rev 839)
@@ -20,7 +20,13 @@
 #email_to <- 'someuser at somehost.com'
 #email_from <- 'someuser at somehost.com'
 #
+#overwrite <- FALSE # whether to overwrite files from the same date, default FALSE
+#image <- TRUE # whether to write write Bid, Ask, and Price images to disk for diagnostics, default TRUE 
+#
 #no.cores <- 1 # for foreach
+#
+# # Also add any additional options that would make this script run better in your environment
+#
 ##############################################################################
 config_file<-'TRTH_config_file.R'
 source(config_file)
@@ -100,7 +106,7 @@
     
 	## Download Report s
 	system(paste("curl ftp://tickhistory-ftp.thomsonreuters.com:15500/results/",Reuters.report[grep(alias,Reuters.report)], " -u ",username,":",password," --ftp-ssl -k > ",archive_dir,"/",Reuters.report[grep(alias,Reuters.report)],sep=""))
-	system(paste("gzip -d -f ",archive_dir,"Report/",Reuters.report[grep(alias,Reuters.report)],sep=""))
+	#system(paste("gzip -d -f ",archive_dir,"Report/",Reuters.report[grep(alias,Reuters.report)],sep=""))
 	
 }	
 
@@ -200,7 +206,7 @@
 missing_i<-''
 instr_s<-unique(files.xts[,'name.new'])
 for(i in 1:length(instr_s)){
-    instr<-getInstrument(instr_s[i])
+    instr<-suppressWarnings(getInstrument(instr_s[i]))
     if(is.instrument(instr)){ 
         files.xts[files.xts$name.new ==instr_s[i],]$type<-as.character(instr$type[1])
     } else {
@@ -242,6 +248,10 @@
 	}
 
 	Data <- read.csv(paste(datapath,date,'/',date,'.',prod,'.csv',sep=''),stringsAsFactors=FALSE,header=FALSE)
+    if(ncol(Data)!=length(H)){
+        warning("length of headers and downloaded data do not match, trying to adjuust, but be careful!")
+        H<-H[1:ncol(Data)]
+    }
 	names(Data) <- H
 	
 	OTC.remove <- grep("IRGCOND",Data$Qualifiers)
@@ -374,7 +384,7 @@
 	
 }  ## End fn reut2xts 
 
-Out <- foreach(ii=iter(1:nrow(files.xts)),.errorhandling='pass') %dopar% reut2xts(files.xts[ii,,drop=FALSE],datapath=path.output, image=image)
+Out <- foreach(ii=iter(1:nrow(files.xts)),.errorhandling='pass') %dopar% reut2xts(files.xts[ii,,drop=FALSE],datapath=path.output, image=image, overwrite=overwrite)
 
 # now clean up
 files.rm <- list.files(archive_dir)



More information about the Blotter-commits mailing list