Where capital
meets consequence.
Quantitative risk frameworks built on institutional methodology — VaR, stress testing, scenario analysis, liquidation mapping. Python-powered. CFA-candidate rigour.
Seeing where the
market is fragile.
Liquidation heatmaps reveal the price levels where leveraged positions are most concentrated — and therefore most vulnerable. By mapping open interest and estimated stop-loss clusters, we identify where cascading liquidations could occur and how to position around them.
Institutional-grade tools.
Built from scratch.
Every model is built in Python, validated with real market data and designed around the same methodologies applied at hedge funds, prime brokers and risk departments at major financial institutions — from Black-Scholes to Geometric Brownian Motion, CAPM to Efficient Frontier optimisation.
from pypfopt import risk_models, expected_returns
# Compute mu & covariance matrix
mu = expected_returns.mean_historical_return(prices)
S = risk_models.CovarianceShrinkage(prices).ledoit_wolf()
# Build frontier & maximise Sharpe
ef = EfficientFrontier(mu, S)
ef.add_constraint(lambda w: w >= 0.02)
ef.add_constraint(lambda w: w <= 0.40)
weights = ef.max_sharpe(risk_free_rate=0.05)
cleaned = ef.clean_weights()
# Performance metrics
ret, vol, sharpe = ef.portfolio_performance(verbose=True)
▶ PORTFOLIO OPTIMISER v1.3
━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Assets: 7 · Method: Max Sharpe
Matrix: Ledoit-Wolf
Optimal Weights
BTC 28.4%
SPY 22.1%
GLD 18.6%
QQQ 14.2%
ETH 10.3%
TLT 4.2%
CASH 2.2%
Performance
Return: +24.8%
Vol: 14.2%
Sharpe: 1.62
def gbm_paths(S0, mu, sigma, T, dt, n):
steps = int(T/dt)
Z = np.random.standard_normal((n, steps))
drift = (mu - 0.5*sigma**2)*dt
shock = sigma * np.sqrt(dt) * Z
paths = S0 * np.cumprod(np.exp(drift+shock), axis=1)
return paths
# 10,000 paths · compute VaR/CVaR
paths = gbm_paths(S0=97420, mu=0.25, sigma=0.72, T=30, dt=1, n=10_000)
VaR_99 = np.percentile(paths[:,-1], 1)
CVaR_99 = paths[:,-1][paths[:,-1]<=VaR_99].mean()
import statsmodels.api as sm
def capm_beta(asset_returns, market_returns):
X = sm.add_constant(market_returns)
model = sm.OLS(asset_returns, X).fit()
return model.params[1]
# Risk-free rate · beta · market premium
Rf = 0.05; Rm = 0.12
beta_btc = capm_beta(btc_ret, spy_ret)
expected_r = Rf + beta_btc * (Rm - Rf)
# β = 1.82 → E(r) = 5% + 1.82(7%) = 17.7%
# Security Market Line plot
sml_x = np.linspace(0, 3, 100)
sml_y = Rf + sml_x * (Rm - Rf)
plt.plot(sml_x, sml_y, color='#c8f135')
"GFC_2008":{"equity":-0.52, "credit":+0.45, "fx":-0.18},
"COVID_2020":{"equity":-0.34, "vix":+3.0, "oil":-0.67},
"FED_TAPER":{"rates":+2.0, "dur":-0.16},
"CRYPTO_CRASH":{"btc":-0.70, "eth":-0.75},
}
"market_vol": 0.30, "credit_risk": 0.25,
"liquidity": 0.20, "concentration": 0.15,
"macro_regime": 0.10
}
def grade(score):
return ("AAA" if score<2 else
"A" if score<4 else
"BB" if score<6 else
"B" if score<8 else "CCC")
USD · Gold · BTC · ETH
Macro-level analysis across the four most systemically important assets. Cross-asset correlations, regime detection, and structural trend identification.
Fed signals. Inflation data.
What it all means.
Macro regime determines the risk environment for all asset classes. These gauges synthesise the most critical data points driving market conditions.