Generate risk contributions for each counterparty in portfolio
Contributions = riskContribution(cmc)
returns a table of risk contributions for each counterparty in the portfolio.
Contributions = riskContribution(
Contributions table allocates the full portfolio
risk measures to each counterparty, such that the counterparty risk
contributions sum to the portfolio risks reported by
Load the saved portfolio data.
Scale the bond prices for portfolio positions for each bond.
migrationValues = migrationPrices .* numBonds;
creditMigrationCopula object with a four-factor model using
cmc = creditMigrationCopula(migrationValues,ratings,transMat,... lgd,weights,'FactorCorrelation',factorCorr)
cmc = creditMigrationCopula with properties: Portfolio: [250x5 table] FactorCorrelation: [4x4 double] RatingLabels: [8x1 string] TransitionMatrix: [8x8 double] VaRLevel: 0.9500 PortfolioValues: 
VaRLevel to 99%.
cmc.VaRLevel = 0.99;
function to simulate 100,000 scenarios, and then use the
riskContribution function to generate the
cmc = simulate(cmc,1e5); Contributions = riskContribution(cmc); Contributions(1:10,:)
ans = 10x3 table ID EL CVaR __ ______ ______ 1 16.397 254.12 2 9.1179 134.31 3 5.7873 236.84 4 6.4235 338.23 5 22.739 544.69 6 10.776 704.29 7 2.9046 551.4 8 12.152 265.97 9 2.1567 26.112 10 1.7495 15.933
Contributions— Risk contributions
Risk contributions, returned as a table containing the following risk contributions for each counterparty:
EL — Expected loss for the
particular counterparty over the scenarios
CVaR — Conditional value at risk
for the particular counterparty over the scenarios
Contributions table allocates the full
portfolio risk measures to each counterparty, such that the counterparty
risk contributions sum to the portfolio risks reported by
 Crouhy, M., Galai, D., and Mark, R. “A Comparative Analysis of Current Credit Risk Models.” Journal of Banking and Finance. Vol. 24, 2000, pp. 59–117.
 Glasserman, P. “Measuring Marginal Risk Contributions in Credit Portfolios.” Journal of Computational Finance. Vol. 9, No. 2, Winter 2005/2006.
 Gordy, M. “A Comparative Anatomy of Credit Risk Models.” Journal of Banking and Finance. Vol. 24, 2000, pp. 119–149.
 Gupton, G., Finger, C., and Bhatia, M. “CreditMetrics – Technical Document.” J. P. Morgan, New York, 1997.
 Jorion, P. Financial Risk Manager Handbook. 6th Edition. Wiley Finance, 2011.
 Kalkbrener, M., Lotter, H., and Overbeck, L. “Sensible and Efficient Capital Allocation for Credit Portfolios.” Risk. 17, 2004, pp. S19–S24.
 Löffler, G., and Posch, P. Credit Risk Modeling Using Excel and VBA. Wiley Finance, 2007.
 McNeil, A., Frey, R., and Embrechts, P. Quantitative Risk Management: Concepts, Techniques, and Tools. Princeton University Press, 2005.