Skip to main content

Improved pybacktestchain library with interactive UI and features added (risk measures, trading strategies, multiple asset classes)

Project description

pybacktestchain-ev

Package for the Python Course based on pybacktestchain library by J. Imbett.

Overview

pybacktestchain-ev is a Python package designed to facilitate portfolio backtesting using various trading strategies. The package incorporates risk management tools, blockchain-based backtest storage, and a user-friendly interface built with Streamlit.

Installation

You can install the package via pip:

$ pip install pybacktestchain-ev

Features

  • Interactive UI: A Streamlit-based interactive interface for configuring backtests, visualizing results, analyzing performance and risk metrics.
  • Portfolio Backtesting: Supports backtesting of standard trading strategies such as Equal Weight, Minimum Variance, Maximum Sharpe Ratio, and Risk Parity.
  • Customizable Transaction Costs: Allows precise configuration of trading fees for realistic simulations.
  • Risk Management: Includes stop-loss and take-profit mechanisms with customizable thresholds, as well as Value-at-Risk (VaR) and Expected Shortfall for the backtested portfolio.
  • Blockchain Integration: Stores backtest results in a blockchain.

Usage

Running the Streamlit Interface

To start the Streamlit interface:

$ streamlit run <your_app_file>.py

Configuring a Backtest

  1. Select Tickers: Enter stock tickers (comma-separated) to define the universe (works across all asset classes).
  2. Set Parameters:
    • Initial cash amount.
    • Start and end dates for the backtest.
    • Choose a strategy: Equal Weight, Minimum Variance, Maximum Sharpe Ratio, or Risk Parity.
    • Configure risk management: Stop-loss, take-profit percentages, and transaction costs.
  3. Run the Backtest: Click the "Run Backtest" button.

Viewing Results

  • Portfolio value and returns are displayed over time, as well as the distribution of returns.
  • Risk metrics, such as Value-at-Risk (VaR) and Expected Shortfall (ES), are calculated.
  • A transaction log is provided for detailed insights and store to the blockchain.
  • Additional visualizations include correlation heatmaps and return distributions.

Blockchain Storage

Each backtest is saved in a blockchain under a randomly generated name. This ensures results are tamper-proof and can be referenced later. Blockchain files are stored in the blockchain/ directory within the package folder.

Contributing

Interested in contributing? Check out the contributing guidelines. Please note that this project is released with a Code of Conduct. By contributing to this project, you agree to abide by its terms.

License

pybacktestchain-ev was created by Enzo Volpato. It is licensed under the terms of the MIT license.

Credits

pybacktestchain-ev was created with cookiecutter and the py-pkgs-cookiecutter template.

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

pybacktestchain_ev-0.1.1.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

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

pybacktestchain_ev-0.1.1-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pybacktestchain_ev-0.1.1.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.10

File hashes

Hashes for pybacktestchain_ev-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3429744367c0d8dacfb3b79cf5707dfa5950216f65f797f594170db580661d6a
MD5 006a4aa8ef46b5441bb242cb01fc7c80
BLAKE2b-256 194a52bc689be741aba8500a0e2ae96ccb3c99647f5160a0011333c005f21cfc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pybacktestchain_ev-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2fcbffdee2d3690a62ed6b3031eec0dc8e18f67aa5e6cf225fb060b3cce5f101
MD5 5d5e6b17fecf4d8f3f303ae7578a0fb1
BLAKE2b-256 f7c9c07498486a5ccd921ff18a1636f4d7cd83bd847d070463bd402cc13a5c19

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