Skip to main content

A flexible backtesting framework for Python

Project description

Build Status Codecov PyPI Version PyPI License

bt - Flexible Backtesting for Python

bt is currently in alpha stage - if you find a bug, please submit an issue.

Read the docs here: http://pmorissette.github.io/bt.

What is bt?

bt is a flexible backtesting framework for Python used to test quantitative trading strategies. Backtesting is the process of testing a strategy over a given data set. This framework allows you to easily create strategies that mix and match different Algos. It aims to foster the creation of easily testable, re-usable and flexible blocks of strategy logic to facilitate the rapid development of complex trading strategies.

The goal: to save quants from re-inventing the wheel and let them focus on the important part of the job - strategy development.

bt is coded in Python and joins a vibrant and rich ecosystem for data analysis. Numerous libraries exist for machine learning, signal processing and statistics and can be leveraged to avoid re-inventing the wheel - something that happens all too often when using other languages that don't have the same wealth of high-quality, open-source projects.

bt is built atop ffn - a financial function library for Python. Check it out!

Features

  • Tree Structure The tree structure facilitates the construction and composition of complex algorithmic trading strategies that are modular and re-usable. Furthermore, each tree Node has its own price index that can be used by Algos to determine a Node's allocation.

  • Algorithm Stacks Algos and AlgoStacks are another core feature that facilitate the creation of modular and re-usable strategy logic. Due to their modularity, these logic blocks are also easier to test - an important step in building robust financial solutions.

  • Charting and Reporting bt also provides many useful charting functions that help visualize backtest results. We also plan to add more charts, tables and report formats in the future, such as automatically generated PDF reports.

  • Detailed Statistics Furthermore, bt calculates a bunch of stats relating to a backtest and offers a quick way to compare these various statistics across many different backtests via Results display methods.

Roadmap

Future development efforts will focus on:

  • Speed Due to the flexible nature of bt, a trade-off had to be made between usability and performance. Usability will always be the priority, but we do wish to enhance the performance as much as possible.

  • Algos We will also be developing more algorithms as time goes on. We also encourage anyone to contribute their own algos as well.

  • Charting and Reporting This is another area we wish to constantly improve on as reporting is an important aspect of the job. Charting and reporting also facilitate finding bugs in strategy logic.

Installing bt

The easiest way to install bt is from the Python Package Index using pip:

pip install bt

Since bt has many dependencies, we strongly recommend installing the Anaconda Scientific Python Distribution, especially on Windows. This distribution comes with many of the required packages pre-installed, including pip. Once Anaconda is installed, the above command should complete the installation.

Recommended Setup

We believe the best environment to develop with bt is the IPython Notebook. From their homepage, the IPython Notebook is:

"[...] a web-based interactive computational environment
where you can combine code execution, text, mathematics, plots and rich
media into a single document [...]"

This environment allows you to plot your charts in-line and also allows you to easily add surrounding text with Markdown. You can easily create Notebooks that you can share with colleagues and you can also save them as PDFs. If you are not yet convinced, head over to their website.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bt-1.0.1.tar.gz (227.6 kB view details)

Uploaded Source

Built Distributions

bt-1.0.1-cp312-cp312-win_amd64.whl (212.9 kB view details)

Uploaded CPython 3.12 Windows x86-64

bt-1.0.1-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

