[R-SIG-Finance] blotter updatePortf issues

Hideyoshi Maeda hideyoshi.maeda at gmail.com
Tue Jul 10 02:44:26 CEST 2012


Hi guys,

I am having a few issues with the updatePortf function...this error seems to keep re-occuring...but have managed to make a reproducible example...that occurs on the demos...fyi this error does not occur when running blotter version 0.8.9

when running
demo(macd)

the code stops with this error...

> updatePortf(Portfolio=portfolio.st,Dates=paste('::',as.Date(Sys.time()),sep=''))
Error in if (length(c(year, month, day, hour, min, sec)) == 6 && c(year,  : 
  missing value where TRUE/FALSE needed
In addition: Warning message:
In as_numeric(YYYY) : NAs introduced by coercion

and running traceback() it shows this...

> traceback()
14: function (year = 1970, month = 12, day = 31, hour = 23, min = 59, 
        sec = 59, subsec = 0.99999, tz = "") 
    {
        if (!missing(sec) && sec%%1 != 0) 
            subsec <- 0
        sec <- ifelse(year < 1970, sec, sec + subsec)
        mon.lengths <- c(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 
            30, 31)
        if (missing(day)) {
            day <- ifelse(month %in% 2, ifelse(((year%%4 %in% 0 & 
                !year%%100 %in% 0) | (year%%400 %in% 0)), 29, 28), 
                mon.lengths[month])
        }
        if (length(c(year, month, day, hour, min, sec)) == 6 && c(year, 
            month, day, hour, min, sec) == c(1969, 12, 31, 23, 59, 
            59) && Sys.getenv("TZ") %in% c("", "GMT", "UTC")) 
            sec <- sec - 1
        ISOdatetime(year, month, day, hour, min, sec, tz)
    }(year = NA_real_, tz = "")
13: do.call(lastof, parse.side(intervals[2], intervals[1]))
12: as.POSIXlt(do.call(lastof, parse.side(intervals[2], intervals[1])))
11: .parseISO8601(ii, .index(x)[1], .index(x)[nr], tz = tz)
10: `[.xts`(prices, paste("/", .parseISO8601(Dates)$last.time, sep = ""))
9: prices[paste("/", .parseISO8601(Dates)$last.time, sep = "")]
8: index(prices[paste("/", .parseISO8601(Dates)$last.time, sep = "")])
7: .updatePosPL(Portfolio = pname, Symbol = as.character(symbol), 
       Dates = Dates, Prices = Prices, ... = ...)
6: updatePortf(Portfolio = portfolio.st, Dates = paste("::", as.Date(Sys.time()), 
       sep = "")) at macd.R#80
5: eval(expr, envir, enclos)
4: eval(ei, envir)
3: withVisible(eval(ei, envir))
2: source(available, echo = echo, max.deparse.length = Inf, keep.source = TRUE)
1: demo(macd)

Other discussions have related the error messages to a non-updated version of xts...I think everything is pretty much up-to-date, but just in case here is my sessionInfo()

> sessionInfo()
R version 2.15.1 (2012-06-22)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

locale:
[1] C/en_US.UTF-8/C/C/C/C

attached base packages:
[1] tools     parallel  stats     graphics  grDevices utils     datasets  methods  
[9] base     

other attached packages:
 [1] XML_3.9-4                    Rook_1.0-5                  
 [3] brew_1.0-6                   lubridate_1.1.0             
 [5] knitr_0.6.3                  rJava_0.9-3                 
 [7] googleVis_0.2.16             RJSONIO_0.98-1              
 [9] timeDate_2160.95             plyr_1.7.1                  
[11] PerformanceAnalytics_1.0.4.4 quantstrat_0.6.8            
[13] blotter_0.8.10               FinancialInstrument_0.15.1  
[15] quantmod_0.3-19              Defaults_1.1-1              
[17] TTR_0.21-1                   xts_0.8-6                   
[19] zoo_1.7-7                   

loaded via a namespace (and not attached):
[1] digest_0.5.2   evaluate_0.4.2 formatR_0.5    grid_2.15.1    lattice_0.20-6
[6] stringr_0.6   

Any help would be greatly appreciated!

And thanks again to you guys who put in so much hard work to build this amazing software!

Thanks



More information about the R-SIG-Finance mailing list