Finds the exact line
Not "your matrix might be unstable." The exact line. The exact condition. How many times out of 5,000 it broke under that market scenario. 8 detector types run automatically — no configuration.
line 82 · 16.9% failure rateThen it blows up in prod.
BlackSwan runs 5,000 Monte Carlo simulations under realistic market stress scenarios and pinpoints the exact source line where your math breaks — how often, under what conditions, and which input caused it.
# Apply correlation stress
corr_shift = params.get("correlation_shift")
adj = corr_matrix + corr_shift
np.fill_diagonal(adj, 1.0)
cov_matrix = np.outer(vols, vols) * adj
L = np.linalg.cholesky(cov_matrix)
scenarios = L @ Z
return scenarios
One command. Five thousand simulations. One exact line — with causal chain, frequency, and a ready-to-apply fix.
Standard linters catch syntax errors. BlackSwan catches the math that looks correct until a 3-sigma event hits it — and tells you exactly where, why, and how to fix it.
Not "your matrix might be unstable." The exact line. The exact condition. How many times out of 5,000 it broke under that market scenario. 8 detector types run automatically — no configuration.
line 82 · 16.9% failure rateEvery failure includes a dependency walk: which root input caused which intermediate variable to drift, finally breaking the math at which line. Two-Path attribution with Slow-Path replay for verified, high-confidence results.
corr_shift → adj_matrix → cov_matrixFor each shatter point, BlackSwan generates a mathematically sound fix — a nearest-PSD correction, an epsilon clamp, a denominator guard — and applies it in one command.
Higham 2002 nearest-PSD appliedEmit SARIF 2.1.0 for GitHub Code Scanning with one flag. Or run stress tests directly from a Claude conversation via the MCP server — findings, causal chains, and fix hints without leaving your IDE.
--output sarif · blackswan-mcpEvery run emits a ReproducibilityCard: exact BlackSwan version, NumPy version, scenario hash, seed, and a ready-to-paste replay command. Same seed, same scenario, same results — always.
seed 42 · scenario_hash a3f9c2Beyond random Monte Carlo: a genetic algorithm evolves perturbation sets toward worst-case inputs. A HardnessAdaptor ramps intensity when no failures are found, so robust code is actually tested hard.
--adversarial --population 200Each scenario is a reproducible YAML spec. Same seed, same parameters, same results — always.
Spread widening, volatility expansion, correlation contagion, and turnover collapse simultaneously.
Sudden volatility regime shift. Tests whether your model survives realized vol 2×–4× above historical.
Pairwise correlations surge. The classic covariance matrix PSD failure scenario.
Parallel rate shift with credit spread widening. Stress tests duration and convexity assumptions.
Random NaN injection and partial time series truncation. Finds silent failures from bad data handling.
CLI, Python API, VS Code extension, GitHub Actions, and Claude MCP — the engine is the same in all of them.
Requires Python 3.11+ · NumPy · PyYAML · Full documentation on GitHub