Financial Derivatives Toolbox    
swapbyhjm

Price swap instrument by HJM interest rate tree

Syntax

Arguments

HJMTree
Forward rate tree structure created by hjmtree.
LegRate
Number of instruments (NINST)-by-2 matrix, with each row defined as:
[CouponRate Spread] or [Spread CouponRate]
CouponRate is the decimal annual rate. Spread is the number of basis points over the reference rate. The first column represents the receiving leg, while the second column represents the paying leg.
Settle
Settlement date. NINST-by-1 vector of serial date numbers or date strings. Settle must be earlier than or equal to Maturity.
Maturity
Maturity date. NINST-by-1 vector of dates representing the maturity date for each swap.
LegReset
(Optional) NINST-by-2 matrix representing the reset frequency per year for each swap. Default = [1 1].
Basis
(Optional) NINST-by-1 vector representing the basis used when annualizing the input forward rate tree. Default = 0 (actual/actual).
Principal
(Optional) NINST-by-1 vector of the notional principal amounts. Default = 100.
LegType
(Optional) NINST-by-2 matrix. Each row represents an instrument. Each column indicates if the corresponding leg is fixed (1) or floating (0). This matrix defines the interpretation of the values entered in LegRate. Default is [1 0] for each instrument.
Options
(Optional) Derivatives pricing options structure created with derivset.

The Settle date for every swap is set to the ValuationDate of the HJM tree. The swap argument Settle is ignored.

This function also calculates the SwapRate (fixed rate) so that the value of the swap is initially zero. To do this enter CouponRate as NaN.

Description

[Price, PriceTree, CFTree, SwapRate] = swapbyhjm(HJMTree, LegRate, Settle, Maturity, LegReset, Basis, Principal, LegType) computes the price of a swap instrument from an HJM interest rate tree.

Price is number of instruments (NINST)-by-1 expected prices of the swap at time 0.

PriceTree is the tree structure with a vector of the swap values at each node.

CFTree is the tree structure with a vector of the swap cash flows at each node.

SwapRate is a NINST-by-1 vector of rates applicable to the fixed leg such that the swaps' values are zero at time 0. This rate is used in calculating the swaps' prices when the rate specified for the fixed leg in LegRate is NaN. SwapRate is padded with NaN for those instruments in which CouponRate is not set to NaN.

Examples

Example 1.

Price an interest rate swap with a fixed receiving leg and a floating paying leg. Payments are made once a year, and the notional principal amount is $100. The values for the remaining parameters are:

Based on the information above, set the required parameters and build the LegRate, LegType, and LegReset matrices.

Price the swap using the HJMTree included in the MAT-file deriv.mat. HJMTree contains the time and forward rate information needed to price the instrument.

Use swapbyhjm to compute the price of the swap.

Using the function treeviewer, you can examine CFTree graphically and see the cash flows from the swap along both the up and the down branches. A positive cash flow indicates an inflow (income - payments > 0), while a negative cash flow indicates an outflow (income - payments < 0).

In this example you have sold a swap (receive fixed and pay floating). At time t = 3, if interest rates go down, your cash flow is positive ($2.63), meaning that you will receive this amount. But if interest rates go up, your cash flow is negative(-$1.58), meaning that you owe this amount.

Example 2.

Using the previous data, calculate the swap rate, the coupon rate for the fixed leg such that the swap price at time = 0 is zero.

See Also

capbyhjm, cfbyhjm, floorbyhjm, hjmtree


  swapbybdt swapbyzero