braverock / quantstrat

289 stars 114 forks source link

Warning message for walk.forward in macdWFA.R demo file #118

Closed miguellacerda closed 4 years ago

miguellacerda commented 4 years ago

Hi there

I have been trying to use the quantstrat::walk.forward function, but have been getting warnings:

Warning messages:
1: In .updatePosPL(Portfolio = pname, Symbol = as.character(symbol),  :
  Could not parse //2016-12-30 as ISO8601 string, or one/bothends of the range were outside the available prices: 2007-01-03/2016-12-30. Using all data instead.
2: In tradeStats(test.portfolio.st) : TotalNetProfit NA forSPY

To debug my code, I tried running some of your demo files, but am still getting warning messages:

macd.R - line 124:

> updatePortf(Portfolio=portfolio.st,Dates=paste('::',as.Date(Sys.time()),sep=''))
[1] "macd"
Warning message:
In .updatePosPL(Portfolio = pname, Symbol = as.character(symbol),  :
  Could not parse ::2020-04-30 as ISO8601 string, or one/bothends of the range were outside the available prices: 2007-01-03/2014-05-30. Using all data instead.

This is easily fixed by removing the Dates argument to updatePortf. However, I still get the following warning in macdWFA.R when trying to run walk.forward:

macdWFA.R - line 61:

> wfresults <- walk.forward(strategy.st, 
                          paramset.label = 'MA', 
                          portfolio.st = wfportfolio, 
                          account.st = account.st, 
                          nsamples = .nsamples,
                          period = 'months',
                          k.training = 36,
                          k.testing = 12,
                          verbose =TRUE,
                          anchored = TRUE,
                          include.insamples = TRUE,
                          savewf = FALSE
)

Warning message:
In .updatePosPL(Portfolio = pname, Symbol = as.character(symbol),  :
  Could not parse //2014-05-30 as ISO8601 string, or one/bothends of the range were outside the available prices: 2007-01-03/2014-05-30. Using all data instead.

Below is my session info:

R version 4.0.0 (2020-04-24)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.4

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

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

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

other attached packages:
 [1] iterators_1.0.12           quantstrat_0.16.7          foreach_1.5.0              blotter_0.14.8            
 [5] PerformanceAnalytics_2.0.4 FinancialInstrument_1.3.1  quantmod_0.4.17            TTR_0.23-6                
 [9] xts_0.12-0                 zoo_1.8-7                 

loaded via a namespace (and not attached):
[1] quadprog_1.5-8   lattice_0.20-41  codetools_0.2-16 MASS_7.3-51.5    grid_4.0.0       curl_4.3        
[7] boot_1.3-24      tools_4.0.0      compiler_4.0.0  

Please could you let me know if there is a bug.

jaymon0703 commented 4 years ago

Hi @miguellacerda. Those are merely warnings and not errors. Are you getting any output for a) macd.R and b) macd.WFA.R?

There may be a bug in blotter 0.14.6/7 which might break WFA in quantstrat. However the commit we believe induced the regression was reverted in the latest blotter version 0.14.8 with https://github.com/braverock/blotter/commit/23aa1c9d72ed5380bc5d2077c1266ff7b4e7174b which i see you are on. So it would help to confirm if you are getting any errors, or just the warning which looks immaterial.

Also, for more on the regression in 0.14.6 and how to downgrade to 0.14.5 if you ever wanted to, please see https://github.com/braverock/quantstrat/issues/112.

miguellacerda commented 4 years ago

Hi @jaymon0703

You are right - these are just warnings. As far as I can tell, the outputs of both demo files seem correct. I guess I'm just being pedantic about the warnings. Since they look immaterial to you, I'll close this issue.

Thanks for getting back to me!

jaymon0703 commented 4 years ago

No problem, thanks for confirming and closing the issue and best of luck.