" # ... And, now that you know what goes on behind the scenes,\n",
" # we could achieve the whole *exact* same thing with simpler:\n",
"\n",
" # To construct weekly RSI, we can use `resample_apply()`\n",
" # helper function from the library\n",
" self.weekly_rsi = resample_apply(\n",
" 'W-FRI', RSI, self.data.Close, self.w_rsi)\n",
"\n",
"source": [
"Better. While the strategy doesn't perform as well as simple buy & hold, it does so with significantly lower exposure (time in market).\n",
"\n",
"In conclusion, to test strategies on multiple time frames, you need to pass in data in the lowest time frame, then resample it to higher time frames, apply the indicators, then resample back to lower time frame, filling in the in-betweens.\n",
"Or simply use [`backtesting.lib.resample_apply()`](https://kernc.github.io/backtesting.py/doc/backtesting/lib.html#backtesting.lib.resample_apply) function."
"In conclusion, to test strategies on multiple time frames, you need to pass in data in the lowest time frame, then resample it to higher time frames, apply the indicators, then resample back to the lower time frame, filling in the in-betweens.\n",
"Which is what the function [`backtesting.lib.resample_apply()`](https://kernc.github.io/backtesting.py/doc/backtesting/lib.html#backtesting.lib.resample_apply) does for you."
# ... And, now that you know what goes on behind the scenes,
# we could achieve the whole *exact* same thing with simpler:
# To construct weekly RSI, we can use `resample_apply()`
# helper function from the library
self.weekly_rsi = resample_apply(
'W-FRI', RSI, self.data.Close, self.w_rsi)
@@ -168,5 +136,5 @@ def next(self):
# Better. While the strategy doesn't perform as well as simple buy & hold, it does so with significantly lower exposure (time in market).
#
# In conclusion, to test strategies on multiple time frames, you need to pass in data in the lowest time frame, then resample it to higher time frames, apply the indicators, then resample back to lower time frame, filling in the in-betweens.
#Or simply use [`backtesting.lib.resample_apply()`](https://kernc.github.io/backtesting.py/doc/backtesting/lib.html#backtesting.lib.resample_apply) function.
# In conclusion, to test strategies on multiple time frames, you need to pass in data in the lowest time frame, then resample it to higher time frames, apply the indicators, then resample back to the lower time frame, filling in the in-betweens.
#Which is what the function [`backtesting.lib.resample_apply()`](https://kernc.github.io/backtesting.py/doc/backtesting/lib.html#backtesting.lib.resample_apply) does for you.
0 comments on commit
7711732