A flexible backtesting framework for Python
Project description
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for bt-1.1.0-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | df537e0526a3fc9485f4705e88d8a82a567ac2107dbbc420ae9805fe5ed599c4 |
|
MD5 | 1ee4dfc550b5e332ce2bf3f8cdec12da |
|
BLAKE2b-256 | e7ada3747b478f2b3eef7839f40782049299efd715c9c7c32d8569bac47574b9 |
Hashes for bt-1.1.0-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e51d02f51c40bf543040e9b651c39edea0fa44a8a734a467382e35f87b82bfb0 |
|
MD5 | ddb29b16e5017be369e2d63460472c53 |
|
BLAKE2b-256 | 5beb28edc01c2b671d36ddb617a46a6efc12694315a7558355069d801fc97ae4 |
Hashes for bt-1.1.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bd0861653ffa4cb620355289a3742e7945ddbaefb90b50f626eb407f2e47f1b4 |
|
MD5 | 9d5732707b22d39abe41a1734540301c |
|
BLAKE2b-256 | cb093e5ca03827a5895121df09a76bd59161263092887e51879afefe4eedaa96 |
Hashes for bt-1.1.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 95fcf166e870a9d6ec5620bb947b34ad28c83dbc4d057feb5db2d0cc4db607a7 |
|
MD5 | 4fcc1a3e30fb4db7212c7bdc1c0a0250 |
|
BLAKE2b-256 | 454ff1417c42fdf8887b95304e777439bed94ccabdac990981bf6d271469b656 |
Hashes for bt-1.1.0-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 099efde3db7dca85e4c6f020afc9a08f02eb6ba79903c6c3bdfae5e0d2ab56d7 |
|
MD5 | 713fd4395a7c4dc15b4aedd2e3ab715b |
|
BLAKE2b-256 | af0d13ebfd475e9498c26c843031f7fcac9f377d49cf2f93a4c0551b5c68d073 |
Hashes for bt-1.1.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b1b9fbcfd4631813b068a56421aa99cc502da3ec91ff69167190afd60e521f4b |
|
MD5 | e66e61ed6ca9f824bcfb6fde19012d05 |
|
BLAKE2b-256 | ac6a2fcc1524ddfca7eb84ef23d99247ecb8ddb5cdc15eb9666c09c5739fb32f |
Hashes for bt-1.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f413268e7fc3decf51e0514674e9bc83018ce4efb5617756cb1598fda7bd04d3 |
|
MD5 | 1b0b2bfd12bf1564d727a80979c4b8e5 |
|
BLAKE2b-256 | 54a6e47ee31dcb9e7c8524507e7d3aa1571feeeb97ba1feca6a9624c63e2f054 |
Hashes for bt-1.1.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba77e767d64a5aa7dd7a31849678937f930a27fc8a645a07e6c1d260709c9ebc |
|
MD5 | 9f942a51703b1a2a007673ef049d32e6 |
|
BLAKE2b-256 | 12b62ddcb1003fc1795fa7feaf1ecdfbcf877934889c67af5865c66fa2dc9715 |
Hashes for bt-1.1.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2541e612674ba681a5ac87e3e464f91e2ed8e9f95cc6d1048790d651d19a7c47 |
|
MD5 | dbfea8f116fe3a2c43061b3c8e64ae69 |
|
BLAKE2b-256 | e1e091d31b227e291dcb3a5cb0037eabb65e4d66f38d3f8b30e5c715229d5cf3 |
Hashes for bt-1.1.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 505e60bd4c938376371c457ffaab22346a9c64e4c10b22aba8359489595745d4 |
|
MD5 | ddeb62d396517d388a461f4a32846004 |
|
BLAKE2b-256 | 8530111cf8563bb50be07ca6456d5763db53e9be504c4e60c0f8edc87c86fefd |
Hashes for bt-1.1.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf7594020059dadcc56a86d00bd4121bbd7140815226d6e7c5ad004643aaea6d |
|
MD5 | 5cad3cbcd6b011f9e2acfde83fbc5dc1 |
|
BLAKE2b-256 | 543b0d2ca3e5917c2a21f9879f76baa09320a61382c0e053dfb0a6933e809dba |
Hashes for bt-1.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9434aa113f4863ebcac8e1ac5752dfc27fb0747ebb3ad6399059777e5594ca9e |
|
MD5 | 7594200de6b970630ae82f3c49c223ba |
|
BLAKE2b-256 | 1c4cffd5fcbf0b0ae17541d233dc652dde66aa4509458546dcac16c7f2f82423 |
Hashes for bt-1.1.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b7dbbbe828e17aff2396b1534f09832b0cdef39bac44cc47f54a247731de9fb |
|
MD5 | d08ceb0d66716aa819b53d65bc83a34e |
|
BLAKE2b-256 | 2fb29295fd029b6f4d9a91b7c7259db614c2f3e7e4b391a2cb8cf91f6b9decd7 |
Hashes for bt-1.1.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f8da0412bbd027b41c6cf40ab13f52e176ba777e513acec1a6f8fc521eb30bee |
|
MD5 | 186effbfcf96ec9ca6cc1ddc4d036502 |
|
BLAKE2b-256 | eb981b070d1065e74efd71b910fe4cd8a222b40398fd78652bb555f8df92d4dd |
Hashes for bt-1.1.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7905b78ed3bca28ca925d8b007a3367f219a03db26aa5efc0681720f5abf846 |
|
MD5 | 1941c59ae0df004909c519879541470d |
|
BLAKE2b-256 | 9fd3a1a29260718b9e03888f4ce90f85ff7f94d1f32ea5a02bf8c88b47aa30e0 |
Hashes for bt-1.1.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b428c71dacd1f0846a417f8dd676b35327961490c011f6fceca2fcaff86959ce |
|
MD5 | 19b17a058d33b5bf0032ffa8a4f63826 |
|
BLAKE2b-256 | 525d127e382da1d8e80bb25a3fb3fe4644e2d5ab705f787ed498b8cae94feab1 |
Hashes for bt-1.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 024580de11e5c84781704336465dc1b25b84db55a904d896b494672f0a58415a |
|
MD5 | c5123c15c83855577a9f1335bec3174e |
|
BLAKE2b-256 | 840aaef91db70af5701524c58f2abd6e089cfe1c78f701fc70fa095b8cde6ece |
Hashes for bt-1.1.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9dc1b7678c9604f4c04aed18719e713da83e3375c90e8bc9f349349e3490cb20 |
|
MD5 | 27a61c897312c48df6337898bd52edae |
|
BLAKE2b-256 | 61e9bc5cf27a710a7b3868f0c0211c7e9b8de25e387bf2d3d33754c52df6ace9 |
Hashes for bt-1.1.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a49fec8db3a4e8618c2a7e56dfdef73b460a089b386d5ea06cd5d2640249d20 |
|
MD5 | 2728f1e5df19067b1922125a57ed60ce |
|
BLAKE2b-256 | af468c34ecce5ab57807a302c1711808874baf7445acb35e4d6038ff683aa08f |
Hashes for bt-1.1.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cda40df04ceaef2d82b6fba7853f46b323e1499a7f6723886a06b7ddf691217c |
|
MD5 | 270935c0d20d4bb85d8555a27af77062 |
|
BLAKE2b-256 | 752d568aceb1f7ccaede26ee3ff16a7fde7959c04e62157eb9be25119ef2f1e2 |
Hashes for bt-1.1.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4407e48b032511eacf1d06fe7f21170ff4e4fca10a58a214c57011e39a7c0d77 |
|
MD5 | 961e8f1a04f3a933a828c49094b64d88 |
|
BLAKE2b-256 | 37ee96b2e2552601e155e1ae24eceda76f3217b54d291eb9fe90d6ace2ceb02f |
Hashes for bt-1.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83c6fd60460b10770f7276e7b357006c8e0ede6cf20b80bc6b6a9ded52ae6001 |
|
MD5 | 40b6e16ae8b17e1d9386320e6dfdb930 |
|
BLAKE2b-256 | 65b8a3ab409a9816bbf10d3b558a6c2295d764e6dd14b0ae271e24da7dae602c |
Hashes for bt-1.1.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 39bbe9bce850d9994c57b1c4e35c31142cc88faf1b521d05b06c91cc925e0e77 |
|
MD5 | ad3524c534794fd1d03a3e3c53016b5c |
|
BLAKE2b-256 | 6c6ea7e68c782679f95388cfc238c52974a2e9af313bfe5e7efe8ade765928b6 |
Hashes for bt-1.1.0-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3cb2a1f500dd92146e730a5564624fd1143be5b9330140e18d5d6845f8f48543 |
|
MD5 | 082919ab6ef216ab72f67467739d44fe |
|
BLAKE2b-256 | 81fe015d81dffaa99d5b6b88250f009f9235a8ab805753a35adeaca6b2b00622 |
Hashes for bt-1.1.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16e402f30840de7b936948e59dfe0a6b33a198bda2a9a3ed98eef6e18ca8c68d |
|
MD5 | 5354dc79ec5ece4ccfd1737b9b169acc |
|
BLAKE2b-256 | a980e0bd1d4e40648811523d59bee906fa88da372b3da5152cc8e58d9aec5eab |