Skip to main content

Alpha Risk Kit

Python Version License

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 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.

Metadata

Release files for alpha-risk-kit 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for alpha-risk-kit 0.1.0
File Size Uploaded Provenance
alpha_risk_kit-0.1.0.tar.gz 476.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for alpha-risk-kit 0.1.0
File Interpreter ABI Platform
alpha_risk_kit-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 523.8 kB

Release files / alpha_risk_kit-0.1.0.tar.gz

Download URL alpha_risk_kit-0.1.0.tar.gz
Size 476.5 kB
Tags Source
SHA-256 checksum
How to use checksums
22e1a30b066b68278ea5352eccd519defce8865bafc4bf41a03c11194ac27960
BLAKE2b-256 checksum
How to use checksums
d554908f6176dd282ae08ad16a13cd41b62507c98ff957e2b00f62a0c75b7d17
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / alpha_risk_kit-0.1.0-py3-none-any.whl

Download URL alpha_risk_kit-0.1.0-py3-none-any.whl
Size 47.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c005b321867b2f72f7ee333a5912fec530f04088c81180299e76d66cef04554a
BLAKE2b-256 checksum
How to use checksums
51a50c68e8b003b4cd6ecd928ef24576fe5976d123c0cf054dd5b13ed4433731
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Security for alpha-risk-kit 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page