[R-SIG-Finance] IBrokers- how to keep target file from being re-written?

Vince Fulco vfulco1 at gmail.com
Tue Aug 11 18:25:43 CEST 2009


For now, using reqHistoricalData() vs. the new wrapper reqHistory(),
setting endDateTime array and then looping thru writing to same file.
Func overwrites and attempt to add 'a'ppend qualifiers doesn't work.

dfile='/home/foo/'

now<- Sys.Date()-1

tp<- seq(now, length=6, by=paste(-5, 'days'))

# reformat dates to conform with IB needs YYYYMMDD

now2<- as.Date(tp, format="%Y%m%d")

reqHistoricalData(tws,
		    contract,
		    endDateTime=now2,
		    barSize = "5 mins",
		    duration = "5 D",
		    useRTH = "0",
		    whatToShow = "TRADES",
		    time.format = "1",
		    verbose = TRUE,
		    tickerId = "1",
		    #eventHistoricalData,
                    # this line fails
                    #file=paste(dfile,'EStest.dat',sep=''),open='a')
		    file=paste(dfile,'EStest.dat',sep=''))

* Would prefer to work from one file but could write out to numerous
and then merge.

Snippet from reqHistoricalData() suggests write.table would need to be
extended with 'append=TRUE' but sure there is something more
obvious...

#
if (!missing(file)) {
            cm[, 1] <- dts
            write.table(cm, file = file, quote = FALSE, row.names = FALSE,
                col.names = FALSE, sep = ",")
            invisible(return())
#


TIA, Vince


-- 
Vince Fulco, CFA, CAIA
612.424.5477 (universal)
vfulco1 at gmail.com

 A posse ad esse non valet consequentia

“the possibility does not necessarily lead to materialization”



More information about the R-SIG-Finance mailing list