$ show fortitudo-tech/fortitudo.tech
This is a Python library for quantitative finance, specifically portfolio optimization and risk management. It implements Conditional Value-at-Risk (CVaR) optimization using Benders decomposition, mean-variance optimization via quadratic programming, and entropy pooling for adjusting scenario probabilities under user-defined views and stress tests. The library also includes fully flexible resampling (FFR) for simulation, Black's model for option pricing, and a set of helper functions for financial statistics. It is designed as a monolithic Python package with a clean API, extensive tests (100% coverage), and 14 Jupyter notebooks that serve as reproducible examples. While the primary character is an application library, it has a strong research and educational orientation, referencing academic papers and providing walkthroughs. The code is well-structured, but domain-specific and depends on cvxopt with GLPK for linear programming, which may limit portability.
The LLM identified 3 files worth highlighting for reuse:
Implements the core entropy pooling algorithm using a dual formulation to adjust a prior probability vector to new views specified as linear equality/inequality constraints (A,b,G,h). This is a self-contained function that can be extracted and applied to any scenario-based probability adjustment problem, not just finance. It solves a minimax optimization problem using scipy.optimize.minimize with SLSQP, and is robust to different constraint types. The code is well-documented and the solver handles edge cases (e.g., zero prior probabilities, infeasible views). It is the most reusable component in the repo, as the entropy pooling technique is generic.
Provides two optimizer classes: MeanCVaR (minimizing CVaR for a target return) and MeanVariance (minimizing variance for a target return). MeanCVaR uses Benders decomposition with cvxopt's LP solver (GLPK), while MeanVariance uses a quadratic programming solver. Both classes accept a returns matrix, linear constraints, and optional probability weights. The efficient_frontier() method returns the full efficient frontier. The implementation is efficient, handles both long-only and general linear constraints, and is parameterized via an options dictionary. This module can be extracted and reused for any portfolio optimization problem with similar objective functions, though it depends on cvxopt's specific solver interface.
Implements Fully Flexible Resampling (FFR) for generating synthetic market scenarios. The key class is FullyFlexibleResampling, which uses crisp bands with state-dependent probabilities (e.g., based on VIX regimes). It includes methods for exponential decay probability generation and calibration of multivariate normal parameters. The simulation method is novel: it resamples historical returns with replacement using probabilities that depend on a regime variable, then applies entropy pooling to match target moments. This component demonstrates non-trivial statistical engineering and is reusable for any time series simulation task that requires regime-dependent scenario generation.