Latest News (October 2019)
Based on the extensive feeback we have received from the QuantStart community we have begun a significant end-to-end overhaul of QSTrader in order to simplify installation, enhance usability and improve performance.
The current stable version will always be found at the master branch at the Github repository. To track the most recent version undergoing development it is possible to checkout the development branch at Github.
We will be providing a release date for the new version in due course, so please check this page regularly for updates.
- Why use QSTrader?
- How does QSTrader work?
- Frequently Asked Questions
- Software Engineering Principles
- Trading Disclaimer
Why use QSTrader?
QSTrader comes with an extensive, well-tested suite of interchangeable systematic trading modules that cover all aspects of simulation and backtesting. This means you can concentrate on strategy development and not infrastructure development. Here is a list of the top features that are currently under development for the new release:
- Alpha Models - A collection of single or multi-asset forecast templates that can be extended to produce complex forecasting models. Our intent is to eventually support Alpha Model blending via static or dynamic weights across backtest horizons to produce meta-forecasts. It is straightforward to use the built-in Alpha Models as a template for your own.
- Portfolio Construction - Portfolio weight optimisation and order sizing is included 'out-of-the-box'. A collection of optimisers is provided including both static such as equal weight (1/N) and fixed proportional weight. Additionally dynamic optimisers such as alpha-driven, mean-variance and equal risk (volatility-adjusted weights) are planned. The built-in optimisers can be used as templates for more sophisticated custom approaches to portfolio construction.
- Simulated Broker with Portfolio Accounting - The default simulated brokerage engine in QSTrader handles all asset position tracking and management, with support for multiple separate portfolios. The intent is to provide a framework for periodic and one-off cashflows such as cash dividends, subscriptions and withdrawals, allowing realistic simulation of investment income over long-term investment horizons. Specific brokers have associated fee models, which allow realistic simulation of commissions/fees for trades.
- Data Handling from Multiple Sources - Price/volume data is currently supported from flat-file CSV. Future implementations will connect to relational databases and NoSQL stores, all behind a common, straightforward interface accessible to nearly all components within the system.
- Performance Statistics - An extensive collection of performance and risk statistics to enable out post-simulation analytics is included. By default a 'tearsheet' visualisation is generated to determine performance 'at a glance'.
- Rapid Prototyping - QSTrader has an extensive suite of end-to-end modules with sensible defaults. This minimises the need to customise the software if you just want to carry out a quick prototype test of some signal logic. Equally, if you wish to run a sophisticated portfolio optimisation mechanism with multiple alpha and risk models, it is easy to override the defaults with your custom logic.
QSTrader is also the backtesting system used within many of the QuantStart strategy tutorials. Hence if you wish to see some examples of what it is capable of you can browser through our articles list.
How does QSTrader work?
The upcoming version of QSTrader is designed to be a periodically-scheduled and rebalanced event-style backtesting engine, built around the concept of alpha, risk and transaction cost models that feed into a portfolio construction model and execution mechanism.
This paradigm of systematic trading engines is inspired by the design outlined within Inside The Black Box by Rishi K. Narang.
QSTrader works by constructing a desired target portfolio of assets on every algorithm rebalance. This target portfolio is compared against the current portfolio at the simulated broker. The comparison generates rebalancing trades that push the current portfolio towards the desired portfolio. This process is then run iteratively for every desired rebalance period.
In order to generate such a target portfolio a Portfolio Construction Model is used, which takes in a set of quantitative 'opinions' from Alpha Models, Risk Models and Transaction Cost Models.
Alpha Models provide forecasts or strength of convictions on one or more tradeable assets. These forecasts may utilise features of the asset price/volume data or external data. The Alpha Models are designed to encapsulate logic for typical quant trading signals such as momentum, value or mean-reversion.
Risk Models provide guidance on exposures of assets to certain potentially undesirable risks such as market risk or sector exposure. These exposures can then be utilised to neutralise potential weightings of assets that might allocate too much 'risk' to certain unwanted factors.
Transaction Cost Models provide estimates for the profitability of individual trades and outline whether they may be too expensive to carry out. For instance a rebalance process of a portfolio may wish to buy only a single share of a stock in order to move the current portfolio closer to the target portfolio.
However if trading commissions are fixed then the expected return for carrying out the rebalance may be less than the hurdle of overcoming the transaction cost. In this case the trade might simply be cancelled until the current portfolio has drifted far enough from the target portfolio to make a rebalancing trade worthwhile over its cost.
The Portfolio Construction Model utilises all three of the above models, along with additionally provided quantitative optimisation and order sizing processes, to generate a target portfolio to be executed by the Execution Model.
Crucially, the schedule of the simulation as a whole can be carried out independently of the portfolio construction rebalance schedule, which provides the ability, say, to determine daily or intraday performance even on a strategy that only rebalances once a month. Similarly this functionality can provide higher-frequency intraday performance and exposure updates on a strategy that may only trade once per day. This mechanism also allows for cashflows and corporate actions to be applied when they actually occurred historically.
It is the task of the Broker engine to keep track of the cash, asset positions and portfolio state at all times in the simulation process. This allows a clean separation between target portfolio generation logic and portfolio cashflows and accounting.
The upcoming version of QSTrader contains sensible, conservative default implementations for all of the above behaviour allowing useful backtests to be run with minimal customisation beyond specification of Alpha and Risk models. It also allows straightforward customisation for those who wish to develop bespoke behaviour for any module in the system.
Frequently Asked Questions
Q) Does QSTrader support live trading?
A) At this stage QSTrader does not have direct linkage to any brokerage API. However it is one of the most important features on our development roadmap.
Despite this however it is designed to provide a straightforward list of rebalance trades per rebalance run. This means it is possible to execute the QSTrader systematic trading portfolio construction process as desired and then carry out the order execution of all the trades generated by this process.
Q) Is QSTrader suitable for technical analysis style 'indicator' trading?
A) QSTrader supports TA-style indicators through the concept of Alpha Models. Classical indicators such as Moving Averages, Stochastic Oscillators, Bollinger Bands etc can be incorporated into Alpha Models.
Be aware however that QSTrader is built around a slightly different paradigm as it makes use of a Portfolio Construction process prior to order generation. This means that TA indicator signals are not converted directly into buy/sell orders of a certain specified size.
Instead a form of optimisation is carried out over the signals to produce target weights, which are then sized appropriately into orders depending upon specified risk and transaction cost models.
Converting directly from TA-style indicator signals into buy/sell orders effectively circumvents this process, which is also supported by simply not supplying any risk or transaction cost models.
Q) Can I help out with QSTrader development?
A) Yes - we gladly welcome contributions to the QSTrader codebase. The first step is to request access to our dedicated Slack channel by contacting firstname.lastname@example.org. Once you have gained access we recommend proposing a change and discussing it with the team and the community. We will then review a submitted Pull Request against the Github QSTrader codebase. One of the most important aspects of QSTrader development is that any submitted code must have a significant unit and/or integration suite present, otherwise we will not be able to review code.
Software Engineering Principles
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 team's systematic strategy research, 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. Any bugs are quickly determined and fixed.
Testing - The codebase contains an extensive suite of unit and integration tests for all of the provided modules. In addition code coverage of the software aims to always remain above 90%, often higher.
Cross-Platform - QSTrader is writte in the Python programming language for straightforward cross-platform support. Utilising the Python Anaconda distribution it is supported on Windows, macOS and Linux.
Copyright © 2015-2020 QuantStart.com
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.