diff --git a/.github/deploy-gh-pages.sh b/.github/deploy-gh-pages.sh old mode 100644 new mode 100755 index bc7d3536..87b4b10a --- a/.github/deploy-gh-pages.sh +++ b/.github/deploy-gh-pages.sh @@ -20,7 +20,7 @@ sitemap() { head=$(git rev-parse HEAD) -git clone -b gh-pages "https://kernc:$GH_PASSWORD@github.com/$TRAVIS_REPO_SLUG.git" gh-pages +git clone -b gh-pages "https://kernc:$GH_PASSWORD@github.com/$GITHUB_REPOSITORY.git" gh-pages mkdir -p gh-pages/doc cp -R doc/build/* gh-pages/doc/ cd gh-pages @@ -30,5 +30,11 @@ if git diff --staged --quiet; then echo "$0: No changes to commit." exit 0 fi -git commit -a -m "CI: Update docs for $TRAVIS_TAG ($head)" + +if ! git config user.name; then + git config user.name 'github-actions' + git config user.email '41898282+github-actions[bot]@users.noreply.github.com' +fi + +git commit -a -m "CI: Update docs for ${GITHUB_REF#refs/tags/} ($head)" git push diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..53dacbd5 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,69 @@ +name: CI +on: + push: { branches: [master] } + pull_request: { branches: [master] } + schedule: [ cron: '2 2 * * 6' ] # Every Saturday, 02:02 + +jobs: + build: + name: Build + runs-on: ubuntu-18.04 + + strategy: + matrix: + python-version: [3.6, 3.7] + include: + - python-version: 3.8 + test-type: lint + - python-version: 3.8 + test-type: docs + + steps: + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - uses: actions/cache@v2 + name: Set up caches + with: + path: ~/.cache/pip + key: ${{ runner.os }}-py${{ matrix.python-version }} + + - name: Checkout repo + uses: actions/checkout@v2 + with: + fetch-depth: 3 + - name: Fetch tags + run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* + + - name: Install dependencies + run: | + pip install -U pip setuptools wheel + pip install -U --pre .[test] + + - name: Install lint dependencies + if: matrix.test-type == 'lint' + run: pip install -U .[dev] + + - name: Install docs dependencies + if: matrix.test-type == 'docs' + run: pip install -e .[doc,test] # -e provides _version.py for pdoc + + - name: Test w/ Coverage, Lint + if: matrix.test-type == 'lint' + env: { BOKEH_BROWSER: none } + run: | + flake8 + mypy backtesting + time catchsegv coverage run -m backtesting.test + bash <(curl -s https://codecov.io/bash) + + - name: Test + if: '! matrix.test-type' + env: { BOKEH_BROWSER: none } + run: time catchsegv python -m backtesting.test + + - name: Test docs + if: matrix.test-type == 'docs' + run: time catchsegv doc/build.sh diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml new file mode 100644 index 00000000..7925fb16 --- /dev/null +++ b/.github/workflows/deploy-docs.yml @@ -0,0 +1,41 @@ +name: Deploy docs +on: + push: + tags: ['[0-9]+.[0-9]+.*'] + +jobs: + deploy: + name: Deploy + runs-on: ubuntu-latest + + steps: + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.8 + + - uses: actions/cache@v2 + name: Set up caches + with: + path: ~/.cache/pip + key: ${{ runner.os }} + + - name: Checkout repo + uses: actions/checkout@v2 + with: + fetch-depth: 3 + - name: Fetch tags + run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* + + - name: Install dependencies + run: | + pip install -U pip setuptools wheel + pip install -U .[doc,test] + + - name: Build docs + run: time catchsegv doc/build.sh + + - name: Deploy docs + env: + GH_PASSWORD: ${{ secrets.GITHUB_TOKEN }} + run: .github/deploy-gh-pages.sh diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 1ea4b97e..00000000 --- a/.travis.yml +++ /dev/null @@ -1,49 +0,0 @@ -os: linux -language: python -dist: bionic -cache: - pip: true -branches: - only: - - master - # Tags - - /^(\d+\.)+\d+(\.\S+)?$/ - -jobs: - fast_finish: true - include: - - python: '3.5' - - python: '3.7' - before_install: - - pip uninstall -y numpy # Avoid https://travis-ci.org/github/kernc/backtesting.py/jobs/704292730 - - - python: '3.8' - name: 'Lint, Test w/ Coverage' - before_script: - - pip install flake8 coverage mypy - script: - - flake8 - - mypy backtesting - - BOKEH_BROWSER=none catchsegv coverage run -m backtesting.test - after_success: - - bash <(curl -s https://codecov.io/bash) - - - python: '3.8' - name: 'Docs' - stage: deploy - install: - - pip install -e .[doc,test] - script: - - doc/build.sh - after_success: - - if [ "$TRAVIS_BRANCH" = "$TRAVIS_TAG" ]; then bash .github/deploy-gh-pages.sh; fi - -before_install: - - set -e - -install: - - pip install -U pip setuptools - - pip install -U --pre .[test] - -script: - - BOKEH_BROWSER=none time catchsegv python -m backtesting.test diff --git a/README.md b/README.md index b791af4e..36387e22 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Backtesting.py ============== -[![Build Status](https://img.shields.io/travis/kernc/backtesting.py.svg?style=for-the-badge)](https://travis-ci.org/kernc/backtesting.py) +[![Build Status](https://img.shields.io/github/workflow/status/kernc/backtesting.py/ci/master?style=for-the-badge)](https://github.com/kernc/backtesting.py/actions) [![Code Coverage](https://img.shields.io/codecov/c/gh/kernc/backtesting.py.svg?style=for-the-badge)](https://codecov.io/gh/kernc/backtesting.py) [![Backtesting on PyPI](https://img.shields.io/pypi/v/backtesting.svg?color=blue&style=for-the-badge)](https://pypi.org/project/backtesting) diff --git a/backtesting/__init__.py b/backtesting/__init__.py index 7d7ac1ba..7a0c8072 100644 --- a/backtesting/__init__.py +++ b/backtesting/__init__.py @@ -48,7 +48,7 @@ try: from ._version import version as __version__ # noqa: F401 except ImportError: - pass # Package not installed + __version__ = '?.?.?' # Package not installed from .backtesting import Backtest, Strategy # noqa: F401 from . import lib # noqa: F401 diff --git a/doc/examples/Quick Start User Guide.ipynb b/doc/examples/Quick Start User Guide.ipynb index 97470644..8516be34 100644 --- a/doc/examples/Quick Start User Guide.ipynb +++ b/doc/examples/Quick Start User Guide.ipynb @@ -9,7 +9,7 @@ "\n", "This tutorial shows some of the features of *backtesting.py*, a Python framework for [backtesting](https://www.investopedia.com/terms/b/backtesting.asp) trading strategies.\n", "\n", - "_Backtesting.py_ is a small and lightweight, blazing fast backtesting framework that uses state-of-the-art Python structures and procedures (Python 3.5+, Pandas, NumPy, Bokeh). It has a very small and simple API that is easy to remember and quickly shape towards meaningful results. The library _doesn't_ really support stock picking or trading strategies that rely on arbitrage or multi-asset portfolio rebalancing; instead, it works with an individual tradeable asset at a time and is best suited for optimizing position entrance and exit signal strategies, decisions upon values of technical indicators, and it's also a versatile interactive trade visualization and statistics tool.\n", + "_Backtesting.py_ is a small and lightweight, blazing fast backtesting framework that uses state-of-the-art Python structures and procedures (Python 3.6+, Pandas, NumPy, Bokeh). It has a very small and simple API that is easy to remember and quickly shape towards meaningful results. The library _doesn't_ really support stock picking or trading strategies that rely on arbitrage or multi-asset portfolio rebalancing; instead, it works with an individual tradeable asset at a time and is best suited for optimizing position entrance and exit signal strategies, decisions upon values of technical indicators, and it's also a versatile interactive trade visualization and statistics tool.\n", "\n", "\n", "## Data\n", diff --git a/doc/examples/Quick Start User Guide.py b/doc/examples/Quick Start User Guide.py index 1a5963fa..b2a015cc 100644 --- a/doc/examples/Quick Start User Guide.py +++ b/doc/examples/Quick Start User Guide.py @@ -18,7 +18,7 @@ # # This tutorial shows some of the features of *backtesting.py*, a Python framework for [backtesting](https://www.investopedia.com/terms/b/backtesting.asp) trading strategies. # -# _Backtesting.py_ is a small and lightweight, blazing fast backtesting framework that uses state-of-the-art Python structures and procedures (Python 3.5+, Pandas, NumPy, Bokeh). It has a very small and simple API that is easy to remember and quickly shape towards meaningful results. The library _doesn't_ really support stock picking or trading strategies that rely on arbitrage or multi-asset portfolio rebalancing; instead, it works with an individual tradeable asset at a time and is best suited for optimizing position entrance and exit signal strategies, decisions upon values of technical indicators, and it's also a versatile interactive trade visualization and statistics tool. +# _Backtesting.py_ is a small and lightweight, blazing fast backtesting framework that uses state-of-the-art Python structures and procedures (Python 3.6+, Pandas, NumPy, Bokeh). It has a very small and simple API that is easy to remember and quickly shape towards meaningful results. The library _doesn't_ really support stock picking or trading strategies that rely on arbitrage or multi-asset portfolio rebalancing; instead, it works with an individual tradeable asset at a time and is best suited for optimizing position entrance and exit signal strategies, decisions upon values of technical indicators, and it's also a versatile interactive trade visualization and statistics tool. # # # ## Data diff --git a/setup.py b/setup.py index d2f277db..32f2f879 100644 --- a/setup.py +++ b/setup.py @@ -1,8 +1,8 @@ import os import sys -if sys.version_info < (3, 4): - sys.exit('ERROR: Backtesting.py requires Python 3.4+') +if sys.version_info < (3, 6): + sys.exit('ERROR: Backtesting.py requires Python 3.6+') if __name__ == '__main__': @@ -31,7 +31,6 @@ 'write_to': os.path.join('backtesting', '_version.py'), }, install_requires=[ - 'typing ; python_version < "3.5"', 'numpy', 'pandas >= 0.25.0, != 0.25.0', 'bokeh >= 1.4.0', @@ -51,10 +50,12 @@ ], 'dev': [ 'flake8', + 'coverage', + 'mypy', ], }, test_suite="backtesting.test", - python_requires='>=3.4', + python_requires='>=3.6', author='Zach Lûster', classifiers=[ 'Intended Audience :: Financial and Insurance Industry',