Skip to content

adifinki/internal-beta

Repository files navigation

Stars Last Commit Self-Hosted Live Demo

📈 Internal Beta

Stop measuring risk against the S&P 500. Measure it against Your Portfolio.

Internal Beta is a professional-grade, self-hosted risk engine for stock investors. While standard tools compare stocks to the "Market," this system calculates how a stock moves relative to your specific holdings.

Built with Python 3.13 (FastAPI), React 19, and Real-time Financial Data, it identifies if a new stock is a true diversifier or just adding hidden concentration to your wealth.

✨ Why Internal Beta?

Every brokerage shows you Beta vs the S&P 500. But that's not your risk.

  • The Insight: A stock with a market beta of 1.2 might have an Internal Beta of 0.3 against your specific portfolio — making it a powerful diversifier for you.
  • The Math: We use Leave-One-Out Covariance to avoid self-correlation inflation and Ledoit-Wolf Shrinkage for stable risk estimation.

🛠️ What It Does

📊 Portfolio Risk Dashboard

Comprehensive analysis of your current state: Sharpe ratio, Max Drawdown, MCTR (Marginal Contribution to Risk), Correlation Clusters, and Efficient Frontier visualization.

🔍 Candidate Analysis ("Should I buy this?")

Pick any stock. The system runs a 5-factor composite score (Sharpe improvement, Volatility reduction, Diversification benefit, Tail risk, and Quality-Valuation fit) to show you the optimal number of shares to add.

⚡ Smart Stock Screener

Scans S&P 400 in real-time via SSE. Ranks candidates by Cheap-Quality Score (Quality x Valuation) and instantly shows their Internal Beta fit for your specific portfolio.

🛡️ Thesis Health Check

Automated monitoring of ROIC, Gross Margins, FCF Yield, and Debt Health. The system flags "Broken Theses" when fundamental compounding signals start to decelerate.


🏗️ Architecture & Tech Stack

The system is built as a high-performance, asynchronous microservices suite:

  • Frontend: React 19, TypeScript, Tailwind CSS, Recharts (Heatmaps & Frontiers).
  • Backend: Python 3.13, FastAPI (Async), Pydantic v2, Poetry.
  • Data Engine: yfinance for data, PyPortfolioOpt for Ledoit-Wolf covariance shrinkage.
  • Infrastructure:
    • Nginx: API Gateway with SSE passthrough.
    • Redis: Shared cache for price/analysis (30min - 24h TTL).
    • PostgreSQL: Secure portfolio persistence.

🚀 Quick Start (Docker)

Ensure you have Docker and Docker Compose installed, then run:

git clone https://github.com/adifinki/internal-beta.git
cd internal-beta
docker compose up --build

View the hosted version at internal-beta.adifinki.com

About

Analyze how stocks fit your portfolio. Open-source institutional-grade risk engine featuring Internal Beta, risk deltas and correlation clusters

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors