Development of AI-based Portfolio Risk Management System
Portfolio risk management — not just stopping losses. It's a decision system: which risks to take consciously, which to hedge, where to limit position. AI adds to classical risk management theory dynamic adaptation to market regimes and nonlinear interdependencies.
Classification of Portfolio Risks
Market Risk:
- Directional: losses from price movements (equity beta, duration)
- Volatility: losses from volatility changes (vega)
- Correlation: losses on correlation breakdown
Credit Risk:
- Default risk: issuer default
- Downgrade risk: rating downgrade
- Spread risk: credit spread widening
Liquidity Risk:
- Market liquidity: inability to sell at acceptable price
- Funding liquidity: margin call on insufficient liquidity
Operational Risk:
- Model risk: valuation model errors
- Execution risk: slippage, system failure
VaR and Its Extensions
Historical Simulation VaR:
def historical_var(portfolio_returns, confidence=0.95, horizon=1):
"""
95% VaR: in 95% of days losses won't exceed this value
"""
return -np.percentile(portfolio_returns, (1 - confidence) * 100)
var_95 = historical_var(daily_pnl, confidence=0.95)
print(f"95% 1-day VaR: {var_95:.2%}")
Monte Carlo VaR: Scenario generation considering correlations and fat tails (Student-t, copula).
CVaR / Expected Shortfall (ES): Expected value of losses conditional on VaR being exceeded. Basel III requirement.
def cvar(returns, confidence=0.95):
var = historical_var(returns, confidence)
tail_returns = returns[returns < -var]
return -tail_returns.mean()
Filtered Historical Simulation: VaR adapts to current volatility. GARCH-volatility scaling:
Scaled_Return(t) = Historical_Return(i) × (σ_current / σ_historical(i))
Factor Risk Model
Portfolio risk decomposition by factors:
Barra-style Factor Analysis:
Portfolio_Return = Σ (weight_i × return_i)
= Σ (weight_i × Σ β_if × factor_f) + Σ (weight_i × ε_i)
= Factor_Return + Idiosyncratic_Return
Equity Portfolio Factors:
- Market Beta: exposure to market movement
- Size (SMB): small vs. large cap
- Value (HML): P/B ratio
- Momentum: 12-1 month momentum
- Quality: ROE, debt/equity
- Volatility: realized vol factor
Contribution to Risk:
def factor_risk_decomposition(weights, factor_returns, factor_loadings, residual_cov):
# Portfolio factor exposure
portfolio_factors = weights @ factor_loadings # shape: [n_factors]
# Factor covariance matrix (typically from Barra, MSCI Axioma)
factor_variance = portfolio_factors @ factor_cov @ portfolio_factors
# Idiosyncratic variance
idio_variance = weights @ residual_cov @ weights
total_variance = factor_variance + idio_variance
return {
'factor_risk_pct': factor_variance / total_variance,
'idio_risk_pct': idio_variance / total_variance
}
Dynamic Risk Management with AI
Volatility Targeting: Target portfolio volatility X%. When realized vol exceeds X% — reduce positions:
target_vol = 0.10 # 10% annualized
realized_vol = portfolio_returns.rolling(63).std() * np.sqrt(252)
scale_factor = target_vol / realized_vol
positions = base_positions * scale_factor.clip(0.5, 2.0)
Regime-Conditional Risk:
- Expansionary regime (low VIX, positive macro): max risk budget
- Risk-off regime (high VIX, inverted curve): 50% risk budget
- Crisis regime (VIX > 35, credit spread widening): 25% risk budget
Tail Risk Hedging: AI-system identifies cost-effective hedges:
- Put options on portfolio: volatility surface analysis to find underpriced protection
- CDS: hedge credit risk through credit default swaps
- VIX calls: positive correlation with portfolio losses on crash
Correlation and Copula Modeling
In crises, correlations spike: all assets fall together. Normal Gaussian copula underestimates this risk.
Dynamic Conditional Correlation (DCC):
# GARCH-DCC: correlations change over time
# R_t = D_t^{-1} H_t D_t^{-1}
# where H_t - conditional correlation matrix (DCC process)
t-Copula: better captures tail dependence — joint extreme movements.
Stress Correlation Matrix: For stress testing use correlation matrix from historical crisis periods (2008-09, COVID 2020).
Limits and Monitoring
Hierarchical Limit System:
- Portfolio VaR 95% 1-day: < 1% NAV
- Single position concentration: < 5% NAV
- Sector concentration: < 25% NAV
- Factor exposure (beta): 0.7-1.3
- Drawdown limit (circuit breaker): if drawdown > 10% → reduce all positions by 30%
Real-time Monitoring:
- PnL and VaR update with each trade
- Alerts when approaching limits (80% triggers warning)
- Daily risk report: PDF with attribution, exposures, stress tests
Timeline: basic VaR system with historical simulation and factor decomposition — 6-8 weeks. Full system with DCC correlations, dynamic risk targeting and automated reporting — 4-5 months.







