Systematic futures trading in python, using the systems developed by Rob Carver
pysystemtrade is the open source version of Rob Carver's own backtesting and trading engine that implements systems according to the framework outlined in his book "Systematic Trading", which is further developed on his blog and in his other books.
For a longer explanation of the motivation and point of this project see this blog post.
Pysystemtrade is a....:
- Backtesting environment that Rob uses to test all the strategies in his various books
- Which implements all the optimisation and system design principles in his books and on his blog.
- A fully automated system for futures trading (for interactive brokers)
pysystemtrade uses the IB insync library to connect to interactive brokers.
Rob originally developed and open sourced the system in December 2015. In 2024 Andy Geach took over as primary maintainer of the project. In January 2026 Rob moved pysystemtrade to a new github "organisation", pst-group. The organisation is 'owned' by Andy and Rob. It is the intention that this organisation will always have at least two owners, which will ensure the project continues into the future in the event of Rob's demise or him losing his github token.
Connecting to interactive brokers
Running as a production system
See the project.dependencies section in pyproject.toml for full details.
This package isn't hosted on pypi.org. So to get the code the easiest way is to use git:
# clone the repo to your local filesystem
$ git clone https://github.com/pst-group/pysystemtrade.git
# navigate to the project directory
$ cd pysystemtrade
# either install pysystemtrade normally
$ python -m pip install .
# or install in editable mode, with development dependencies
$ python -m pip install --editable '.[dev]'
There is a more complete installation guide here
This is an open source project, designed for people who are already comfortable using and writing python code, are capable of installing the dependencies, and who want a head start on implementing a system of their own. If you need a higher level of support then you are better off with another project. The most efficient way of getting support is by opening an issue on github. If you discover a bug please include:
- The full script that produces the error, including all
importstatements, or if it's a standard example file a pointer to the file. Ideally this should be a "minimal example" - the shortest possible script that produces the problem. - Versions of any necessary libraries you have installed
- The full output trace including the error messages
If you have a question like 'how to do X' or 'should we do Y' use the discussions board, not the error reporting. Offers to contribute will of course be gratefully accepted.
GNU v3 ( See LICENSE )
Absolutely no warranty is implied with this product. Use at your own risk. No guarantee is provided that it will be profitable, or that it won't lose all your money very quickly, or delete every file on your computer (by the way: it's not supposed to do that. Just in case you thought it was). All financial trading offers the possibility of loss. Leveraged trading, such as futures trading, may result in you losing all your money, and still owing more. Backtested results are no guarantee of future performance. The owners of the project can take no responsibility for any losses caused by live trading using pysystemtrade. Use at your own risk. The owners of the project are not currently registered or authorised by any financial regulator.