Forum: help
Monitor Forum | Start New ThreadRE: quantstrat::ruleOrderProc.R allowMagicalThinking = T has no effect [ Reply ] By: Kirill Savin on 2016-04-19 12:22 | [forum:43188] |
Thank you, Brian. I had no clue 'T' is not a reserved word in R, but a global variable, so I didn't even try to check that. Apologies for the false report. |
RE: quantstrat::ruleOrderProc.R allowMagicalThinking = T has no effect [ Reply ] By: Brian Peterson on 2016-04-19 11:54 | [forum:43139] |
There's nothing wrong with that match.call code. Here's a quick example: x<-function(a,b,c,...){match.call(expand.dots=TRUE)} x(a=1,d=4)$a ## [1] 1 x(a=1,d=4)$d ## [1] 4 x(a=1,d=4, allowMagicalThinking=FALSE)$allowMagicalThinking ## [1] FALSE x(a=1,d=4, allowMagicalThinking=TRUE)$allowMagicalThinking ## [1] TRUE isTRUE(x(a=1,d=4, allowMagicalThinking=TRUE)$allowMagicalThinking) ## [1] TRUE isTRUE(x(a=1,d=4, allowMagicalThinking=FALSE)$allowMagicalThinking) ## [1] FALSE |
RE: quantstrat::ruleOrderProc.R allowMagicalThinking = T has no effect [ Reply ] By: Brian Peterson on 2016-04-19 11:26 | [forum:43138] |
T isn't TRUE. I'm not inclined to change the code for a match that implies horrible strategy design practices to support bad coding too. |
quantstrat::ruleOrderProc.R allowMagicalThinking = T has no effect [ Reply ] By: Kirill Savin on 2016-04-19 10:27 | [forum:43137] |
I was passing an argument allowMagicalThinking = T to applyStrategy function, which in turn passes it to ruleOrderProc, where it is checked by the following lines (88-89) ----------- if(hasArg(allowMagicalThinking)) allowMagicalThinking=match.call(expand.dots=TRUE)$allowMagicalThinking else allowMagicalThinking = FALSE ------------ mach.call here does not return the argument value, but a "name" object instead (always fails isTRUE check later). Replacing it with list(...)$allowMagicalThinking fixes the issue. Session Info(): R version 3.2.4 Revised (2016-03-16 r70336) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows >= 8 x64 (build 9200) locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] magrittr_1.5 ggplot2_2.1.0 data.table_1.9.6 [4] IKTrading_1.0 roxygen2_5.0.1 digest_0.6.9 [7] Rcpp_0.12.3 quantstrat_0.9.1739 foreach_1.4.3 [10] blotter_0.9.1695 PerformanceAnalytics_1.4.3541 FinancialInstrument_1.2.0 [13] quantmod_0.4-5 TTR_0.23-1 xts_0.9-7 [16] zoo_1.7-12 loaded via a namespace (and not attached): [1] munsell_0.4.3 colorspace_1.2-6 lattice_0.20-33 stringr_1.0.0 plyr_1.8.3 tools_3.2.4 [7] grid_3.2.4 gtable_0.2.0 iterators_1.0.8 codetools_0.2-14 rsconnect_0.4.2.1 labeling_0.3 [13] stringi_1.0-1 scales_0.4.0 chron_2.3-47 |