Skip to content

Commit c0a241b

Browse files
committed
Updated README for latest API and tearsheet.
1 parent e152d38 commit c0a241b

File tree

1 file changed

+46
-18
lines changed

1 file changed

+46
-18
lines changed

README.md

Lines changed: 46 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
# QSTrader
55

6-
QSTrader is an open-source event-driven backtesting and live trading platform for use in the equities markets, currently in an early "alpha" state.
6+
QSTrader is an open-source event-driven backtesting platform for use in the equities markets, currently in an alpha state.
77

8-
It has been created as part of the Advanced Trading Infrastructure article series on QuantStart.com to provide the systematic trading community with a robust trading engine that allows straightforward equities/ETF strategy implementation and testing.
8+
It has been created as part of the Advanced Trading Infrastructure article series on QuantStart.com to provide the systematic trading community with a robust trading engine that allows straightforward equities strategy implementation and testing.
99

1010
The software is provided under a permissive "MIT" license (see below).
1111

@@ -19,40 +19,40 @@ The software is provided under a permissive "MIT" license (see below).
1919

2020
* **Software Development** - QSTrader is written in the Python programming language for straightforward cross-platform support. QSTrader contains a suite of unit tests for the majority of its calculation code and tests are constantly added for new features.
2121

22-
* **Event-Driven Architecture** - QSTrader is completely event-driven both for backtesting and live trading, which leads to straightforward transitioning of strategies from a research/testing phase to a live trading implementation.
22+
* **Event-Driven Architecture** - QSTrader is completely event-driven, which leads to straightforward transitioning of strategies from a research phase to a live trading implementation.
2323

2424
* **Backtesting** - QSTrader supports both intraday tick-resolution (top of order book bid/ask) datasets as well as OHLCV "bar" resolution data on various time scales.
2525

2626
* **Private Components** - QSTrader allows you to include a repository of your own private strategies or components. Simply checkout your own repository within the root of QSTrader and rename the directory to `private_files`. This will ensure the QSTrader repository can be easily kept up to date without interfering with your private repository.
2727

28-
* **Performance Metrics** - QSTrader will supports basic strategy/portfolio performance measurement and equity curve visualisation via the Matplotlib and Seaborn visualisation libraries.
28+
* **Performance Metrics** - QSTrader supports both portfolio-level and trade-level performance measurement. It provides a comprehensive "tearsheet" (see below) with associated strategy statistics.
2929

3030
# Planned Features
3131

32-
* **Transaction Costs** - Fees/commission, slippage and market impact will all be simulated using realistic assumptions. This means the costs predicted in backtests will be similar to those encountered in live trading.
32+
* **Transaction Costs** - Commissions are currently supported using Interactive Brokers standard fees for North American equities. Slippage and market impact are planned, but are not currently supported.
3333

34-
* **Trading** - QSTrader will support live intraday trading using the Interactive Brokers API across a set of equities/ETFs.
34+
* **Trading** - QSTrader will support live intraday trading using the Interactive Brokers native Python API, initially for North American equities.
3535

3636
# Installation and Example Usage
3737

38-
QSTrader is in an extremely early alpha state at the moment and should only be used for exploratory backtesting research. The installation procedure is a little more involved than a standard Python package as it has not been added to the Python package repository yet.
38+
QSTrader is in an early alpha state at the moment. It should only be used for exploratory backtesting research. The installation procedure is a little more involved than a standard Python package as it has not yet been added to the Python package repository.
3939

