首页 > > 详细

代写QF5203帮做Python编程作业

QF5203 Lecture 5 
Interest Rate Swaps and their Risk Measures 
Part 2 
1. References 
2. A More Realistic Yield Curve Example 
3. Single Currency Tenor Basis Swap 
4. Cross Currency Swap 
5. Simple Variations of Plain Vanilla Swaps 
6. Common Exotic Swaps 
7. The Evolution of Yield Curve Construction 
8. Summary 
9. Homework 
10. Project 
1. References 
• Options, Futures and Other Derivatives, John Hull 
• Interest Rate Option Models, Riccardo Rebonato 
• Pricing and Trading Interest Rate Derivatives, H. Darbyshire 
• QuantLib Python Cookbook, Gautham Balaraman, Luigi Ballabio 
• https://www.quantlib.org/quantlibxl/ 
• For market conventions see https://opengamma.com/wp- 
content/uploads/2017/11/Interest-Rate-Instruments-and-Market- 
Conventions.pdf 
2. A More Realistic Yield Curve Example 
• In the previous lecture we looked at the case of using a flat yield curve in 
QuantLib Python/Excel in order to focus on the vanilla IRS cash flows 
• Obviously, a flat yield curve is not realistic 
• We will now show how to build a more realistic yield curve using Deposits, Short 
Term Interest Rate Futures (STIRF’s) and Interest Rate Swaps 
• We will also look at the functionality that QuantLib provides to study the risk 
sensitivities of a portfolio of interest rate swaps 
2. A More Realistic Yield Curve Example 
USD 3M Libor Swap Curve 
Tenor Rate Used Shift (Bp) 
ON 1.8200 0.0 
TN 1.7500 0.0 
S/N 1.8000 0.0 
1W 1.7500 0.0 
2W 1.7000 0.0 
3W 1.6600 0.0 
1M 1.6100 0.0 
2M 1.4100 0.0 
3M 1.2200 0.0 
F1 99.4800 0.0 
F2 99.6200 0.0 
F3 99.6300 0.0 
F4 99.6900 0.0 
F5 99.7000 0.0 
F6 99.6900 0.0 
F7 99.6700 0.0 
F8 99.6400 0.0 
3Y 0.4600 0.0 
4Y 0.5100 0.0 
5Y 0.5600 0.0 
7Y 0.6800 0.0 
10Y 0.8100 0.0 
12Y 0.8600 0.0 
15Y 0.9200 0.0 
20Y 0.9700 0.0 
25Y 1.0000 0.0 
30Y 1.0100 0.0 
2. A More Realistic Yield Curve Example 
General Inputs Fixed Leg Details Float Leg Details Name Obj ID Error 
Quote Date 3-Apr-20 Ccy USD Ccy USD Fixed Leg Schedule IDUSDFixedLegSchedule#0002 
Result Ccy USD Notional 100,000,000 Notional 100,000,000 Fixed Leg ID USDFixedLeg#0002 
Spot Date 7-Apr-20 Start Date 7-Apr-20 Start Date 7-Apr-20 Fixed Leg NPV 7,802,552 
Start Date 7-Apr-20 Maturity 10y Maturity 10y 
Maturity 10y End Date 8-Apr-30 End Date 8-Apr-30 Float Leg ScheduleUSDFloatLegSchedule#0002 
End Date 8-Apr-30 Pay/Rec REC Pay/Rec PAY Float Leg Index ID USDLiborIndex#0000 
Notional 100,000,000 Fwd Swap 0.80800% Margin 0.00% Float Leg ID USDLiborLeg#0000 
Coupon 0.80800% Freq Quarterly Fixed Leg NPV 7,802,552 
Yc ID USD Yield Curve#0000 Coupon Freq Semiannual Basis Actual/360 
Basis 30/360 (Bond Basis) Bus Day ConvModified Following Vanilla Swap ID USDVanillaSwap#0000 
Bus Day ConvModified Following Pmt CalendarUnitedStates::Settlement 
Pmt CalendarUnitedStates::Settlement Reset CalendarU itedKingdom::Settlement Swap Engine ID USDVanillaSwapDiscountingSwapEngine#0000 
Pricing Engine ID TRUE 
NPV 0 
Npv Details 
Fixed Leg 7,802,552 USD 7,802,552 7.80% 7,802,552 
Float Leg -7,801,081 USD -7,801,081 -7.80% -7,802,552 
Npv Deal 1,471 0.00% 0 
3. Single Currency Tenor Basis Swap 
• In a tenor basis swap, there is no fixed leg, and one party pays/receives a 
(floating) LIBOR of one tenor (e.g. 3m) and the other party receives/pays a 
(floating) LIBOR of a different tenor (e.g. 6m) 
• Note that in a tenor basis swap the notional on which the rate is applied is in the 
same currency 
• Other important examples of tenor basis swaps include Overnight Index Swaps 
(OIS) where the underlying index is a one-day rate, versus LIBOR (e.g. 3m) 
• Theoretically there should be no basis between LIBOR rates of different tenors 
(see tenor basis swap spreadsheet included in course material) 
• In practice there is a basis and market practice is to add it to the leg with the 
shorter tenor 
3. Single Currency Tenor Basis Swap 
General Inputs Leg 1 Float Details Leg 2 Float Details 
Quote Date 3-Apr-20 Notional 100,000,000 Notional 100,000,000 
Ccy USD Start Date 7-Apr-20 Start Date 7-Apr-20 
Set Evaluation DateTRUE Maturity 5y Maturity 5y 
Days to Spot 2 End Date 7-Apr-25 End Date 7-Apr-25 
Spot Date 7-Apr-20 Pay/Rec REC Pay/Rec PAY 
Float Margin 0.0000% Float Margin 0.0000% 
Yield Curve Inputs Frequency Quarterly Frequency Semiannual 
Handle USDBasisSwapFlatFwdYieldCurveAccrual Basis Actual/360 Accrual Basis Actual/360 
Ndays 0 Float Index LIBOR3M Float Index LIBOR6M 
Calendar UnitedStates::SettlementBus Day Conv Modified Following Bus Day Conv Modified Following 
Rate 4.00% Pmt CalendarUnitedStates::Settlement Pmt CalendarUnitedStates::Settlement 
Day Count Actual/365 (Fixed) Reset CalendarUnitedKingdom::Settlement Reset CalendarUnitedKingdom::Settlement 
Compounding Continuous 
Frequency Annual 
Yc ID USDBasisSwapFlatFwdYieldCurve#0005 
Npv Details 
Leg 1 18,127,948 
Leg 2 -18,127,948 
Net -0 
4. Cross Currency Swap 
• In a cross currency basis swap one party pays (or receives) a foreign floating 
LIBOR rate (e.g. USD LIBOR 3m) on an notional denominated in the foreign 
currency, and receives (or pays) a domestic floating LIBOR rate (e.g. JPY LIBOR 
3m) on a notional denominated in the domestic currency 
• On the start date of the swap there is an initial exchange of notional where the 
payer (or receiver) of the foreign floating leg receives (or pays) the foreign 
notional from (or to) the counterparty and pays (or receives) the domestic 
notional to (or from) the counterparty 
• On the maturity date of the swap there is a final exchange of notional where the 
payer (or receiver) of the USD floating leg pays (or receives) the foreign notional 
to (or from) the counterparty and receives (or pays) the domestic notional from 
(or to) the counterparty 
4. Cross Currency Swap 
General Inputs Ccy1 Fixed/Float Details Ccy2 Fixed/Float Details Fixed/Floating Leg 1 
Quote Date 3-Apr-20 Ccy USD Ccy JPY 
Set Evaluation DateTRUE Notional 100,000,000 Notional 11,000,000,000 
Result Ccy USD Notional Exchange BOTH Notional Exchange BOTH 
Days to Spot 2 Start Date 7-Apr-20 Start Date 7-Apr-20 
Spot Date 7-Apr-20 Maturity 10Y Maturity 10Y 
End Date 8-Apr-30 End Date 8-Apr-30 
Fx Details Pay/Rec REC Pay/Rec PAY 
USD/JPY 110.00 Fixed/Floating FLOAT Fixed/Floating FLOAT 
Fixed Rate 0.0000% Fixed Rate 0.0000% 
Float Margin 0.00000% Float Margin 0.0000% 
Frequency Quarterly Frequency Quarterly 
Accrual Basis Actual/360 Accrual Basis Actual/360 
Yield Curve 1 Inputs Fixing Method ADVANCE Fixing Method ADVANCE 
Handle USDCrossCcySwapFlatFwdYieldCurveloat Index LIBOR3M Float Index LIBOR3M 
Ndays 0 Bus Day Conv Modified Following Bus Day Conv Modified Following 
Calendar UnitedStates::SettlementPmt CalendarUnitedStates::Settlement Pmt CalendarUnitedStates::Settlement 
Rate 4.00% Reset CalendarUnitedKingdom::Settlement Reset CalendarUnitedKingdom::Settlement 
Day Count Actual/365 (Fixed) Days To Spot 2 Days To Spot 2 
Compounding Continuous 
Frequency Annual Ccy1 Bullet Payment Details Ccy2 Bullet Payment Details 
Yc ID USDCrossCcySwapFlatFwdYieldCurve#0006Date Amount Date Amount 
7-Apr-20 -100,000,000 7-Apr-20 11,000,000,000 
Yield Curve 2 Inputs 8-Apr-30 100,000,000 8-Apr-30 -11,000,000,000 
Handle JPYCrossCcySwapFlatFwdYieldCurve 
Ndays 0 
Calendar Japan 
Rate 1.00% Npv Details 
Day Count Actual/365 (Fixed) USD JPY Npv (USD) 
Compounding Continuous Upfront Pmts -99,956,174 10,998,794,587 32,868 
Frequency Annual Backend Pmts 66,980,603 -9,951,302,946 -23,485,788 
Yc ID JPYCrossCcySwapFlatFwdYieldCurve#0005Fixed/Floating Leg 32,975,571 -1,047,491,640 23,452,920 
Fees 0 0 0 
Net 0 0 0 
5. Simple Variations of Plain Vanilla Swaps 
• Forward Starting Swaps 
➢ A forward starting fixed versus floating interest rate swap is identical to a 
plain vanilla fixed versus floating interest rate swap except for the fact that 
it does not start from the spot date (e.g. a 5y 5y forward fixed versus 
floating interest rate swap starts in 5y from today and ends in 10y from 
today) 
➢ The equilibrium swap rate is obtained in the usual way, namely the fixed 
rate for which the PV of the fixed leg equals the PV of the floating leg 
➢ Note that this is a non-standard swap and would need to be quoted on a 
bespoke basis by a bank’s trading desk (banks or brokers do not provide 
screens with these rates) 
➢ Forward starting swaps are very sensitive to the forward LIBOR rates, and so 
interpolation choices are very important 
5. Simple Variations of Plain Vanilla Swaps 
• Amortising Swaps 
➢ Variation of a plain vanilla fixed versus floating swap where the notional on 
the fixed and/or floating legs amortises according to a pre-specified 
schedule 
• Accreting Swaps 
➢ Variation of a plain vanilla fixed versus floating swap where the notional on 
the fixed and/or floating legs accretes according to a pre-specified schedule 
• Step Up Coupon Swaps 
➢ Variation of a plain vanilla fixed versus floating swap where the fixed rate 
steps up or down 
Note that in each case the equilibrium swap rate is obtained in the usual way, 
namely the fixed rate for which the PV of the fixed leg equals the PV of the floating 
leg 
6. Common Exotic Swaps 
• LIBOR-in- Arrears Swap 
➢ With a plain vanilla swap the LIBOR rate fixes at the beginning of the accrual period and 
pays at the beginning of the period 
➢ With a LIBOR in arrears swap the LIBOR rate fixes at the end of the period and pays at the 
end of the period 
➢ A convexity adjustment is required because the forward LIBOR rate is no longer a 
Martingale under the measure induced by the zero coupon bond associated with the start 
of the accrual period 
• Constant Maturity Swap 
➢ A constant maturity swap (CMS) is a fixed versus floating swap where the floating index is a 
forward swap rate 
➢ As with the LIBOR-in-arrears swap a convexity adjustment is required for accurate pricing 
• Quanto Swap 
➢ A quanto swap is a fixed versus floating swap where the floating index (e.g. LIBOR) is 
associated with a different currency than the notional it is applied to 
➢ A quanto adjustment to the LIBOR forward rate is required for accurate pricing 
7. Yield Curve Construction – Pre GFC 
• Before the financial crisis there was little or no difference between Libor rates of 
different tenors and similarly the Libor-OIS spread was relatively small and stable 
• A single zero coupon curve used for both projecting Libor forwards and 
discounting future cash flows 
• Implicitly assumed Libor funding 
• No tenor basis 
• Yield Curve Instruments included: 
✓ Cash 
✓ FRAs/Futures (eventually included convexity adjustment) 
✓ Swaps 
• Combined with an interpolation scheme one bootstraps the discount factors 
• Leads to a simple expression the PV of the floating leg (see next slide) 
7. Yield Curve Construction – Pre GFC 
• Recall the interest rate pricing constraints from the previous lecture: 
; , +1 = 
( , +1) 
(; ) 
(; +1) 
− 1 
σ=1 
; −1, −1, (; ) 
σ 
=1 
−1, (; ) 
= (; ) − (; ) 
• In the above is ‘equilibrium’ swap rate, namely the fixed rate for which the 
present value of the fixed and floating legs are equal 
7. Yield Curve Construction – Pre GFC 
• The next level of sophistication came about with the need to include FX related 
instruments (i.e. FX Forwards and Cross Currency Basis Swaps) into a consistent 
framework 
• This was the first attempt by a few (notably USD based banks) to incorporate a 
separate forecasting and discounting curves 
• Yield Curve Instruments included: 
✓ Cash 
✓ FRAs/Futures (eventually included convexity adjustment) 
✓ Swaps 
✓ FX Forwards (up to about 1y) and then Cross Currency Basis Swaps 
• Two curves must be bootstrapped together and therefore requires an 
optimisation approach rather than simple bootstrapping 
• The pricing constraints and screen shot of a cross currency swap are shown on 
the next two slides 
7. Yield Curve Construction – Pre GFC 
• The generalization of the pricing constraints is given by: 
; , +1 = 
(,+1) 
(;) 
(;+1) 
− 1 ; ; , +1 = 
(,+1) 
(;) 
(;+1) 
− 1 
σ=1 
; −1, −1, 
(; ) 
σ 
=1 
−1, (; ) 
; = 
σ=1 
; −1, −1, 
(; ) 
σ 
=1 
−1, (; ) 
; −σ=1 
;−1, −1, 
; − 
(;) 
σ 
=1 
−1, (;) 
; −σ=1 
;−1, −1, 
; − 
(;) 
σ 
=1 
−1, (;) 
7. Yield Curve Construction – Post GFC 
• In the aftermath of the first credit crisis, single currency tenor basis swaps no 
longer traded with a zero basis due to a combination of credit and liquidity 
concerns 
• Now tenor basis must be explicitly included in our curve construction and 
separate Libor projection curves are needed for each index 
• Yield Curve Instruments needed to include: 
✓ Deposits 
✓ FRAs/Futures (eventually included convexity adjustment) 
✓ Swaps 
✓ FX Forwards (up to about 1y) and then Cross Currency Basis Swaps 
✓ Tenor basis swaps (e.g. 3m versus 6m, etc.) 
• Earlier in this lecture we went through the cash flows for a USD LIBOR 3m versus 
USD LIBOR 6m tenor basis swap 
7. Yield Curve Construction – Post GFC 
• Another consequence of the GFC is that the LIBOR-OIS basis dramatically widened, and 
whereas before the GFC this spread amount to less than 10bp, during the GFC it 
widened to more than 300bp 
• This called into question the long standing assumption that LIBOR was a good proxy for 
the risk free rate required in derivatives valuation 
• The overnight index swap (OIS) became the market standard risk free rate to be used for 
discounting cash flows 
• Overnight Indexes are indexes related to interbank lending over a one day time horizon 
• The OIS rate is paid on a compounding basis (see Open Gamma page 43) 
• The main OIS indices are: 
➢ FED FUNDS 
➢ EONIA 
➢ SONIA 
➢ TONAR 
7. Yield Curve Construction – Post GFC 
• A further level of complexity was introduced into the swap yield curve construction as a 
result of the realization that the collateral arrangements with counterparties directly 
impacted the rate to be used for discounting 
• There seems to be widespread agreement that the appropriate funding curve to use is 
the one associated with the collateral rate specified in the CSA (hence the name CSA 
discounting) 
• However, due to the variety of CSA agreements, I need to be able to discount any swap 
using any one of a number of funding curves (e.g. with EUR swap with an assumed USD 
OIS funding 
• With one counterparty I might have a EUR swap with a CSA which specifies a USD OIS 
collateral rate but with another counterparty I might have a EUR swap with a CSA which 
specifies JPY OIS and furthermore I will almost certainly have swaps cleared through 
LCH for which EUR OIS is the relevant collateral rate 
• The extra funding curves are constructed similarly to the extra index curves where we 
now our discount factors are indexed according to the relevant funding curve 
7. Yield Curve Construction – Post GFC 
• What is a CSA? 
• A CSA stands for Credit Support Annex and is essentially an agreement which 
specifies the details as to how two parties in an OTC derivative transaction will 
exchange collateral 
• Important information in a CSA includes: 
➢ frequency at which collateral is to be exchanged and any associated haircuts 
➢ type of collateral to be exchanged (e.g. cash, government bonds, etc.) 
➢ specification of any thresholds (e.g. zero threshold or …) 
➢ rehypothecation rights (defines what I can do with the collateral) 
➢ bilateral/unilateral 
7. Yield Curve Construction – Post GFC 
• CSA agreements often grant one or more counterparties the choice of posting 
one of several types of collateral (e.g. cash in one 3 currencies, say) 
• Such a CSA has embedded in it a chooser type option 
• The rational counterparty will choose the collateral for which he obtains the 
highest rate of return 
• In principle one needs to have a complex term structure model containing 
various basis spread volatilities and numerous correlations 
• Some (albeit less accurate) alternatives to such a complete framework would be 
• Assume a spot cheapest to deliver collateral rate and use this to discount all 
future cash flows 
• Calculate the intrinsic value of the embedded option on each future cash flow 
date and use this as the relevant discounting rate 
7. Yield Curve Construction – The Future 
• As a result of a few high profile scandals, largely on the back of the global 
financial crisis (GFC), the various regulators have decided that IBOR is 
• SOFR (Secured Overnight Financing Rate) has been chosen by the U.S. Federal 
Reserve’s Alternative Reference Rates Committee (ARRC) as the alternative 
reference benchmark to replace U.S. LIBOR 
• In Europe, ESTR is the replacement for EONIA, SONIA will continue as the risk 
free rate for the United Kingdom, and TONAR will continue as the risk free rate 
for Japan 
8. Summary 
• Before the GFC the use of LIBOR as a discounting curve was market practice 
• There was no appreciable basis between LIBOR rates of different tenors 
 
联系我们 - QQ: 99515681 微信:codinghelp2
© 2014 www.7daixie.com
程序代写网!