-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
walk.forward.R Filename format issue #44
Comments
I suspect that a better solution may be to use make.names() instead of as.Date() This would turn dashes, spaces, and colons into dots and preserve all the information. |
Can you please provide a minimal, reproducible example that illustrates the problem? The luxor.8.walk.forward demo is broken, so I don't know how you're "running |
I'm afraid I haven't got deep enough into the code to work out where it's referencing the files, but the line that creates those files is line 169 in walk.forward.R. Using the make.names() function around the indexes as suggested by Brian fixes the issue. This can be tested by:
Other than this (and some other small adjustments), the demo seems to be working for me - could you tell me why it is deemed as broken, I fear I've missed something major!? |
Are you using the latest build from this repo? And what is your You opened another issue this morning that says the |
I believe I installed from the R-Forge repo. Yes Windows, agreed about the ":". Ahh ok! If its any help, Ive inserted this in the demo prior to calling walk.forward: daylist <- lapply(split(GBPUSD, "days"), function(x) {
if(NROW(x) >= 35) x
})
GBPUSD <- do.call(rbind, daylist) I believe there is potentially a further issue with QuantStrat's implementation of WFA when used on short time-frames: On each individual Train and Test datasets, applying the strategy causes it to calculate all of the indicators and signals from the start of that individual dataset. If you're working with indicators with a look-back period of "n" bars then during the WFA, no trades can occur during the first "n" bars of that particular Test, as they are being used to initialize the signals. The shorter your training and testing periods (and the longer the look-back period of your indicators) the more this behaviour is likely to deviate your results away from what would have actually happened, as in real life, you are unlikely to reset all of your indicators each day. My conclusion is that it is far better to use much longer Training and Test periods ie 3 months and 1 month respectively! I'm very interested to hear your opinions on this and if you think it's a potential issue or not?! sessionInfo()
R version 3.3.0 (2016-05-03)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=English_Australia.1252 LC_CTYPE=English_Australia.1252 LC_MONETARY=English_Australia.1252
[4] LC_NUMERIC=C LC_TIME=English_Australia.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] zoo_1.7-13 tools_3.3.0 blotter_0.9.1741 xts_0.9.874
[5] quantmod_0.4-5 codetools_0.2-14 grid_3.3.0 iterators_1.0.8
[9] foreach_1.4.3 TTR_0.23-1 quantstrat_0.9.1739 FinancialInstrument_1.2.0
[13] PerformanceAnalytics_1.4.4000 lattice_0.20-33 |
obviously your training period needs to be long enough to warm up your indicators and get everything into a state where it trades. This isn't a problem with quantstrat's walk forward, it is a limitation of walk forward in any signal driven strategy process. because the training and testing periods overlap, this shouldn't cause any issues as long as the training period is large enough. The testing period should mimic what would be realistic in real life. Very few production strategies, even in automated shops, go through a major (external) reparameterization more often than weekly. |
My preferred solution would be to represent the datetimes as ISO8601 strings without any special characters. Thoughts? fmt <- "%Y%m%dT%H%M%S"
time.range <- paste(format(index(symbol[training.start]), fmt),
format(index(symbol[training.end]), fmt), sep=".")
save(.audit, file = paste(audit.prefix, symbol.st, time.range, "RData", sep=".")) |
sounds good to me |
@edward-wilson I just pushed a potential fix to the walkforward_filename branch. Please test and let me know if that resolves the issue. |
@joshuaulrich I just tested this and it appears to have fixed the issue! |
Running
walk.forward
on the GBPUSD 30min data as provided in the Luxor demo generates this error:Error in gzfile(file, "wb") : cannot open the connection In addition: Warning message: In gzfile(file, "wb") : cannot open compressed file 'wfa.GBPUSD.2002-10-21 00:30:00.2002-10-23 23:30:00.RData', probable reason 'Invalid argument'
I believe that there is some issue with the file name (it's length or special characters?) when the date AND time are used.
A solution proposed on a pull request in the R-Finance/Quantstrat Repo is to wrap the indexes in the
as.Date()
function to remove the time. This solves the issue but, as suggested by braverock, it could prevent applying new parameters at any other time than midnight.The text was updated successfully, but these errors were encountered: