Portfolio analytics toolkit with interactive widgets for quants - return analysis, drawdown visualization, and benchmark comparison
Project description
Alpha Risk Kit
Portfolio analytics toolkit with interactive widgets for quants
Alpha Risk Kit is a comprehensive Python library for analyzing portfolio returns, inspired by QuantStats and VectorBT. It provides:
- Interactive Widgets: AnyWidget-based components for Jupyter, Marimo, and VS Code
- Static Charts: Matplotlib and Plotly visualizations
- Pandas Accessor: VectorBT-style
returns.ark.stats()pattern - Bilingual Support: English and Chinese (中文) interfaces
Quick Start
uv sync --extra all
uv run jupyter notebook
uv run marimo edit --watch usages/marimo/demo.py
uv run streamlit run usages/streamlit/app.py
import alpha_risk_kit as ark
import pandas as pd
# Your returns data
returns = pd.Series([0.01, -0.02, 0.015, -0.005, 0.02])
# Get comprehensive statistics
returns.ark.stats()
# Create interactive widget
from alpha_risk_kit.widgets import ReturnsWidget
widget = ReturnsWidget(returns=returns)
widget # Display in Jupyter
Installation
# Basic installation
pip install alpha-risk-kit
# With plotting support
pip install alpha-risk-kit[plots]
# All dependencies
pip install alpha-risk-kit[all]
# Development installation
pip install -e ".[all]"
Features
Core Metrics
# Using pandas accessor
returns.ark.sharpe() # Sharpe Ratio
returns.ark.sortino() # Sortino Ratio
returns.ark.max_drawdown() # Maximum Drawdown
returns.ark.calmar() # Calmar Ratio
returns.ark.win_rate() # Win Rate
# With benchmark comparison
returns.ark.stats(benchmark=sp500_returns)
Interactive Widgets
from alpha_risk_kit.widgets import ReturnsWidget, ComparisonWidget, DashboardWidget
# Single strategy analysis
widget = ReturnsWidget(returns=my_returns, benchmark=benchmark)
# Strategy vs benchmark comparison
comparison = ComparisonWidget(returns=strategy, benchmark=benchmark)
# Multi-strategy dashboard
dashboard = DashboardWidget(returns=strategies_df, benchmarks=benchmarks_df)
Static Charts
# Matplotlib
fig = ark.plot_combined(returns, benchmark=benchmark, backend='matplotlib')
# Plotly (interactive)
fig = ark.plot_combined(returns, benchmark=benchmark, backend='plotly')
fig.show()
Bilingual Support
ark.set_language('zh') # Switch to Chinese (中文)
ark.set_language('en') # Switch to English
Widget Gallery
| Widget | Description |
|---|---|
ReturnsWidget |
Cumulative returns + drawdown + key metrics |
ComparisonWidget |
Strategy vs benchmark with excess returns |
DashboardWidget |
Multi-strategy comparison with sortable table |
Platform Support
| Platform | Widgets | Static Charts |
|---|---|---|
| Jupyter Notebook | ✅ | ✅ |
| JupyterLab | ✅ | ✅ |
| VS Code | ✅ | ✅ |
| Marimo | ✅ | ✅ |
| Streamlit | ❌ | ✅ |
| Google Colab | ✅ | ✅ |
Project Structure
alpha-risk-kit/
├── src/alpha_risk_kit/
│ ├── stats.py # Core metrics
│ ├── plots.py # Chart generation
│ ├── accessors.py # Pandas accessor
│ ├── i18n.py # Translations
│ ├── utils.py # Utilities
│ └── widgets/ # AnyWidget components
├── usages/
│ ├── jupyter/ # Jupyter notebook demo
│ ├── streamlit/ # Streamlit app demo
│ └── marimo/ # Marimo notebook demo
└── docs/ # MkDocs documentation
Comparison with Other Tools
| Feature | Alpha Risk Kit | QuantStats | VectorBT |
|---|---|---|---|
| Interactive Widgets | ✅ AnyWidget | ❌ | ❌ |
| Pandas Accessor | ✅ .ark |
❌ | ✅ .vbt |
| Bilingual (EN/ZH) | ✅ | ❌ | ❌ |
| Plotly Charts | ✅ | ✅ | ✅ |
| Matplotlib Charts | ✅ | ✅ | ✅ |
Documentation
Full documentation is available at: https://daviddwlee84.github.io/alpha-risk-kit
Contributing
Contributions are welcome! Please see AGENTS.md for development guidelines.
License
MIT License - see LICENSE for details.
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 alpha_risk_kit-0.1.0.tar.gz.
File metadata
- Download URL: alpha_risk_kit-0.1.0.tar.gz
- Upload date:
- Size: 476.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
22e1a30b066b68278ea5352eccd519defce8865bafc4bf41a03c11194ac27960
|
|
| MD5 |
1229cd70d9434225893a8b9c7afe01bc
|
|
| BLAKE2b-256 |
d554908f6176dd282ae08ad16a13cd41b62507c98ff957e2b00f62a0c75b7d17
|
File details
Details for the file alpha_risk_kit-0.1.0-py3-none-any.whl.
File metadata
- Download URL: alpha_risk_kit-0.1.0-py3-none-any.whl
- Upload date:
- Size: 47.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c005b321867b2f72f7ee333a5912fec530f04088c81180299e76d66cef04554a
|
|
| MD5 |
405622e1d0d442f0c980a6862a002cfd
|
|
| BLAKE2b-256 |
51a50c68e8b003b4cd6ecd928ef24576fe5976d123c0cf054dd5b13ed4433731
|