|
5 | 5 | # extension: .py
|
6 | 6 | # format_name: light
|
7 | 7 | # format_version: '1.5'
|
8 |
| -# jupytext_version: 1.3.0 |
| 8 | +# jupytext_version: 1.3.5 |
9 | 9 | # kernelspec:
|
10 | 10 | # display_name: Python 3
|
11 | 11 | # language: python
|
|
16 | 16 | # ============
|
17 | 17 | #
|
18 | 18 | # The best trading strategies relying on technical analysis take into account the price action on multiple time frames.
|
19 |
| -# This tutorial will show how to do that with _backtesting.py_, offloading most of the work to |
| 19 | +# This tutorial will show how to do that with backtesting.py, offloading most of the work to |
20 | 20 | # [pandas resampling](http://pandas.pydata.org/pandas-docs/stable/timeseries.html#resampling).
|
21 | 21 | # It is assumed you're already familiar with
|
22 |
| -# [basic _backtesting.py_ usage](https://kernc.github.io/backtesting.py/doc/examples/Quick Start User Guide.html). |
| 22 | +# [basic usage](https://kernc.github.io/backtesting.py/doc/examples/Quick Start User Guide.html). |
23 | 23 | #
|
24 | 24 | # We will put to the test this long-only, supposed
|
25 | 25 | # [400%-a-year trading strategy](http://jbmarwood.com/stock-trading-strategy-300/),
|
26 | 26 | # which uses daily and weekly
|
27 | 27 | # [relative strength index](https://en.wikipedia.org/wiki/Relative_strength_index)
|
28 | 28 | # (RSI) values and moving averages (MA).
|
29 | 29 | #
|
30 |
| -# Let's introduce the two indicators we'll be using. |
31 |
| -# In practice, one can use functions from any indicator library, such as |
32 |
| -# [TA-Lib](https://github.com/mrjbq7/ta-lib), |
| 30 | +# In practice, one should use functions from an indicator library, such as |
| 31 | +# [TA-Lib](https://github.com/mrjbq7/ta-lib) or |
33 | 32 | # [Tulipy](https://tulipindicators.org),
|
34 |
| -# PyAlgoTrade, ... |
| 33 | +# but among us, let's introduce the two indicators we'll be using. |
35 | 34 |
|
36 | 35 | # +
|
37 | 36 | import pandas as pd
|
@@ -138,5 +137,10 @@ def next(self):
|
138 | 137 |
|
139 | 138 | # Better. While the strategy doesn't perform as well as simple buy & hold, it does so with significantly lower exposure (time in market).
|
140 | 139 | #
|
141 |
| -# 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. |
| 140 | +# In conclusion, to test strategies on multiple time frames, you need to pass in OHLC 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. |
142 | 141 | # 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.
|
| 142 | + |
| 143 | +# Learn more by exploring further |
| 144 | +# [examples](https://kernc.github.io/backtesting.py/doc/backtesting/index.html#tutorials) |
| 145 | +# or find more framework options in the |
| 146 | +# [full API reference](https://kernc.github.io/backtesting.py/doc/backtesting/index.html#header-submodules). |
0 commit comments