The following basic trading strategies are implemented and evaluated as part of this analysis:
- Bollinger Bands
- Simple Moving Average Cross Over
- Buy and Hold
We start by analysing the dataset downloaded from Kaggle that contains stock and ETF OHLC (Open, High, Low, Close) prices. This dataset consists of a large number of individual files with each containing market data for one ticker. We first develop a market data API that abstracts away access to ticker files before proceeding with an EDA. We also showcase usage of Dask given that the market data is spread across a number of files and all of the data cannot fit into memory on my laptop.
We then implement a simple backtester for running trading strategies. As part of it we develop a number of Python classes: Strategy, Backtest, ConfigSearch, etc. The backtester allows us to search for the best perforing ticker & strategy combinations. We run a backtest for all 3 strategies using 5 year's worth of market data.
Install prerequisites:
$ conda env create -f environment.yml
Jupyter notebooks are located under notebooks
directory:
- The strategy backtesting notebook is inspired by the following Kaggle analysis:
- Some of the ideas around backtesting are inspired by quantstart.com
-
Implement and evaluate the Mean Reversion Pairs Trading strategy
-
Develop a more sophisticated backtester