# Swap

## Contents

## Definition

A swap is a contract in which two parties agree to exchange a stream of cash flows of one type against a stream of cash flows of another type. An interest rate swap (IRS), often referred as a plain vanilla swap, is an agreement to exchange cash flows determined by a floating interest rate against cash flows determined by a fixed interest rate.

A basic interest rate swap can be interpreted as a linear combination of forward rate agreements.

## Pricing

The value of a forward rate agreement with settlement day $T$ and maturity $T + \Delta$ is given by

$\displaystyle{V_{FRA}(t) = \left[\left(P(t,T) - P(t,T + \Delta)\right) - P(t,T + \Delta) L \Delta\right]F }$

for a fixed rate $L$, the so-called swap level, and a notional amount $F$.

Since the payoff structure of a basic swap is equal to the cash flows generated by a series of FRAs, the value on an arbitrage-free market must be

$\displaystyle{\sum_{i=0}^{N-1}V_{FRA}(t, T_{i}, T_{i+1})\,, }$

where $T_{0},...,T_{N-1}$ are the reset dates and $T_{i+1} = T_{i} + \Delta_{i}$. The period $\Delta_{i}$ is the *tenor* of the i-th payment. $T_{0} - t$ will be called the *lead time* and $T_{N}$ the maturity.

It follows that the value equals

$\displaystyle{\sum_{i=0}^{N-1}\left[\left(P(t,T_{i}) - P(t,T_{i+1})\right) - P(t,T_{i+1}) L \Delta\right]F \,. }$

The sum can be represented as the sum of two sums. The expression

$\displaystyle{\sum_{i=0}^{N-1}\left(P(t,T_{i}) - P(t,T_{i+1})\right)F = \left(P(t,T_{0}) - P(t,T_{N})\right)F }$

is the value of the *floating leg* and does not depend on the intermediate reset dates.

The value of the *fixed leg* is simply the sum of the discounted fixed payments, which are known in advance:

$\displaystyle{-\sum_{i=0}^{N-1} P(t,T_{i+1}) L \Delta_{i} F \,.}$

The value of the swap is simply the sum of the fixed leg and the floating leg value and henceforth given by

$\displaystyle{\left[\left(P(t,T_{0}) - P(t,T_{N})\right) - \sum_{i=0}^{N-1} P(t,T_{i+1}) L \Delta_{i} \right]F \,.}$

## Swap Yield

The swap yield is the fixed rate $L$ at which the contract has a value of $0$. Thus, this level $L^{*}$ is given by

$\displaystyle{ L^{*} = \frac{P(t,T_{0}) - P(t, t_{N})}{\sum_{i=0}^{N-1} P(t, T_{i+1}) \Delta_{i}} \,. }$

If the lead time $T_{0} - t$ is greater than $0$, then the swap contract is called a forward swap. If $T_{0} = t$, then $P(t,T_{0})$ simplifies to the payoff at maturity and equals $1$.

There are two representations of the swap yield which give further insight into the structure of swap contracts, both starting with a reformulation of the floating leg. First note that the value of the floating leg can be written as

$\displaystyle{\sum_{i=0}^{N-1}\frac{1}{\Delta_{i}}\left(\frac{P(t,T_{i})}{P(t,T_{i+1})} - 1\right)\,P(t,T_{i+1})\Delta_{i}F }$

or equivalently by

$\displaystyle{\sum_{i=0}^{N-1}f(t,T_{i},T_{i+1})P(t,T_{i+1})\Delta_{i}F \,. }$

Hence, the swap yield can be either represented as a linear combinations of simply compounded forward rates,

$\displaystyle{L^{*} = \sum_{j=0}^{N-1} v_{j} f(t,T_{j},T_{j+1}) \,,}$

where the weights

$\displaystyle{v_{j} = \frac{P(t, T_{j+1})}{\sum_{i=0}^{N-1} P(t, T_{i+1})\Delta_{i}}}\Delta_{j} \,, }$

depend on the term structure of discount factors (or equivalently, zerobonds), or as a linear combination of zerobonds,

$\displaystyle{L^{*} = \sum_{j=1}^{N} w_{j} P(t, T_{j}) \,,}$

where the weights are

$\displaystyle{w_{j} = \frac{f(t,T_{j-1}, T_{j})}{\sum_{i=1}^{N} P(t, T_{i})\Delta_{i-1}}}\Delta_{j-1} \,.}$

## Codebook

### Constructors

The class `IRSwap` provides a factory method to create interest rate swaps:

double notional = 1000000; ILevelTS ts_nelson_siegel = SvenssonTS(0.06, -0.02, 0.02, 1.0); ts_nelson_siegel.setExternalCompounding(Compounding.SIMPLE); double lead_time = 0.1; double tenors = {0.25, 0.25, 0.25, 0.25, 0.25}; IRSwap swap1 = IRSwap.create(notional, ts_nelson_siegel, lead_time, tenors);

The fixed rate is set to the swap yield during creation. Thus, the value of the contract will always be 0 after calling this method. It is, however, possible to change the fixed rate at any time.

### Methods

Most users will apply the `IRSwap` class to pricing problems. Since there are payments if a swap is established, both parties must have assigned a value of 0 to the contract. Thus, the most important question is how to choose the fixed rate, such that value is really 0, i.e. how to determine the swap yield. If an `IRSwap` object has just been created, you can call the `fixedRate()` method, since the initial fixed rate is set to the swap yield. Later on, if the fixed rate might have changed, the swap yield can be obtained by calling the `swapYield()` method:

double swap_yield = swap1.swapYield(); // swap_yield = in this example

Another question that might arise is to determine the price of a contract that has been established at a given swap level. The value can be determined by calling the `value()` method

swap1.setFixedRate(0.05); // sets the fixed rate to 5 % double value = swap1.value(); // value = in this example.

## See also

## References

- Rebonato, Riccardo:
*Interest rate option models - understanding, analysing and using models for exotic interest rate options*, 2nd ed., Wiley , Chichester, 1998.