40-
Ubuntu is the recommended platform on which to install QSTrader, but it will also work on Windows or Mac OSX under the Anaconda distribution (https://www.continuum.io/downloads).
40+
Ubuntu Linux is the recommended platform on which to install QSTrader, but it will also work on Windows or Mac OSX under the Anaconda distribution (https://www.continuum.io/downloads).
4141

42-
For those that wish to create their own virtual environment, the following steps are necessary to run a basic Buy And Hold strategy.
42+
For those that wish to create their own Python virtual environment the following steps are necessary to run both a basic Buy And Hold strategy as well as a slightly more complex Moving Average Crossover trend-following strategy.
4343

44-
An example virtual environment directory ```~/venv/qstraderp3``` has been used for this example. If you wish to change this directory then re-name it in the following steps.
44+
An example virtual environment directory ```~/venv/qstraderp3``` has been used here. If you wish to change this directory then rename it in the following steps.
4545

4646
The following steps will create a virtual environment directory with Python 3 and then activate the environment:
4747

4848
```
4949
mkdir -p ~/venv/qstraderp3
5050
cd ~/venv/qstraderp3
51-
virtualenv --no-site-packages -p /usr/bin/python3 .
51+
virtualenv --no-site-packages -p python3 .
5252
source ~/venv/qstraderp3/bin/activate
5353
```
5454

55-
At this point it is necessary to use pip to install QSTrader as a library and then manually install the requirements. The following steps will take some time as QSTrader relies on NumPy, SciPy, Pandas, Matplotlib as well as many other libraries and hence they will all need to compile:
55+
At this point it is necessary to use pip to install QSTrader as a library and then manually install the requirements. The following steps will take some time (5-10 minutes) as QSTrader relies on NumPy, SciPy, Pandas, Matplotlib as well as many other libraries and hence they will all need to compile:
5656

5757
```
5858
pip install git+https://github.com/mhallsmoore/qstrader.git
@@ -75,15 +75,43 @@ Finally, we can run the backtest itself:
7575
python buy_and_hold_backtest.py
7676
```
7777

78-
Once complete you will see performance charts indicating:
78+
Once complete you will see a full "tearsheet" of results including:
7979

8080
* Equity curve
81-
* Period returns
82-
* Drawdown
81+
* Drawdown curve
82+
* Monthly returns heatmap
83+
* Yearly returns distribution
84+
* Portfolio-level statistics
85+
* Trade-level statistics
8386

84-
The chart will look similar to:
87+
The tearsheet will look similar to:
8588

86-
![alt tag](https://s3.amazonaws.com/quantstart/media/images/qstrader-buy-and-hold.png)
89+
![alt tag](https://s3.amazonaws.com/quantstart/media/images/qstrader-buy-and-hold-tearsheet.png)
90+
91+
You can explore the buy_and_hold_backtest.py file to examine the API of QSTrader. You will see that it is relatively straightforward to set up a simple strategy and execute it.
92+
93+
For slightly more complex buy and sell rules it is possible to consider a Moving Average Crossover strategy.
94+
95+
The following strategy creates two Simple Moving Averages with respective lookback periods of 100 and 300 days. When the 100-period SMA exceeds the 300-period SMA 100 shares of AAPL are longed. When the 300-period SMA exceeds the 100-period SMA the position is closed out. To obtain the data for this strategy and execute it run the following code:
96+
97+
```
98+
cd ~/data
99+
wget https://raw.githubusercontent.com/mhallsmoore/qstrader/master/data/AAPL.csv
100+
cd ~/qstrader/examples
101+
wget https://raw.githubusercontent.com/mhallsmoore/qstrader/master/examples/moving_average_cross_backtest.py
102+
```
103+
104+
The backtest can be executed with the following command:
105+
106+
```
107+
python moving_average_cross_backtest.py
108+
```
109+
110+
Once complete a full tearsheet will be presented, this time with a benchmark:
111+
112+
![alt tag](https://s3.amazonaws.com/quantstart/media/images/qstrader-moving-average-cross-tearsheet.png)
113+
114+
Other example strategies can be found in the ```examples``` directory. Each example is self-contained in a ```****_backtest.py``` file, which can be used as templates for your own strategies.
87115

88116
The project is constantly being developed, so unfortunately it is likely that the current API will experience backwards incompatibility until a mature beta version has been produced.
89117

@@ -93,7 +121,7 @@ If you notice any bugs or other issues that you think may be due to the codebase
93121

94122
# License Terms
95123

96-
Copyright (c) 2015-2016 Michael Halls-Moore
124+
Copyright (c) 2015-2017 Michael Halls-Moore
97125

98126
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
99127

0 commit comments

Comments
 (0)