joshuaulrich / TTR

Technical analysis and other functions to construct technical trading rules with R
GNU General Public License v2.0
325 stars 102 forks source link

ZLEMA caused fatal session error/hard crash in RStudio #95

Closed yogat3ch closed 4 years ago

yogat3ch commented 4 years ago

Description

TTR::ZLEMA causes RStudio session to abort with fatal error.

Expected behavior

The moving average is computed as intended.

Minimal, reproducible example

Example 1 - normal call:

TTR::ZLEMA(1:20, ratio = .9, n = 7)

Example 2 - using eval:

`!!!` <- rlang::`!!!`
.opts <- list(x = 1:20,
     ratio = .9,
     n = 7)
.call <- rlang::call2(.fn = TTR::ZLEMA, !!!.opts)     
eval(.call)

Session Info

R version 3.5.3 (2019-03-11)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] 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] RevoUtils_11.0.3     RevoUtilsMath_11.0.0

loaded via a namespace (and not attached):
 [1] zoo_1.8-7            tidyselect_1.1.0     purrr_0.3.4.9000    
 [4] splines_3.5.3        lattice_0.20-38      timetk_0.1.3.9000   
 [7] vctrs_0.3.1.9000     generics_0.0.2       yaml_2.2.1          
[10] blob_1.2.1           survival_2.43-3      prodlim_2019.11.13  
[13] rlang_0.4.6.9000     pillar_1.4.4.9000    glue_1.4.1.9000     
[16] tibbletime_0.1.3     withr_2.2.0          DBI_1.1.0           
[19] bit64_0.9-7          TTR_0.23-6           lifecycle_0.2.0.9000
[22] quantmod_0.4-16      lava_1.6.7           stringr_1.4.0       
[25] timeDate_3043.102    recipes_0.1.12.9000  websocket_1.1.0     
[28] memoise_1.1.0        parallel_3.5.3       curl_4.3            
[31] class_7.3-15         xts_0.12-0           Rcpp_1.0.4.12       
[34] readr_1.3.1          ipred_0.9-9          HDA_0.0.0.9000      
[37] jsonlite_1.6.1       bit_1.1-15.2         catchr_0.2.2        
[40] hms_0.5.3            packrat_0.5.0        digest_0.6.25.1     
[43] stringi_1.4.7        dplyr_1.0.0          grid_3.5.3          
[46] tools_3.5.3          magrittr_1.5         tibble_3.0.1.9001   
[49] RSQLite_2.2.0.9000   AlpacaforR_1.0.0     crayon_1.3.4        
[52] tidyr_1.0.2          pkgconfig_2.0.3      ellipsis_0.3.1      
[55] MASS_7.3-51.1        Matrix_1.2-15        lubridate_1.7.9     
[58] gower_0.2.1          httr_1.4.1           rstudioapi_0.11     
[61] R6_2.4.1             rpart_4.1-13         nnet_7.3-12         
[64] compiler_3.5.3  
joshuaulrich commented 4 years ago

Thanks for the report! I can replicate the crash with TTR::ZLEMA(1:20, ratio = .9, n = 7). Thanks for the very simple example!

I'm not going to run the other example, because it's not minimal (i.e. it involves another package--and especially because that package manipulates how code is evaluated). If I fix the normal call, and it still fails with the rlang call, then you will need to investigate yourself or ask someone else to help. I don't have time to debug something that complex.

yogat3ch commented 4 years ago

Thanks for the quick response! That sounds good. If you let me know when it's fixed I can test out the eval usage and go from there. That was the way I was originally using it when I encountered the error, so I included it just to have it documented.

joshuaulrich commented 4 years ago

I'm confident this was a bug in TTR only, so the rlang version should work fine now. Thanks again for this report, and the minimal example!

yogat3ch commented 4 years ago

Indeed, functioning as intended now! Thank you!