bt-1.0.1-cp312-cp312-macosx_11_0_arm64.whl (240.3 kB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

bt-1.0.1-cp312-cp312-macosx_10_9_x86_64.whl (257.2 kB view details)

Uploaded CPython 3.12 macOS 10.9+ x86-64

bt-1.0.1-cp311-cp311-win_amd64.whl (214.6 kB view details)

Uploaded CPython 3.11 Windows x86-64

bt-1.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

bt-1.0.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (1.3 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

bt-1.0.1-cp311-cp311-macosx_11_0_arm64.whl (245.3 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

bt-1.0.1-cp311-cp311-macosx_10_9_x86_64.whl (266.3 kB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

bt-1.0.1-cp310-cp310-win_amd64.whl (214.3 kB view details)

Uploaded CPython 3.10 Windows x86-64

bt-1.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

bt-1.0.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (1.2 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

bt-1.0.1-cp310-cp310-macosx_11_0_arm64.whl (243.9 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

bt-1.0.1-cp310-cp310-macosx_10_9_x86_64.whl (264.6 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

bt-1.0.1-cp39-cp39-win_amd64.whl (214.5 kB view details)

Uploaded CPython 3.9 Windows x86-64

bt-1.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

bt-1.0.1-cp39-cp39-macosx_11_0_arm64.whl (244.1 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

bt-1.0.1-cp39-cp39-macosx_10_9_x86_64.whl (264.9 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

bt-1.0.1-cp38-cp38-win_amd64.whl (215.7 kB view details)

Uploaded CPython 3.8 Windows x86-64

bt-1.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

bt-1.0.1-cp38-cp38-macosx_11_0_arm64.whl (242.6 kB view details)

Uploaded CPython 3.8 macOS 11.0+ ARM64

bt-1.0.1-cp38-cp38-macosx_10_9_x86_64.whl (261.4 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

File details

Details for the file bt-1.0.1.tar.gz.

File metadata

  • Download URL: bt-1.0.1.tar.gz
  • Upload date:
  • Size: 227.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.9

File hashes

Hashes for bt-1.0.1.tar.gz
Algorithm Hash digest
SHA256 5ac3d184c3e287a9f831708cee381b576d7e74eabd5050ddff2daaeed5059680
MD5 7063e1f4e47b33702cf3b7a8abe89382
BLAKE2b-256 8efda9285a2d2224fd62ae796fec035f1663b37eb0a4243dee5ddea360584b69

See more details on using hashes here.

File details

Details for the file bt-1.0.1-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: bt-1.0.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 212.9 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.9

File hashes

Hashes for bt-1.0.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 1854bc0bf556375b95c261c40dffaa7780a8a3650320a86fb30d9d43265a9b42
MD5 e2a5edc07acfe424d0903077760a855b
BLAKE2b-256 1658d57c38446a3dc5e453841e229b02cf543f43bfd47f7dbaa3b832ba12e69f

See more details on using hashes here.

File details

Details for the file bt-1.0.1-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for bt-1.0.1-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 91f47d7fa29efb6f00a522a7e7f39e4019d1bf19ea7f6f64a5a230d3bf00f196
MD5 2031037d4a5b9f40b53538cd8baf442a
BLAKE2b-256 fbe8c0f1b6f0d1c70e9c0806e6dec40cae4007f2ee9285d0b5b8b037f8296155

See more details on using hashes here.

File details

Details for the file bt-1.0.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for bt-1.0.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 00acd37a717c72de9b42b72677bf703dd6ff9c05e8562303a9a8b4a929a83b2e
MD5 d33b173d0c8bcf7d2dc89c9121a4733f
BLAKE2b-256 be2913ea89ee665aca6bd106729f441afd9ffa81768fcfc55d967208d3ed222b

See more details on using hashes here.

File details

Details for the file bt-1.0.1-cp312-cp312-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for bt-1.0.1-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b01ff3c1453dd3b79a1c08bf5a21cf34523d7bfc6a68e03a30b0718d49101f2b
MD5 c76e7a7a68887f7e188e18036d626d0f
BLAKE2b-256 c0b096efa690c608dd58c0630ede3f7fbcc6a9a4078037d96940fa4e9245313b

See more details on using hashes here.

File details

Details for the file bt-1.0.1-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: bt-1.0.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 214.6 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.9

File hashes

Hashes for bt-1.0.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 b1a06c5e672d6af3359d09b96dac8ef345e6b85121d1cc830d85b43a865c0735
MD5 d4d9c43989ef64bd1c98e24bcd4e0950
BLAKE2b-256 f21a4d3a959cc3cfb9311cdf3b0863f22348181cfd5f4c802800bd08c9940a1f

See more details on using hashes here.

File details

Details for the file bt-1.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for bt-1.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 76938322717bc76bb855ff1b758e83c268a23feb76476135445471adfcf36e70
MD5 6af7db7b87ed4409ddca7fc785ca1659
BLAKE2b-256 710e32c4e36e6e15a12f5405c983a94180c1d61dffb50fd75d1aa4b700df9402

See more details on using hashes here.

File details

Details for the file bt-1.0.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for bt-1.0.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 678aef315e0af1ba988685db19383730fb4a8b2cecaad9c03d52ad1a6499a266
MD5 c7e8cb45d49bf30f8bd785bf8a4c6929
BLAKE2b-256 a27a89fa5df27612c62da93abed88190a83c47f90e4adf1698f0cf22c6ac073f

See more details on using hashes here.

File details

Details for the file bt-1.0.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for bt-1.0.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ffae4e56f4ca91504e348bee2d6d5de6367877df8f5dfc31a6ffc4f22a05caf2
MD5 597933f321e79608b0a70dae08c1b46f
BLAKE2b-256 16038515e5b578ffdc010063af7d3da755a731ad36e96706b78eb7e8e6c090e4

See more details on using hashes here.

File details

Details for the file bt-1.0.1-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for bt-1.0.1-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b1cb0f62f50d8b8683c130f342cf42f7f59f09102832c358fca8f88de63be644
MD5 f08598b4130f2f223c747ee673e36564
BLAKE2b-256 aa0e5d7460e7c19056c971d098c518b61b9e16fa312cdd2412da12333ec6ffeb

See more details on using hashes here.

File details

Details for the file bt-1.0.1-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: bt-1.0.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 214.3 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.9

File hashes

Hashes for bt-1.0.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 aa07c59d3b41cf9cd9186e8d29086f638bc3f3c75b370075c579e44f4b9db228
MD5 609d735d26aeb6cca268b9e23f5eacd4
BLAKE2b-256 3a9e095683ef1359a18f8b22a7788356ee3814e36c7514afe67577b03620533f

See more details on using hashes here.

File details

Details for the file bt-1.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for bt-1.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 de8a58f5144d0786560e91af3988c2f58d847b430b30d7dc004e960a028bb794
MD5 2ea6ac10000cde270cba6a7b9864e512
BLAKE2b-256 e1168fb1a51027851e4925173afac801cb9b3746874af18ef20be35b6374c4bb

See more details on using hashes here.

File details

Details for the file bt-1.0.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for bt-1.0.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 a6b2788861045ad77eb860e5f3f29808c2261b2bff7b25ee316639bea2679b8d
MD5 69a9e240d45b0df4e1ab0c9a6d0194a8
BLAKE2b-256 68cd12f144c36454b1761a63cd452ab9514b99a7ac7a129aabb7e6bc5ac2676b

See more details on using hashes here.

File details

Details for the file bt-1.0.1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for bt-1.0.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2399a95121b4d06779f5b09a10dd45774045e07a610a17a99d146455b52f7a05
MD5 c9bbde9169d8926476cff82a95a6733e
BLAKE2b-256 401aa77b75451e975c4032cf6faf21abfd828e90b23822989ed199e26aefa4cd

See more details on using hashes here.

File details

Details for the file bt-1.0.1-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for bt-1.0.1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 a85f9dc6341f1c65e54b5148eabf04d683e2c253fff9cd5e637ce1d311ed39ca
MD5 0711c9156d02446b92e93dd74e20e632
BLAKE2b-256 94e7ed3ecfe7f11d282a4ee791e810c8845995ce3b8e2baeec961880306d6685

See more details on using hashes here.

File details

Details for the file bt-1.0.1-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: bt-1.0.1-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 214.5 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.9

File hashes

Hashes for bt-1.0.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 010c518b84cc2773dfe75d1f95d8f79555004e8314828aa7acae383a516ae73a
MD5 cdf87a4f2451fa5240f161e414c9d221
BLAKE2b-256 ecafc16ece0446b6d1e27d0210647e9f40f1e2d3ca9bafe5195e40c21d4b0e79

See more details on using hashes here.

File details

Details for the file bt-1.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for bt-1.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7db7958998d60fef9bfe58ced795e07ee65b2a47a19f324ab8196c90aa5a9689
MD5 87eac50f0cf2c70a237f00f9abacb5e5
BLAKE2b-256 f4febeb5fed9cc3f2d0f16bb35ca6f4a602f9b2442746d510734470f9c821fd8

See more details on using hashes here.

File details

Details for the file bt-1.0.1-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

  • Download URL: bt-1.0.1-cp39-cp39-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 244.1 kB
  • Tags: CPython 3.9, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.9

File hashes

Hashes for bt-1.0.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a77e1c8d4f5fd2ba83bb780ad5d487a3cc800539b1e1ee30099213c7e266e50e
MD5 7b603c0e3a1613345ce01bfc86d4ee66
BLAKE2b-256 4f577622bac06f5c9e4e158009aed020aa00c62e618ebfbda2c75dd51b95342e

See more details on using hashes here.

File details

Details for the file bt-1.0.1-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: bt-1.0.1-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 264.9 kB
  • Tags: CPython 3.9, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.9

File hashes

Hashes for bt-1.0.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 8e521c4f5aba9128a0982ee8a45424deb8370eefac15ebb4a572d17cd17509f7
MD5 42db2c42f3410c484cf692e95fb6f1b9
BLAKE2b-256 90c6cfa18111cf41ed2ab2abdddf25ad83fbdf10d884276f71169f824ee04c03

See more details on using hashes here.

File details

Details for the file bt-1.0.1-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: bt-1.0.1-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 215.7 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.9

File hashes

Hashes for bt-1.0.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 d8a09a210c4d66b9194344695b4f4407f8c2378f1502e3da534f11f9d239db57
MD5 fd7d5405d8725dd4a3c14e3fda17be49
BLAKE2b-256 2a8657d4839f6a59c83f60aae8877cbafa172e7a06e89fd9d5fd44e0eeeb1e52

See more details on using hashes here.

File details

Details for the file bt-1.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for bt-1.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d9fa02c0e9a8ebf5ed548ae6d484650752cabe691ef3e55002bd4639c9e9dc51
MD5 97ccdd675694bbc6b7d8679661366876
BLAKE2b-256 dacdcd552e4be59a1bceacca4152325756d99f284c3018a00c129508885a4d75

See more details on using hashes here.

File details

Details for the file bt-1.0.1-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

  • Download URL: bt-1.0.1-cp38-cp38-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 242.6 kB
  • Tags: CPython 3.8, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.9

File hashes

Hashes for bt-1.0.1-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fffac7e53be8f1112623250e17ffde93b0870e569ffba69a3edd03f81947cec8
MD5 782188ced682095245f357b1c671ed53
BLAKE2b-256 5a6209f2557e276be191d9d039fe7155b42ccb75f588db73d85896c2c0585799

See more details on using hashes here.

File details

Details for the file bt-1.0.1-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: bt-1.0.1-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 261.4 kB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.9

File hashes

Hashes for bt-1.0.1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 0051198b17bbb6ad53121d50c199398ebcc2e6008e8a400595eacbb9949fe42e
MD5 609345b73767ea315b7d63e3593e451b
BLAKE2b-256 3228435ea5570988912aa7c1866dcf95e130193407671913d82cddf98a7aa742

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page