Skip to main content

Decision-Risk & Robustness Simulator by Allostan Labs

Project description

RiskLabs

Decision-Risk & Robustness Simulator by Allostan Labs

RiskLabs is a Python library designed to help quantitative researchers and portfolio managers evaluate the robustness of their strategies. It goes beyond simple backtesting by subjecting strategies to various "flight path" scenarios, such as historical crashes, volatility spikes, and correlation breakdowns.

Features

  • Scenario Analysis: Simulate strategies under stress conditions (e.g., 2008 Crash, COVID-19 Volatility).
  • Robustness Metrics: Calculate specialized scores based on performance stability across regimes.
  • Regime Detection: Analyze strategy behavior in Bull vs. Bear markets.
  • HTML Reporting: Generate beautiful, standalone HTML dashboards with interactive charts.
  • Privacy-First: Runs entirely locally. No data leaves your machine.

Installation

pip install risklabs

Quick Start

from risklabs.client import create_strategy, analyze

# 1. Define a Strategy
strategy = create_strategy(
    name="My 60/40 Portfolio",
    allocations=[
        {"ticker": "SPY", "weight": 0.6},
        {"ticker": "AGG", "weight": 0.4}
    ]
)

# 2. Run Robustness Analysis
print("Running simulations...")
report = analyze(strategy)

# 3. Generate Report
report.to_file("my_portfolio_report.html")
print("Report generated: my_portfolio_report.html")

Running the Demo

We include a demo simulation script to showcase the library's capabilities:

# Ensure you are in the risklabs directory
python demo_hram.py

This will generate a sample robustness report showing stress tests and regime analysis.

How It Works

  1. Define Strategy: You specify target allocations (static weights for MVP).
  2. Fetch Data: The library automatically downloads historical data for the tickers using yfinance.
  3. Simulate Scenarios: The engine runs multiple simulations:
    • Historical Baseline: Standard backtest.
    • Crash Replay: Applies historical shock factors.
    • Regime Stress: Modifies volatility and correlation matrices.
  4. Score & Report: Aggregates results into a "Robustness Score" and renders an HTML dashboard.

Architecture & Methodology

RiskLabs is designed as a modular pipeline to ensure rigorous stress testing:

  1. Client Layer (risklabs.client):
    • The entry point for users. Accepts a concise human-readable Strategy definition and orchestrates the analysis.
  2. Simulation Engine (risklabs.engine):
    • The core "brain" of the system. It doesn't just run a single backtest; it executes a battery of tests including Historical Replays (e.g., 2008 Crisis), Monte Carlo Perturbations (Fragility), and Parameter Sweeps (Sensitivity).
  3. Analyzers:
    • RegimeDetectionEngine: Classifies market history into 4 regimes (Bull/Bear x High/Low Vol).
    • FragilityAnalyzer: Tests "what if my weights were slightly different?" to catch overfitting.
    • DecisionEngine: Aggregates all metrics into a final Confidence Rating and Recommendation (APPROVE/REJECT).
  4. Reporting (risklabs.reporting):
    • Compiles the rich data into an interactive, standalone HTML dashboard with no external dependencies.

License

MIT

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

risklabs-0.2.3.tar.gz (44.2 kB view details)

Uploaded Source

Built Distribution

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

risklabs-0.2.3-py3-none-any.whl (23.1 kB view details)

Uploaded Python 3

File details

Details for the file risklabs-0.2.3.tar.gz.

File metadata

  • Download URL: risklabs-0.2.3.tar.gz
  • Upload date:
  • Size: 44.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for risklabs-0.2.3.tar.gz
Algorithm Hash digest
SHA256 2491ee9a628f45e7c5186f5448040a6f9d9a85c4924d72e4f1157099175e4319
MD5 9936c055166e307f537e3cfbb246f3fd
BLAKE2b-256 7d8451e3593fe371be181027e3871209e11ea0b5cfcc2d48b5f3950749bcafb6

See more details on using hashes here.

File details

Details for the file risklabs-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: risklabs-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 23.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for risklabs-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4cd303d4478963716f953867b4e57827fcd31a503933910aa158c8f7faff6ce7
MD5 22a020015687ce23fa9f4aeb974bd0b5
BLAKE2b-256 10de66ae64db8d140cfd0e4c9b6e36e13061a77d74553f49c6f35ccf2aad71aa

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