Building a custom trading infrastructure or using vendor software is a complex decision. Here's why you should consider QSTrader.
Free, Open Source Licensing - QSTrader has been released under an extremely permissive open-source MIT License, which allows full usage in both research and commercial applications, without restriction. You can use it at home to carry out retail trading or within a quant fund as a basis for your research and/or order management system, with no download cost or usage license whatsoever.
Maintainability - Many developers improve the software for their own usage and collaborate with the community by sharing their code. New features are added frequently (often daily, but nearly always weekly). Any bugs are quickly determined and fixed.
Software Development - QSTrader is written in the Python programming language for straightforward cross-platform support. The codebase contains a suite of unit tests for the majority of its calculation engine and tests are constantly added for new features.
Event-Driven Architecture - QSTrader is completely event-driven both for backtesting and live trading, which leads to straightforward transitioning of strategies from a research and testing phase to a live trading implementation. Core strategy/portfolio code is often identical across both deployments.
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.
Performance Metrics - QSTrader contains an entire Statistics module for performance measurement of portfolios over a backtest. This currently includes equity curve, period returns, drawdowns (through the Matplotlib/Seaborn libraries) and the usual risk/reward measures.
You can see the full source code for the project at the Github page.
QSTrader is in an "alpha" state at the moment and should only be used for exploratory backtesting research and/or development within a larger system.
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.
Ubuntu Linux (14.04 LTS or 16.04 LTS) is the recommended platform on which to install QSTrader, but it will also work on Windows or Mac OSX under the Anaconda distribution.
For those that wish to create their own virtual environment, the following steps are necessary to run a basic Buy And Hold strategy.
An example virtual environment directory
~/venv/qstraderp3 has been used for this instance. If you wish to change this directory then re-name it in subsequent instructions below.
The following steps will create a virtual environment directory with Python 3 and then activate the environment:
$ mkdir -p ~/venv/qstraderp3 $ cd ~/venv/qstraderp3 $ virtualenv --no-site-packages -p /usr/bin/python3 . $ source ~/venv/qstraderp3/bin/activate
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:
$ pip install git+git://github.com/mhallsmoore/qstrader.git $ pip install -r https://raw.githubusercontent.com/mhallsmoore/qstrader/master/requirements.txt
Now that the library itself and requirements have been installed it is necessary to create the default directories for the data and output. In addition it is possible to download the necessary data and example code to run a simple backtest of a Buy And Hold strategy on the S&P500 total return index:
$ mkdir -p ~/qstrader/examples ~/data $ cd ~/data $ wget https://raw.githubusercontent.com/mhallsmoore/qstrader/master/data/SP500TR.csv $ cd ~/qstrader/examples $ wget https://raw.githubusercontent.$ com/mhallsmoore/qstrader/master/examples/buy_and_hold_backtest.py
Finally, we can run the backtest itself:
$ python buy_and_hold_backtest.py
Once complete you will see performance charts indicating:
The chart will look similar to:
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.
If you have any questions about the installation then please feel free to email firstname.lastname@example.org.
If you notice any bugs or other issues that you think may be due to the codebase specifically, feel free to open a Github issue here: https://github.com/mhallsmoore/qstrader/issues
Copyright © 2015-2016 Michael Halls-Moore
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:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Trading equities on margin carries a high level of risk, and may not be suitable for all investors. Past performance is not indicative of future results. The high degree of leverage can work against you as well as for you. Before deciding to invest in equities you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with equities trading, and seek advice from an independent financial advisor if you have any doubts.