Skip to content Skip to sidebar Skip to footer

Calculating The Potential Future Exposure For Ir Swaps In Python Using Eonia Curve For Discounting And 6m Euribor Forward Curve For Pricing

I want to calculate the Potential Future Exposure (PFE) of a portfolio of two swaps using 2 curves - EURIBOR 6M to price the floating leg, and EONIA curve to discount the fixed leg

Solution 1:

You actually have two questions here:

1. PFE Example

First, the reason you cannot extract the data for the FraRateHelper is that there is an extra comma in one of the elements. Notice the type here that makes that particular tuple have 3 elements and not 2:

(-0.,452068001031876, 17)

After that, replace this bit of code (where you are creating a flat curve):

rate = ql.SimpleQuote(0.0536)
rate_handle = ql.QuoteHandle(rate)
dc = ql.Actual365Fixed()
yts = ql.FlatForward(today, rate_handle, dc)
yts.enableExtrapolation()

with...

yts = euribor6m_curve

and you should be good to use the example you mentioned.

2. Pricing Swaps

Now for pricing swaps with the two curves, the idea is to use the the forwards curve for the index:

euribor6m = ql.Euribor6M(hyts)

and then the discount curve for the engine:

engine = ql.DiscountingSwapEngine(discount_curve)
swap.setPricingEngine(engine)
print( swap.NPV() )
print( swap.fairRate() )

Post a Comment for "Calculating The Potential Future Exposure For Ir Swaps In Python Using Eonia Curve For Discounting And 6m Euribor Forward Curve For Pricing"