For a fix-for-floating Interest Rate Swap compute both the spread and the value of the legs.
[spread,leg]=irs(time,months,r,setting);
The function computes both the spread (i.e. the fixed payment) and the value of the legs for an Interest Rate Swap. The function can take into account both "in advance" and "in arrears" IRS.
Let as assume that 12th May 2010 an annual swap is subscribed (with 3-month payments).We first set the relevant interest rates (for one year swap with 3-month payments the interest rates must be four):
-->r=[0.00652 0.00956 0.01091 0.01216]';
Now we can use the function. For an "in advance" IRS we have
-->[spread,leg]=irs([2010 5 12],3,r,0)
leg = 0.0121787
spread = 0.0120930
Thus we have to pay 1.2% in exchange of the floating interest rate.
In the case of an "in arrears" IRS the last
-->[spread,leg]=irs([2010 5 12],3,r,1)
leg = 0.0106842
spread = 0.0140050
The spread is higher since we eliminate the first interest rate with an increasing curve.
Francesco Menoncin - Brescia University - 2010