| Математика
Key words: Interest Rate Swap, IRS, Quantlib, Plain Vanilla IRS, IMM dates, Swap valuation, Fixed leg, Floating Leg, Curve constraction, Swaps NPV

The interest rate swap (IRS) market is the largest derivative market. The size and continued growth of this market is really impressive: the article shows statistic across all OTC derivatives where IRS outstanding notional amount is $425,569 billion as of June 2013.

Vanilla IRS is a bilateral contract between counterparties who agree to exchange a series of cash flows at periodic dates. Cash flows are interest rate streams without transferring nominal amount. Therefore a nominal amount is considered to be a hypothetical loan on which counterparty only pays the interest. A plain vanilla IRS assumes interest payments:

• Fixed leg payer is said to be the buyer with semiannual payments and 30/360 day convention
• Floating leg payer (receiving the fixed rate) is said to be the seller. Floating rate benchmark is based on 3 month LIBOR rates, Act/360 convention.
• New York and London calendars are used for valuation
• Netting – the counterparty owing the greater amount pays the difference between what is owed and what is received

For each leg of a swap, Accrual Start/ Accrual End date, Pay date and Reset date must be defined.
Each leg of a swap is comprised of calculation periods. In our example we consider a 1-year USD swap that has 2 semiannual calculation periods on the fixed leg, and four quarterly calculation periods on the floating leg. Also, we define modified following roll conventions, a holiday date is adjusted to the next good business day, unless it rolls into the next month, in which case, the date is instead adjusted backwards to the last good business day.

Swap valuation

Swap pricing is based on the zero coupon and forward curve. These curves are derived by using bootstrapping . The valuation is simply computing the net PV of the fixed and floating legs. IRS is priced so that it has a net present value of zero, so called par swap.

1. Market instruments
We use the same curve as previously in our bootstrapping example, US-dollar interest rate swaps, YCSW0047 Index in Bloomberg, but with one main difference. Our curve was constructed of EDs contiguous futures (March, June, September and December months). As we pricing a 1-year swap we would like to have more market data for 1 year period. Therefore we use serial futures instead – March, April, May, June, July and August.

By using ICVS function in Bloomberg, one can use different curves for valuation:
• 23 USD swap curve (30/360 S/A) based on serial ED futures up to 4 years
• 47 USD swap curve (Act/360, Ann) based on ED futures up to 1 year
• 42 USD http://billiontrader.com/post/55 OIS Swaps

QuantLib is very flexible to take into account different market instruments with different maturities. It is easy to set up serial futures, i.e. to define correct IMM dates we just state month and year:

Date imm = IMM::date(“H5”,settlementDate);

2. Swap Setup

Real nominal = 10000000;
// fixed leg
Frequency fixedLegFrequency = Semiannual;
BusinessDayConvention fixedLegConvention = ModifiedFollowing;
BusinessDayConvention floatingLegConvention = ModifiedFollowing;
DayCounter fixedLegDayCounter = Thirty360();
Rate fixedRate = 0.00483153; //0.00483153

// floating leg
DayCounter floatingLegDayCounter = Actual360();
Frequency floatingLegFrequency = Quarterly;
boost::shared_ptr&ltIborIndex> USIndex(new USDLibor(Period(3, Months), forecastingTermStructure));
Spread spread = 0.00;
Integer lenghtInYears = 1;
VanillaSwap::Type swapType = VanillaSwap::Payer;
Date maturity = settlementDate + lenghtInYears*Years;

3. Schedule setup

Schedule fixedSchedule(settlementDate, maturity,
calendar, fixedLegConvention,
DateGeneration::Backward, false);
Schedule floatSchedule(settlementDate, maturity,
calendar, floatingLegConvention,
DateGeneration::Backward, false);

4. Final Vanilla Swap

VanillaSwap spot5YearSwap(swapType, nominal,
fixedSchedule, fixedRate, fixedLegDayCounter,
floatSchedule, USIndex, spread,

Let’s illustrate logic of the code above and consider Payment Date to be equal Accrual End Date.

Interest rate swaps payments

Now, let’s evaluate each leg and the final NPV payments. Floating leg has reset days, where the first rate is our actual Libor 3M rate, the others are forward rates.

Intest rate swaps calculations

The output of the program below shows NPV is -$0.59 (Our swap fixed rate is 0.483153%) and this is an off-market swap, one of the counterparties needs to compensate the other the NPV. We used the NPV() function in our code that gave exactly the same NPV result as we got in our calculations in the table above, NPV() = Sum = -$0.59.
We use fairRate() function to calculate the par swap fixed rate:

fairRate = spot1YearSwap.fairRate();

The result is 0.483147% and the NPV is equal to zero (which means PV of fixed leg is equal to PV of floating leg), i.e. “No losers, No winners at the beginning”.

Quantlib Interest rate swap