Portfolio Risk & Rebalancing Lab
General-purpose portfolio optimization and uncertainty-aware risk budgeting for portfolio-manager decision support.
Interactive PM decision workspace · GitHub source · Issues · MIT license and notices
Portfolio Risk Lab provides a general-purpose NumPy, pandas and SciPy API and CLI to compare conventional long-only portfolios with scenario-robust risk budgeting.
Quick start
pip install portfolio-risk-lab
portfolio-risk-lab demo --output sample.json
import pandas as pd
from portfolio_risk_lab import PortfolioAnalyzer, RiskConfig
daily_returns = pd.read_csv(
"daily_returns.csv", parse_dates=["date"]
).set_index("date")
model = PortfolioAnalyzer(
daily_returns,
config=RiskConfig(
risk_budget=0.12,
max_weight=0.40,
cash_asset="Cash_Proxy",
transaction_cost_bps=10,
),
)
result = model.compare(
methods=["standard", "scenario_robust"],
uncertainty="historical_calibration",
)
print(result.allocation_comparison)
print(result.risk_budget_analysis)
Input values are daily simple decimal returns; 0.01 denotes +1%, not a price level. At least 504 daily rows are required by default.
Features
- Standard and scenario-robust mean–variance optimization with hard long-only, fully invested position and risk constraints.
- Annualized long-window, short-window and EWMA covariance forecasts.
- Historical risk-error margin using exclusively matured, completed calendar months.
- Asset-weight comparisons, model disagreement, risk contributions, one-time trade-cost estimates, and JSON output.
- Data-source agnostic API/CLI, without broker accounts, order execution or Streamlit.
Research boundaries
The library is intended for research and decision support, not trading signals or investment advice. Historical reference-portfolio error quantiles do not guarantee future risk-limit coverage. Exploratory backtests did not establish a persistent increase in economic utility over simply tighter conventional risk limits.
The GitHub Pages decision workspace is a separate browser-only JavaScript approximation using simulated portfolio data. It is not the SciPy solver and does not retrieve live market prices.
The MIT license grants rights to newly authored Portfolio Risk Lab code. Historic third-party files in the GitHub repository are not bundled into the Python distribution and are explicitly excluded from the new-code license grant.
Metadata
Release files for portfolio-risk-lab 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| portfolio_risk_lab-0.1.0.tar.gz | 18.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| portfolio_risk_lab-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 35.0 kB
Release files / portfolio_risk_lab-0.1.0.tar.gz
| Download URL | portfolio_risk_lab-0.1.0.tar.gz |
|---|---|
| Size | 18.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
15c08b474f3b483fe2faa29caad19ad914653747074b8a4de66ea83f9d381693
|
|
BLAKE2b-256 checksum How to use checksums |
86b49b9e691a8a4587cb5c93318dc5d2b53a1d6dee2c1fc9c483038098532789
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.
Transparency logRelease files / portfolio_risk_lab-0.1.0-py3-none-any.whl
| Download URL | portfolio_risk_lab-0.1.0-py3-none-any.whl |
|---|---|
| Size | 16.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
baab58f934002d7126d79f7dba5f9c15e17d4032288a6a9248cbb0a49125da7e
|
|
BLAKE2b-256 checksum How to use checksums |
81c2ee78df76a1724cebaaeb589275756028a74ae41c85676f33a91740bde19c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.
Transparency log