Skip to content

Commit

Permalink
Merge pull request #426 from timkpaine/tkp/pkg
Browse files Browse the repository at this point in the history
Uplift packaging for 2023, move to rust, rework ci scripts
  • Loading branch information
timkpaine authored Nov 20, 2023
2 parents 51ec0c0 + c737843 commit 2581278
Show file tree
Hide file tree
Showing 15 changed files with 143 additions and 339 deletions.
15 changes: 0 additions & 15 deletions .coveragerc

This file was deleted.

12 changes: 4 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:

strategy:
matrix:
python-version: [3.9]
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.8, 3.9, '3.10', 3.11]

steps:
- uses: actions/checkout@v4
Expand All @@ -36,17 +36,13 @@ jobs:
python -m pip install -U wheel twine setuptools
- name: Lint
run: |
make lint
run: make lint

- name: Test
run: |
make test
run: make test

- name: Coverage
uses: codecov/codecov-action@v3

- name: Package and check
run: |
python setup.py sdist bdist_wheel
python -m twine check dist/*
run: make dist
19 changes: 6 additions & 13 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Deploy

on:
on:
push:
tags:
- 'v*'
Expand All @@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.7, 3.8, 3.9]
python-version: [3.8, 3.9, '3.10', 3.11]

steps:
- uses: actions/checkout@v4
Expand All @@ -28,24 +28,17 @@ jobs:
python -m pip install -U wheel twine setuptools
- name: Lint
run: |
make lint
run: make lint

- name: Test
run: |
make test
run: make test

- name: Package and check
run: |
python setup.py sdist bdist_wheel
python -m twine check dist/*
run: make dist

- name: Publish distribution 📦 to PyPI
if: ${{ startsWith(github.ref, 'refs/tags') && matrix.os != 'ubuntu-latest' }}
env:
TWINE_USERNAME: ${{ secrets.PYPI_UN }}
TWINE_PASSWORD: ${{ secrets.PYPI_PW }}
run: |
python -m twine upload dist/* --skip-existing || echo "Failed to deploy"
run: make upload
File renamed without changes.
23 changes: 12 additions & 11 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
graft bt
graft ffn
include LICENSE
include README.md
include pyproject.toml

include LICENSE.txt
include README.rst
include setup.py
prune docs
prune tests

graft docs
prune docs/build

global-exclude *.so
global-exclude *.pyd
# Patterns to exclude from any directory
global-exclude *~
global-exclude *.pyc
global-exclude .git*
global-exclude .DS_Store
global-exclude *.pyo
global-exclude .git
global-exclude .ipynb_checkpoints
global-exclude .mypy_cache
global-exclude .DS_Store
13 changes: 7 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,23 @@ test:
python -m pytest -vvv tests --cov=bt --junitxml=python_junit.xml --cov-report=xml --cov-branch --cov-report term

lint:
python -m flake8 bt setup.py docs/source/conf.py
python -m ruff bt setup.py docs/source/conf.py

fix:
python -m black bt setup.py docs/source/conf.py
python -m ruff format bt setup.py docs/source/conf.py

dist:
python setup.py sdist
python setup.py sdist bdist_wheel
python -m twine check dist/*

upload: clean dist
twine upload dist/*
python -m twine upload dist/* --skip-existing

docs:
docs:
$(MAKE) -C docs/ clean
$(MAKE) -C docs/ html

pages:
pages:
rm -rf $(TMPREPO)
git clone -b gh-pages git@github.com:pmorissette/bt.git $(TMPREPO)
rm -rf $(TMPREPO)/*
Expand Down
93 changes: 36 additions & 57 deletions README.rst → README.md
Original file line number Diff line number Diff line change
@@ -1,75 +1,59 @@
.. image:: http://pmorissette.github.io/bt/_static/logo.png
![](http://pmorissette.github.io/bt/_static/logo.png)

.. image:: https://github.com/pmorissette/bt/workflows/Build%20Status/badge.svg
:target: https://github.com/pmorissette/bt/actions/
[![Build Status](https://github.com/pmorissette/bt/workflows/Build%20Status/badge.svg)](https://github.com/pmorissette/bt/actions/)
[![Codecov](https://codecov.io/gh/pmorissette/bt/branch/master/graph/badge.svg)](https://codecov.io/pmorissette/bt)
[![PyPI Version](https://img.shields.io/pypi/v/bt)](https://pypi.org/project/bt/)
[![PyPI License](https://img.shields.io/pypi/l/bt)](https://pypi.org/project/bt/)

.. image:: https://codecov.io/gh/pmorissette/bt/branch/master/graph/badge.svg
:target: https://codecov.io/pmorissette/bt

.. image:: https://img.shields.io/pypi/v/bt
:alt: PyPI
:target: https://pypi.org/project/bt/

.. image:: https://img.shields.io/pypi/l/bt
:alt: PyPI - License
:target: https://pypi.org/project/bt/

bt - Flexible Backtesting for Python
====================================
# 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?
-----------
## 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 <http://pmorissette.github.io/bt/bt.html#bt.core.Algo>`_. 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.
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](http://pmorissette.github.io/bt/bt.html#bt.core.Algo). 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
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.
**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 <https://github.com/pmorissette/ffn>`_ - a financial function library for Python. Check it out!
bt is built atop [ffn](https://github.com/pmorissette/ffn) - a financial function library for Python. Check it out!

Features
---------
## Features

* **Tree Structure**
`The tree structure <http://pmorissette.github.io/bt/tree.html>`_ facilitates the construction and composition of complex algorithmic trading
strategies that are modular and re-usable. Furthermore, each tree `Node
<http://pmorissette.github.io/bt/bt.html#bt.core.Node>`_
has its own price index that can be
used by Algos to determine a Node's allocation.
[The tree structure](http://pmorissette.github.io/bt/tree.html) facilitates the construction and composition of complex algorithmic trading
strategies that are modular and re-usable. Furthermore, each tree [Node](http://pmorissette.github.io/bt/bt.html#bt.core.Node) has its own
price index that can be used by Algos to determine a Node's allocation.

* **Algorithm Stacks**
`Algos <http://pmorissette.github.io/bt/bt.html#bt.core.Algo>`_ and `AlgoStacks <http://pmorissette.github.io/bt/bt.html#bt.core.AlgoStack>`_ are
[Algos](http://pmorissette.github.io/bt/bt.html#bt.core.Algo) and [AlgoStacks](http://pmorissette.github.io/bt/bt.html#bt.core.AlgoStack) 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,
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'
<http://pmorissette.github.io/bt/bt.html#bt.backtest.Result>`_ display methods.
these various statistics across many different backtests via [Results](http://pmorissette.github.io/bt/bt.html#bt.backtest.Result) display methods.


Roadmap
--------
## Roadmap

Future development efforts will focus on:

Expand All @@ -87,30 +71,25 @@ Future development efforts will focus 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 <https://pypi.python.org/pypi/bt/>`_
using ``pip`` or ``easy_install``:
## Installing bt

.. code-block:: bash
The easiest way to install `bt` is from the [Python Package Index](https://pypi.python.org/pypi/bt/)
using `pip`:

$ pip install bt
```bash
pip install bt
```

Since bt has many dependencies, we strongly recommend installing the `Anaconda Scientific Python
Distribution <https://store.continuum.io/cshop/anaconda/>`_, 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.

bt should be compatible with Python 2.7 and Python 3 thanks to the contributions
made by fellow users.
Since bt has many dependencies, we strongly recommend installing the [Anaconda Scientific Python
Distribution](https://store.continuum.io/cshop/anaconda/), 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
-----------------
## Recommended Setup

We believe the best environment to develop with bt is the `IPython Notebook
<http://ipython.org/notebook.html>`__. From their homepage, the IPython Notebook
is:
We believe the best environment to develop with bt is the [IPython Notebook](http://ipython.org/notebook.html).
From their homepage, the IPython Notebook is:

"[...] a web-based interactive computational environment
where you can combine code execution, text, mathematics, plots and rich
Expand Down
2 changes: 1 addition & 1 deletion bt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
import ffn
from ffn import utils, data, get, merge

__version__ = (0, 2, 10)
__version__ = "1.0.0"
Loading

0 comments on commit 2581278

Please sign in to comment.