## Libor.LiborDerivatives Class Swap

```java.lang.Object Libor.LiborDerivatives.LiborDerivative Libor.LiborDerivatives.Swap
```

public class Swap
extends LiborDerivative

Payer swap `swp([T_p,T_q],kappa)` settled in arrears pays off `delta_k*(L_k(T_k)-kappa)` at time `T_{k+1}` for `k=p,p+1,...,q-1`. Here `kappa` is the strike rate and the notional amount of the swap is `1`.

At any time `t<=T_p` the value of receiving Libor on the interval `[T_p,T_q]` is the same as receiving the swap rate `S_pq(t)` and consequently the price `c(t)` of the swap becomes

`c(t)=B_pq(t)(S_pq(t)-kappa)`

where `B_pq(t)=sum_{k=p}^{q-1}delta_kB_{k+1}(t)` is the annuity on `[T_p,T_q]` as usual.

No Libor vector implemented for fast valuation. No control variate implemented. Why would we want to compute a Monte Carlo price for this swap at all when the price can be computed directly from the Libors? The answer is verification of model correctness.

 Constructor Summary ```Swap(LiborProcess LP, int p, int q, double kappa)```           Libors needed for forward payoff are `L_j, j>=p` up to time `min{T_q,T_{n-1}}`.

 Method Summary ` double` `analyticForwardPrice(int t)`           Analytic time `T_n`-forward swap price `c(t)=B_pq(t)(S_pq(t)-kappa)/B_n(t)` at time `t`. ` double` `currentForwardPayoff()`           The payoffs `delta_k*(L_k(T_k)-kappa)=X_k(T_k)-delta_k*kappa` at times `T_{k+1}, k=p,p+1,...,q-1` transported forward and aggregated at the horizon `T_n`, value computed from current Libor path. `static void` `main(java.lang.String[] args)`           Test program.

 Methods inherited from class Libor.LiborDerivatives.LiborDerivative `controlledForwardPayoff, controlledMonteCarloForwardPrice, controlVariateMean, currentControlledForwardPayoff, forwardPayoff, lognormalForwardPayoff, lognormalForwardPayoffSample, lognormalMonteCarloForwardPrice, monteCarloForwardPrice`

 Methods inherited from class java.lang.Object `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

 Constructor Detail

### Swap

```public Swap(LiborProcess LP,
int p,
int q,
double kappa)```
Libors needed for forward payoff are `L_j, j>=p` up to time `min{T_q,T_{n-1}}`. Note: if `q=n` nothing happens when transporting forward from time `T_q`.

Parameters:
`LP` - underlying Libor process.
`p` - swap begins at `T_p`.
`q` - swap ends at `T_q`.
`kappa` - strike rate.
 Method Detail

### currentForwardPayoff

`public double currentForwardPayoff()`
The payoffs `delta_k*(L_k(T_k)-kappa)=X_k(T_k)-delta_k*kappa` at times `T_{k+1}, k=p,p+1,...,q-1` transported forward and aggregated at the horizon `T_n`, value computed from current Libor path.

Specified by:
`currentForwardPayoff` in class `LiborDerivative`

### analyticForwardPrice

`public double analyticForwardPrice(int t)`

Analytic time `T_n`-forward swap price `c(t)=B_pq(t)(S_pq(t)-kappa)/B_n(t)` at time `t`.

Overrides:
`analyticForwardPrice` in class `LiborDerivative`
Parameters:
`t` - current discrete time.

### main

`public static void main(java.lang.String[] args)`

Test program. Allocates a Libor process of dimension `n=15` and prices the swap `swp([T_5,T_15],0.06)`.

The Monte Carlo forward price is compared to analytic price. The correlation of the payoff with the control variate is computed also.