How aditri-07/counterparty-credit-risk-imm works
This repository is a counterparty-credit-risk Monte Carlo simulator. The principal workflow loads market curves and a portfolio, bootstraps a yield curve, simulates rates and credit spreads, reprices bonds and swaps across paths, and derives EE/PFE and CVA. Separate branches provide deterministic DV01/convexity analysis and stressed exposure runs. The runner excerpt shows SQL staging, but the referenced SQL pipeline has no file in the supplied tree; it is represented at the existing src/ directory. Other links follow the README where runner excerpts are incomplete.
Main entry points: run_simulation.py Simulation Runner · exposure_engine.py Exposure Engine · stress_testing.py Stress Scenarios · data_loader.py Market Data Loader
Components 17
Market and Portfolio Inputs
- Market Data Loader
src/data_loader.py - Portfolio Input
src/data_loader.py - SQL Staging
src
Market Models
- Yield Curve
src/curve_construction.py - Hull-White Rates
src/hull_white.py - Credit Spread GBM
src/credit_spread.py
Exposure and Valuation
- Bond and Swap Pricing
src/instruments.py - Exposure Engine
src/exposure_engine.py - EE and PFE Profile
src/exposure_engine.py
Risk Analysis
- CVA Calculation
src/cva.py - DV01 and Convexity
src/sensitivity.py - Stress Scenarios
src/stress_testing.py - Reports and Plots
run_simulation.py
Other components
- Analyst
- Simulation Runner
run_simulation.py - FRED
- WRDS
Connections 21
- Analyst → Simulation Runner: runs
README.md - Simulation Runner → Market Data Loader: loads curves
run_simulation.py - Simulation Runner → Portfolio Input: loads portfolio
run_simulation.py - Market Data Loader → FRED: fetches data
README.md - Market Data Loader → WRDS: queries data
README.md - Simulation Runner → SQL Staging: stages and queries
run_simulation.py - Simulation Runner → Yield Curve: bootstraps curve
README.md - Simulation Runner → Hull-White Rates: calibrates model
README.md - Simulation Runner → Credit Spread GBM: calibrates model
README.md - Simulation Runner → Exposure Engine: runs simulation
run_simulation.py - Exposure Engine → Hull-White Rates: simulates paths
src/exposure_engine.py - Exposure Engine → Credit Spread GBM: simulates paths
src/exposure_engine.py - Exposure Engine → Bond and Swap Pricing: builds and reprices
src/exposure_engine.py - Exposure Engine → EE and PFE Profile: aggregates exposure
src/exposure_engine.py - Simulation Runner → CVA Calculation: computes CVA
run_simulation.py - Simulation Runner → DV01 and Convexity: computes risk
README.md - Simulation Runner → Stress Scenarios: runs scenarios
run_simulation.py - Stress Scenarios → Hull-White Rates: builds stressed model
src/stress_testing.py - Stress Scenarios → Credit Spread GBM: builds stressed model
src/stress_testing.py - Stress Scenarios → Exposure Engine: reruns simulation
src/stress_testing.py - Simulation Runner → Reports and Plots: writes reports
README.md