Skip to main content

Introduction

The pyqstrat package is designed for backtesting quantitative strategies. It was originally built for my own use as a quant trader / researcher, after I could not find a python based framework that was fast, extensible and transparent enough for use in my work.

This framework is designed for capable programmers who are comfortable with numpy and reasonably advanced Python techniques.

The goals are:

  • Speed - Performance sensitive components are written at the numpy level, or in C++, which can lead to performance improvement of several orders of magnitude over regular Python code. Where possible, we parrallelize work so you can take advantage of all the cores available on your machine.

  • Transparency - If you are going to commit money to a strategy, you want to know exactly what assumptions you are making. The code is written and documented so these are as clear as possible.

  • Extensibility - It would be impossible to think of all requirements for backtesting strategies that traders could come up with. In addition, its important to measure custom metrics relevant to the strategy being traded.

Using this framework, you can:

  • Create indicators, trading signals, trading rules and market simulators and add them to a strategy

  • Create contract groups for PNL grouping. For example, for futures and options, you may create a “front-month future” and “delta hedge” where the actual instruments change over time but you still want to analyze PNL at the contract group level.

  • Reuse existing market simulation or add your own assumptions to simulate how and when orders are filled

  • Measure returns, drawdowns, common return metrics such as sharpe, calmar and also add your own metrics.

  • Optimize your strategy’s parameters using all the CPU cores on your machine.

Installation

I would strongly recommend installing mamba and creating a mamba environment. See https://github.com/conda-forge/miniforge for installation instructions.

pyqstrat relies on numpy, scipy and pandas which in turn use Fortran and C code that needs to be compiled. pyqstrat also includes C++ code that will need to be compiled

mamba install pyqstrat

Requirements:

  • Python version 3.10 or higher;

Documentation

The best way to get started is to go through the getting started Jupyter notebook: Getting Started

Jupyter Notebooks

API docs

Discussion

The pyqstrat user group is the group used for pyqstrat discussions. You can also add code issues via github

Disclaimer

The software is provided on the conditions of the simplified BSD license.

Metadata

Release files for pyqstrat 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyqstrat 1.0.2
File Size Uploaded
pyqstrat-1.0.2.tar.gz 7.1 MB Details

Release files / pyqstrat-1.0.2.tar.gz

Download URL pyqstrat-1.0.2.tar.gz
Size 7.1 MB
Tags Source
SHA-256 checksum
How to use checksums
17032aac373649a9fe7ac2364227c761d658d2d188ea48695425891486790514
BLAKE2b-256 checksum
How to use checksums
25e7cf3a922ca85102843bcaf113e371eb45912d1543da7e02251a4d7b9bf24c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12

Release history Release notifications | RSS feed

This release

1.0.2 This release

1 release file

1.0.1

1 release file

1.0.0

1 release file

0.3.24

1 release file

0.3.23

1 release file

0.3.22

1 release file

0.3.21

1 release file

0.3.20

1 release file

0.3.19

1 release file

0.3.17

1 release file

0.3.16

1 release file

0.3.15

1 release file

0.3.14

1 release file

0.3.13

1 release file

0.3.12

1 release file

0.3.11

1 release file

0.3.10

1 release file

0.3.9

1 release file

0.3.8

1 release file

0.3.7

1 release file

0.3.6

1 release file

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.1

1 release file

0.3.0

2 release files

0.2.15

2 release files

0.2.14

2 release files

0.2.13

2 release files

0.2.12

2 release files

0.2.10

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page