This repository contains example strategies to help you get started with AutoTrader. Please note that the strategies here are for the latest release of AutoTrader.
Are you looking to trade crypto? Then you may be more interested in my other project, cryptobots.
To run the strategies in this repository, you must first have AutoTrader installed. The easiest way to do so is by using pip:
pip install autotrader
Clone this repository by your preffered method. If you are new to git, simply click the green 'code' button at the top right of this page and download the zip. Alternatively, click here. You can also clone the repository on the command line using:
git clone https://github.com/kieran-mackle/autotrader-demo/
After cloning this repo, you are ready to begin backtesting any of the strategies. Simply run runfile.py
, after specifying the name of the strategy's configuration file (located in the config/
directory). For example, to run the MACD Crossover Trend Strategy, the runfile will look as so:
from autotrader.autotrader import AutoTrader # Import AutoTrader
at = AutoTrader() # Create AutoTrader instance
at.configure(show_plot=True, verbosity=1) # Configure the settings of AutoTrader
at.add_strategy('macd') # Provide the name of the strategy configuration file
at.backtest(start = '1/1/2020', # Configure the backtest
end = '1/1/2021',
initial_balance=1000,
leverage = 30)
at.run() # Run AutoTrader
If you would like a detailed explanation of how to construct a strategy with AutoTrader, refer to the tutorials on the AutoTrader website, by clicking here.
The following is a list of demo strategies provided in this repository. The configuration file names of each is provided.
macd.yaml
MACD Crossover Trend Strategy (from the website tutorials)ema_crossover.yaml
/long_ema_crossover.yaml
EMA Crossover Strategy (long only example plus long/short Forex example)supertrend.yaml
SuperTrend Trend Detector (AutoScan demo)