swapbyhw - Price swap instrument from Hull-White interest-rate tree

Syntax

[Price, PriceTree, SwapRate] = swapbyhw(HWTree, LegRate,
LegRate, Settle, Maturity, LegReset, Basis, Principal,
LegType)

Arguments

HWTree

forward-rate tree structure created by hwtree.

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 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) Day-count basis of the instrument. A vector of integers.

  • 0 = actual/actual (default)

  • 1 = 30/360 (SIA)

  • 2 = actual/360

  • 3 = actual/365

  • 4 = 30/360 (PSA)

  • 5 = 30/360 (ISDA)

  • 6 = 30/360 (European)

  • 7 = actual/365 (Japanese)

  • 8 = actual/actual (ISMA)

  • 9 = actual/360 (ISMA)

  • 10 = actual/365 (ISMA)

  • 11 = 30/360E (ISMA)

  • 12 = actual/365 (ISDA)

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 HW 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, SwapRate] = swapbyhw(HWTree, LegRate, LegRate, Settle, Maturity, LegReset, Basis, Principal, LegType) computes the price of a swap instrument from a Hull-White 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.

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. The SwapRate output 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 arguments are

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

Settle = '01-Jan-2005';
Maturity = '01-Jan-2008';
Basis = 0; 
Principal = 100;
LegRate = [0.06 20]; % [CouponRate Spread] 
LegType = [1 0]; % [Fixed Float] 
LegReset = [1 1]; % Payments once per year 

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

load deriv.mat; 

Use swapbyhw to compute the price of the swap.

[Price, PriceTree, SwapRate] = swapbyhw(HWTree, LegRate, ... 
Settle, Maturity, LegReset, Basis, Principal, LegType) 

Price =

    5.9109

PriceTree = 

     FinObj: 'HWPriceTree'
      PTree: {1x5 cell}
       tObs: [0 1 2 3 4]
    Connect: {[2]  [2 3 4]  [2 2 3 4 4]}
      Probs: {[3x1 double]  [3x3 double]  [3x5 double]}

SwapRate =

   NaN

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

LegRate = [NaN 20]; 

[Price, PriceTree, SwapRate] = swapbyhw(HWTree, LegRate, ... 
Settle, Maturity, LegReset, Basis, Principal, LegType) 
Price = 

   1.4211e-014

PriceTree = 

FinObj: 'HWPriceTree'
       PTree: {1x5 cell}
        tObs: [0 1 2 3 4]
     Connect: {[2]  [2 3 4]  [2 2 3 4 4]}
      Probs: {[3x1 double]  [3x3 double]  [3x5 double]}

SwapRate = 

   0.0438

See Also

bondbyhw, capbyhw, cfbyhw, floorbyhw, fixedbyhw, hwtree

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS