braverock / quantstrat

289 stars 114 forks source link

signal.RSI.R example has dependency error - gamlss.util library not availe #137

Closed climbthemt closed 3 years ago

climbthemt commented 3 years ago

Description

demo/signal.RSI.R requires gamlss.util but gamlss.util is no longer available in cran.

Expected behavior

Expected gamlss.util library to be available.

Minimal, reproducible example

require(gamlss.util) # depends on gamlss Loading required package: gamlss.util Warning message: In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, : there is no package called ‘gamlss.util’

From cran website: "Package ‘gamlss.util’ was removed from the CRAN repository. Formerly available versions can be obtained from the archive. Archived on 2020-09-03 as check issues were not corrected in time. A summary of the most recent check results can be obtained from the check results archive. Please use the canonical form https://CRAN.R-project.org/package=gamlss.util to link to this page."

Session Info

R version 4.0.5 (2021-03-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.5 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/atlas/libblas.so.3.10.3
LAPACK: /usr/lib/x86_64-linux-gnu/atlas/liblapack.so.3.10.3

Random number generation:
 RNG:     Mersenne-Twister 
 Normal:  Inversion 
 Sample:  Rounding 

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
 [1] gamlss_5.3-4               nlme_3.1-152               gamlss.dist_5.3-2          MASS_7.3-54               
 [5] gamlss.data_6.0-1          iterators_1.0.13           IKTrading_1.0              roxygen2_7.1.1            
 [9] digest_0.6.27              Rcpp_1.0.6                 png_0.1-7                  quantstrat_0.16.9         
[13] foreach_1.5.1              blotter_0.15.0             PerformanceAnalytics_2.0.4 FinancialInstrument_1.3.1 
[17] quantmod_0.4.18            TTR_0.24.2                 xts_0.12.1                 zoo_1.8-9                 
[21] devtools_2.4.1             usethis_2.0.1             

loaded via a namespace (and not attached):
 [1] xfun_0.22         remotes_2.3.0     purrr_0.3.4       lattice_0.20-44   testthat_3.0.2    survival_3.2-11  
 [7] rlang_0.4.11      pkgbuild_1.2.0    glue_1.4.2        withr_2.4.2       sessioninfo_1.1.1 lifecycle_1.0.0  
[13] stringr_1.4.0     codetools_0.2-18  memoise_2.0.0     knitr_1.33        callr_3.7.0       fastmap_1.1.0    
[19] ps_1.6.0          curl_4.3.1        cachem_1.0.4      desc_1.3.0        pkgload_1.2.1     fs_1.5.0         
[25] stringi_1.6.1     processx_3.5.2    grid_4.0.5        rprojroot_2.0.2   quadprog_1.5-8    cli_2.5.0        
[31] tools_4.0.5       magrittr_2.0.1    crayon_1.4.1      Matrix_1.3-3      ellipsis_0.3.2    xml2_1.3.2       
[37] prettyunits_1.1.1 R6_2.5.0          boot_1.3-28       compiler_4.0.5   
jaymon0703 commented 3 years ago

Right, so the dependency is with the distributional.boxplot() function which uses the gamlss() function from the gamlss package. Either we "port" the code directly in quantstrat, or we use another approach or we comment out the use of distributional.boxplot() functions completely in this demo...

climbthemt commented 3 years ago

Well, I'm just getting serious with quantstrat, and the signal analysis and validation part of it. So I don't know what that graph would have shown. If it shows something really important that would help diagnostically to validate a signal I'd say port it over. But I do not have the knowledge to make that call. My ticket was just a 'hey, I saw something failed you need to be aware of' kind of trouble ticket.

jaymon0703 commented 3 years ago

This is the plot you get from that call to distributional.boxplot() if you specify xlim=c(0,10) which we should do in that demo script.

image

I will port the code to a new branch, and appreciate your testing the new branch when i have.

jaymon0703 commented 3 years ago

After some testing, and dependency rabbit holes it is occurring to me that we could simply download the archived package from GitHub whilst it is not on CRAN...i am testing this approach and it appears to be working...

So, if you install gamlss and gamlss.util from GitHub with the below code:

require(devtools)
install_github("cran/gamlss")
install_github("cran/gamlss.util")

then install the latest commit to this quantstrat branch,

install_github("braverock/quantstrat", ref = "be2e3ee")

then run the below (note i have changed the signal.RSI demo slightly by calling the distributional.boxplot first and then the signal.plot.

demo("signal.RSI")

then i suspect you will experience joy.

Please do let us know?

climbthemt commented 3 years ago

Well, no love yet. I get :+1:

GAMLSS-RS iteration 1: Global Deviance = 28964.94 GAMLSS-RS iteration 2: Global Deviance = 28964.94 gamlss package currently doesnt support encapsulation of their plotting function. Pending Patch.

jaymon0703 commented 3 years ago

Please make sure your plot window pane is large enough to plot and try again? I recall getting an error, and that message is returned from the tryCatch statement (https://github.com/braverock/quantstrat/blob/6c536dbe97d0efb622c853d8d9445f9b2933b040/R/signals.R#L922), when i think the error is something else.

climbthemt commented 3 years ago

Plots strangely. Probably because of the 'rows=2, columns = 5)' from the first plot Screenshot_2021-05-21_12-46-43

jaymon0703 commented 3 years ago

I changed the RSI demo so that the distributional box plot displays first, then the signal plots. If you installed the package with install_github("braverock/quantstrat", ref = "be2e3ee") it should work ok, or just use your own script calling the distributional boxplot first followed by the signal plots.

climbthemt commented 3 years ago

Success! I had to reinstall again from github. Ran demo and got what the expected graphs. Closed! Screenshot_2021-05-21_13-08-16