Quantcast

blotter updatePortf issues

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

blotter updatePortf issues

Hideyoshi Maeda
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

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should go.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: blotter updatePortf issues

OpenTrades
Hi Hideyoshi,

On 10-07-12 02:44, Hideyoshi Maeda wrote:

> 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

Looks like you hit the same bug that I filed a couple of weeks ago, see:
http://r-forge.r-project.org/tracker/index.php?func=detail&aid=2116&group_id=118&atid=516 
for a description and a workaround.

Please attach your reproducible example to my bug report, so the
developers can fix the bug.

HTH,

Jan.

>
> 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
>
> _______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.
>


--
Jan Humme - OpenTrades

WWW:     http://www.opentrades.nl
Email:   [hidden email]
Twitter: @opentrades

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should go.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: blotter updatePortf issues

gsee
This does not have anything to do with xts.  It is a blotter bug that
was introduced in Rev. 1027
(http://r-forge.r-project.org/scm/viewvc.php/pkg/blotter/R/updatePosPL.R?sortby=rev&root=blotter&r1=1027&r2=1026&pathrev=1027)

You can see from Hideyoshi's traceback, that updatePortf was called
with Dates=paste("::", as.Date(Sys.time()))

6: updatePortf(Portfolio = portfolio.st, Dates = paste("::",
as.Date(Sys.time()),
       sep = "")) at macd.R#80

Then, later, in .updatePosPL, a "/" is added to the date string

8: index(prices[paste("/", .parseISO8601(Dates)$last.time, sep = "")])

So, it's trying to parse something that looks sort of like this "/::2012-07-10"

That said, I'm not sure how to patch.

Best,
Garrett

On Tue, Jul 10, 2012 at 4:12 AM, OpenTrades <[hidden email]> wrote:

> Hi Hideyoshi,
>
>
> On 10-07-12 02:44, Hideyoshi Maeda wrote:
>>
>> 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
>
>
> Looks like you hit the same bug that I filed a couple of weeks ago, see:
> http://r-forge.r-project.org/tracker/index.php?func=detail&aid=2116&group_id=118&atid=516
> for a description and a workaround.
>
> Please attach your reproducible example to my bug report, so the developers
> can fix the bug.
>
> HTH,
>
> Jan.
>
>
>>
>> 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
>>
>> _______________________________________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>> -- Subscriber-posting only. If you want to post, subscribe first.
>> -- Also note that this is not the r-help list where general R questions
>> should go.
>>
>
>
> --
> Jan Humme - OpenTrades
>
> WWW:     http://www.opentrades.nl
> Email:   [hidden email]
> Twitter: @opentrades
>
>
> _______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions
> should go.

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should go.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: blotter updatePortf issues

gsee
Apologies for the misinformation.  blotter was version 0.8.9 at Rev.
1027, and according to the OP version 0.8.9 does not have the error.

I am unable to reproduce the error.

Garrett

On Tue, Jul 10, 2012 at 8:20 AM, G See <[hidden email]> wrote:

> This does not have anything to do with xts.  It is a blotter bug that
> was introduced in Rev. 1027
> (http://r-forge.r-project.org/scm/viewvc.php/pkg/blotter/R/updatePosPL.R?sortby=rev&root=blotter&r1=1027&r2=1026&pathrev=1027)
>
> You can see from Hideyoshi's traceback, that updatePortf was called
> with Dates=paste("::", as.Date(Sys.time()))
>
> 6: updatePortf(Portfolio = portfolio.st, Dates = paste("::",
> as.Date(Sys.time()),
>        sep = "")) at macd.R#80
>
> Then, later, in .updatePosPL, a "/" is added to the date string
>
> 8: index(prices[paste("/", .parseISO8601(Dates)$last.time, sep = "")])
>
> So, it's trying to parse something that looks sort of like this "/::2012-07-10"
>
> That said, I'm not sure how to patch.
>
> Best,
> Garrett
>

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should go.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: blotter updatePortf issues

unsown
Hi,

I seem to have exactly the same problem as Hideyoshi described. Here is the code that produce the problem.
quantstrat_test.R

The sessionInfo is:
R version 2.15.1 (2012-06-22)
Platform: i386-pc-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=Chinese (Simplified)_People's Republic of China.936
[2] LC_CTYPE=Chinese (Simplified)_People's Republic of China.936  
[3] LC_MONETARY=Chinese (Simplified)_People's Republic of China.936
[4] LC_NUMERIC=C                                                  
[5] LC_TIME=Chinese (Simplified)_People's Republic of China.936    

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

other attached packages:
[1] quantstrat_0.6.8           blotter_0.8.10            
[3] FinancialInstrument_0.15.1 quantmod_0.3-17          
[5] Defaults_1.1-1             TTR_0.21-1                
[7] xts_0.8-6                  zoo_1.7-7                

loaded via a namespace (and not attached):
[1] grid_2.15.1    lattice_0.20-6 tools_2.15.1
Loading...