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. Imbet.
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.
The package includes:
- A fully interactive Streamlit-based user interface (UI).
- Support for multiple asset classes (stocks, commodities, FX, fixed income, etc.).
- Customizable backtesting parameters and risk management tools.
- Pre-processing capabilities for data compatibility across all time zones.
Installation
You can install the package via pip:
$ pip install pybacktestchain-ev
Features
- Interactive UI: A Streamlit-based interface for configuring backtests, visualizing results, and analyzing performance and risk metrics.
- Portfolio Backtesting: Supports backtesting of standard trading strategies:
- Equal Weight
- Minimum Variance
- Maximum Sharpe Ratio
- 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.
- Computes Value-at-Risk (VaR) and Expected Shortfall (ES) with user-defined confidence levels.
- Pre-Processing:
- Handles data across various asset classes and ensures compatibility across time zones.
- Blockchain Integration: Stores backtest results in a tamper-proof blockchain for future reference.
Usage
Running the Streamlit Interface
To start the Streamlit interface:
$ streamlit run <your_app_file>.py
Configuring a Backtest
- Select Tickers: Enter assets' tickers (comma-separated) to define the universe (supports all asset classes).
- Set Parameters:
- Initial cash amount.
- Start and end dates for the backtest.
- Choose a strategy:
- Equal Weight
- Minimum Variance
- Maximum Sharpe Ratio
- Risk Parity
- Configure risk management:
- Stop-loss and take-profit thresholds.
- Transaction costs.
- Confidence levels for VaR and Expected Shortfall.
- Run the Backtest: Click the "Run Backtest" button.
Viewing Results
- Summary Statistics: Includes key metrics for the backtested portfolio.
- Visualizations:
- Portfolio value and returns over time.
- Distribution of returns.
- Correlation heatmap of asset returns.
- Risk Metrics: Displays VaR and Expected Shortfall with selected confidence levels.
- Transaction Log: Provides detailed insights into executed trades.
- Blockchain Storage: Saves each backtest under a randomly generated name for future reference.
Blockchain Storage
Each backtest is saved in a blockchain file 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
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 Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pybacktestchain_ev-0.1.2.tar.gz.
File metadata
- Download URL: pybacktestchain_ev-0.1.2.tar.gz
- Upload date:
- Size: 11.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
976a5bb159fed6e20b264da227e541eaba886f4da75ad362a578c7e4c1035bd8
|
|
| MD5 |
2629b3338bd03b49f44f9675b98be74e
|
|
| BLAKE2b-256 |
d2f64651eed34ab8e5fec15b6b8ef948fcfc18e00bbb88ec1be2ec9ef28bd196
|
File details
Details for the file pybacktestchain_ev-0.1.2-py3-none-any.whl.
File metadata
- Download URL: pybacktestchain_ev-0.1.2-py3-none-any.whl
- Upload date:
- Size: 13.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5bf4eb1d7a7e20d4899813ca41985b8f2cea339dfc26342e69d594c3fa49fef
|
|
| MD5 |
1308c1c0475b1a68a3d11130498abad8
|
|
| BLAKE2b-256 |
fa4b0d97b57673839232b24c1549602a4c6905bd9207fdbac068a4dfcbc1ad22
|