Skip to main content

CryptoLion back‑testing library

Project description

CI PyPI version

CryptoLion Backtester

A lightweight command‑line tool for backtesting cryptocurrency strategies, optimizing parameters, walk‑forward validation, and portfolio aggregation.

Installation

pip install -r requirements.txt
pip install cryptolion-backtester

Usage

Show help and available commands:

backtester --help

Run a backtest:

backtester backtest \
  --file data/ETH_USDT_4h.csv \
  --params '{"fast":5,"slow":21,"fee":0.001,"sig":9}' \
  --save-plots

Optimize strategy parameters:

backtester optimize \
  --file data/ETH_USDT_4h.csv \
  --param-grid '{"fast":[5,8],"slow":[21,34]}' \
  --processes 4 \
  --output grid_results.csv

Aggregate multiple symbols into an equal‑weight monthly‑rebalanced portfolio:

backtester portfolio \
  --folder data/ \
  --weight equal \
  --rebalance M \
  --fee 0.001 \
  --slippage 0.0005 \
  --out-file portfolio_equity.csv

Development

Install dev dependencies and run formatting, linting, and tests:

pip install -r requirements.txt black flake8 pytest
black backtester.py tests
flake8 backtester.py tests
pytest -q

License

This project is licensed under the MIT License. See LICENSE for details.

Next Steps

  1. Verify CI Status: Check the GitHub Actions tab to ensure all tests, linting, and formatting checks pass on main and PRs.

  2. Release a new version to PyPI

    If you get a 403 Forbidden during upload it likely means the project name backtester is already taken on PyPI. We've renamed the package to cryptolion-backtester—make sure your metadata matches.

    Update package metadata

    1. Open pyproject.toml and set:
      [project]
      name = "cryptolion-backtester"
      version = "0.1.1"
      # ...
      
    2. Commit and tag:
      git add pyproject.toml
      git commit -m "chore: rename package, bump to v0.1.1"
      git tag v0.1.1
      git push origin main --tags
      

    Clean old build artifacts

    rm -rf dist build cryptolion_backtester-*.egg-info
    

    Build & upload

    pip install --upgrade build twine
    python3 -m build
    twine upload dist/*
    

    Ensure your ~/.pypirc or TWINE_USERNAME/TWINE_PASSWORD points to your valid API token for cryptolion-backtester.

Using this token

To use this API token:

  • Set your username to __token__
  • Set your password to the token value, including the pypi- prefix

For example, in ~/.pypirc:

[pypi]
username = __token__
password =

For further instructions, see the [PyPI help page](https://pypi.org/help/#invalid-auth).

Coverage Status](https://coveralls.io/github//?branch=main)

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

cryptolion-0.1.1.tar.gz (22.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cryptolion-0.1.1-py3-none-any.whl (26.4 kB view details)

Uploaded Python 3

File details

Details for the file cryptolion-0.1.1.tar.gz.

File metadata

  • Download URL: cryptolion-0.1.1.tar.gz
  • Upload date:
  • Size: 22.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.13

File hashes

Hashes for cryptolion-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c4991ca8633486dfdbaff5ed66dfbd93b796fd3302c1a05f302aef6ac5186935
MD5 73d23e9c4aea4d6dd0fb782352cd80df
BLAKE2b-256 f79c3b644d281dd9509090d60604c020b53f9d40fe54c12639c649ef9e4feebe

See more details on using hashes here.

File details

Details for the file cryptolion-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: cryptolion-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 26.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.13

File hashes

Hashes for cryptolion-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 916c3288fc9603646ebb26735bcd9e0ed14edad442ea20c463b51485663805e9
MD5 03cfb47bb29c5b01fb86c7b239be0263
BLAKE2b-256 f2c5c8d157dc4b270eb91fdba1ec644c91a1531114242d2cb825ac9e0cc41f9c

See more details on using hashes here.

Supported by

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