stress_test
Analyze portfolio resilience by replaying historical crises, simulating rate/equity shocks, performing factor decomposition, and running Monte Carlo simulations to compute VaR and CVaR.
Instructions
Run comprehensive portfolio stress tests.
Includes: historical scenario replay (GFC, COVID, etc.), hypothetical rate/equity/sector shocks, Fama-French factor decomposition, and Monte Carlo simulation.
Args: portfolio_json: JSON array of holdings, e.g. '[{"ticker": "AAPL", "weight": 0.20, "sector": "Technology"}, ...]'. prices_json: JSON of price data from fetch_prices (the "prices" array). factor_data_json: Optional JSON of Fama-French factors from fetch_ff_factors. benchmark: Benchmark ticker (default "SPY"). run_scenarios: Run historical scenario replay (default True). run_shocks: Run hypothetical shocks (default True). run_factors: Run Fama-French factor decomposition (default True). run_montecarlo: Run Monte Carlo simulation (default True). n_simulations: Number of Monte Carlo simulations (default 10000).
Returns: JSON with scenario results, shock estimates, factor betas/alpha, Monte Carlo VaR/CVaR, risk flags, and overall risk level.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| portfolio_json | Yes | ||
| prices_json | Yes | ||
| factor_data_json | No | ||
| benchmark | No | SPY | |
| run_scenarios | No | ||
| run_shocks | No | ||
| run_factors | No | ||
| run_montecarlo | No | ||
| n_simulations | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |