FNCE 5323 Counterparty Risk Management Summer 2023
Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit
FNCE 5323 Counterparty Risk Management
Summer 2023
Course Project: CVACalculation for IRS
Project Objective
Use Spyder running Python 3 to develop code for calculating CVA for an Interest Rate Swap for a counterparty entering into an IRS as a Fixed Pay Receiver.
Project Requirements
Use Spyder running Python 3 to develop the code featuring the following functionality:
• Read the Run Parameters from the file FNCE5323_23Sm_CVA-IRS-Params.csv which contains the following table:
Param |
Value |
mu |
0.05 |
kappa |
0.1 |
sigma |
0.01 |
r0 |
0.05 |
Nmb Scens |
1000 |
dt (in years) |
0.25 |
t term (in years) |
10 |
dtau (in years) |
0.25 |
tau term (in years) |
10 |
Swap rates |
0.05 |
PFE Conf Level (k) |
0.975 |
LGD |
0.6 |
Credit Curve (CDS) |
|
Time (years) |
Given Credit Curve (Spread in bps) |
0 |
0 |
1 |
200 |
3 |
221 |
5 |
244 |
7 |
270 |
10 |
314 |
• Use the script you developed for Assignment 1 to
o Generate 1000 stochastic scenarios for short term interest rates T (n, ti ),
where n = 1, … , Nmbscens and ti = dt, 2dt, … , Idt, I = t term years) and
calculating prices of zero coupon bonds Z (n, ti, τj ), for n = 1, … , Nmbscens;
ti = 0, dt, 2dt, … , Idt, I = t term t(n) years); τj = 1 ∙ dtau, 2 ∙ dtau, … ,J ∙ dtau, J = tauter years).
• Apply the script you developed for Assignment 2 to
o Use the zero coupon prices of z(n, ti, τj) for calculating IRS Fixed Leg and IRS Floating Leg by applying correspondingly:
Fixed Leg(n, ti) = s ∙ dt ∙ iz(n, ti, τj) ,
Floating Leg(n, ti) = 1 − z(n, ti, T − ti),
where T = t term (in years), for all ti = 0, dt, 2dt, … , Idt, I = t term years).
o For each scenario n = 1, … , Nmb Scens and all ti = 0, dt, 2dt, … , Idt, I = t term years)
use Fixed Leg(n, ti) and Floating Leg(n, ti) to calculate
IRS MtM Fixed Leg payer(n, ti) = Floating Leg(n, ti) − Fixed Leg(n, ti) or
IRS MtM Fixed Leg Receiver(n, ti) = Fixed Leg(n, ti) − Floating Leg(n, ti) that is specified in the Project Objective.
o For each ti = 0, dt, 2dt, … , Idt, I = t term years) go across all the scenarios to calculate the EE(ti)
and PFEk(ti) for the given PFE confidence level k.
• Use the script you developed for Assignment 3 to interpolate credit spreads given at the bottom part of the
parameter table for each ti = 0, dt, 2dt, … , Idt, I = t term years) and then
calculate PD(ti−1, ti) for each ti = dt, 2dt, … . , Idt, I = t term years) .
• Use the formula shown in Deck10_CalculatingCVApdf and in FNCE5323_23Sm_CVA-IRS- Template.xlsm to calculate
o CVA,
o Risky DUTation, CVA(bPs)Approx 1 and
o EPE, CVA(bPs)APPTox 2
• Put the EE(ti) and PFEk(ti), SPTead(ti) and PD(ti−1, ti), for all ti = 0, dt, 2dt, … , Idt, I = t term years)
into a .csv output file that should be named as CVA-IRS_YourGroupID_out.csv
For example, Hartford group H3 the file should be named as
CVA-IRS_H3_out.csv
• Put CVA, Risky DUTation, CVA(bPs)Approx 1, EPE, CVA(bPs)APPTox 2 into
exactly the same output file CVA-IRS_YourGroupID_out.csv
• Do !!!NOT!!! create any additional files. All your outputs should go into
the same file which should look like FNCE5323_23Sm_CVA-IRS-Out.csv
Project Delivery
• The project code should be saved as a Python file that can be run in Spyder.
The file should be named CVA-IRS_YourGroupID.py
For example, Hartford group H3 the file should be named as CVA-IRS_H3.py
• !!!! Only the file with your Python script should be submitted. DO NOT submit your output file.
• The file should be submitted via Blackboard no later than
11:59 pm,Thursday, July 27, 2023
• It is expected that for each group the submission is done by the group representative. There should be ONE
and ONLY ONE submission for each group.
Suggestions
Make sure that every member of your group can run the code in his/her computer before delivering your code to me.
Use IRS-CVA_Template.xlsm to check your answers before delivering your code tome:
• Make sure that your interpolated spreads have exactly the same vales as in Column D.
• Make sure that your default probabilities have exactly the same vales as in Column E.
• Copy and paste your EEvalues into column F. If your calculations are accurate, the vales you will see in Column I should be very close your values.
2023-07-25
CVA Calculation for IRS