Contents

swapbyhw

Price swap instrument from Hull-White interest-rate tree

Syntax

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

Input 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 representing the settlement date for each swap. Settle must be earlier than Maturity.

Maturity

Maturity date. NINST-by-1 vector of dates representing the maturity date for each swap.

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.

Ordered Input or Name-Value Pair Arguments

Enter the following optional inputs using an ordered syntax or as name-value pair arguments. You cannot mix ordered syntax with name-value pair arguments.

LegReset

NINST-by-2 matrix representing the reset frequency per year for each swap. NINST-by-1 vector representing the frequency of payments per year.

Default: [1 1]

Basis

Day-count basis of the instrument. A vector of integers.

  • 0 = actual/actual

  • 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)

  • 13 = BUS/252

For more information, see basis.

Default: 0 (actual/actual)

Principal

NINST-by-1 vector or NINST-by-1 cell array of the notional principal amounts or principal value schedules. For the latter case, each element of the cell array is a NumDates-by-2 call array where the first column is dates and the second column is its associated notional principal value. The date indicates the last day that the principal value is valid.

Default: 100

LegType

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: [1 0] for each instrument

Options

Derivatives pricing options structure created with derivset.

EndMonthRule

End-of-month rule. NINST-by-1 vector. This rule applies only when Maturity is an end-of-month date for a month having 30 or fewer days.

  • 0 = Ignore rule, meaning that a bond coupon payment date is always the same numerical day of the month.

  • 1 = Set rule on, meaning that a bond coupon payment date is always the last actual day of the month.

Default: 1

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

AdjustCashFlowsBasis

Adjust the cash flows based on the actual period day count. NINST-by-1 of logicals.

Default: false

BusinessDayConvention

Require payment dates to be business dates. NINST-by-1 cell array with possible choices of business day convention:

  • actual

  • follow

  • modifiedfollow

  • previous

  • modifiedprevious

Default: actual

Holidays

Holidays used for business day convention. NHOLIDAYS-by-1 of MATLAB® date numbers.

Default: If no dates are specified, holidays.m is used.

StartDate

NINST-by-1 vector of dates when the swap actually starts. Use this argument to price forward swaps, i.e., swaps that start in a future date

Default: Settle date

Description

[Price, PriceTree, SwapRate] = swapbyhw(HWTree,
LegRate, Settle, Maturity)
computes the price of a swap instrument from a Hull-White interest-rate tree.

[Price, PriceTree, SwapRate] = swapbyhw(HWTree,
LegRate, Settle, Maturity, LegReset, Basis,
Principal, LegType, Options, EndMonthRule)
computes the price of a swap instrument from a Hull-White interest-rate tree with optional input arguments.

[Price, PriceTree, SwapRate] = swapbyhw(HWTree,
LegRate, Settle, Maturity, Name,Value)
computes the price of a swap instrument from a Hull-White interest-rate tree with additional options specified by one or more Name,Value pair arguments.

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 NaNs for those instruments in which CouponRate is not set to NaN.

Examples

expand all

Price an Interest-Rate Swap

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:

  • Coupon rate for fixed leg: 0.06 (6%)

  • Spread for floating leg: 20 basis points

  • Swap settlement date: Jan. 01, 2005

  • Swap maturity date: Jan. 01, 2008

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)
Warning: Swaps are valued at Tree ValuationDate rather than Settle 

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

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)
Warning: Swaps are valued at Tree ValuationDate rather than Settle 

Price =

   1.4211e-14


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

Price an Amortizing Swap

Price an amortizing swap using the Principal input argument to define the amortization schedule.

Create the RateSpec.

Rates = 0.035;
ValuationDate = '1-Jan-2011';
StartDates = ValuationDate;
EndDates = '1-Jan-2017';
Compounding = 1;

RateSpec = intenvset('ValuationDate', ValuationDate,'StartDates', StartDates,...
'EndDates', EndDates,'Rates', Rates, 'Compounding', Compounding)
RateSpec = 

           FinObj: 'RateSpec'
      Compounding: 1
             Disc: 0.8135
            Rates: 0.0350
         EndTimes: 6
       StartTimes: 0
         EndDates: 736696
       StartDates: 734504
    ValuationDate: 734504
            Basis: 0
     EndMonthRule: 1

Create the swap instrument using the following data:

Settle ='1-Jan-2011';
Maturity = '1-Jan-2017';
Period = 1;
LegRate = [0.04 10];

Define the swap amortizing schedule.

Principal ={{'1-Jan-2013' 100;'1-Jan-2014' 80;'1-Jan-2015' 60;'1-Jan-2016' 40; '1-Jan-2017' 20}};

Build the HW tree using the following data:

VolDates = ['1-Jan-2012'; '1-Jan-2013';'1-Jan-2014';'1-Jan-2015';'1-Jan-2016';'1-Jan-2017'];
VolCurve = 0.1;
AlphaDates = '01-01-2017';
AlphaCurve = 0.1;

HWVolSpec = hwvolspec(RateSpec.ValuationDate, VolDates, VolCurve,...
AlphaDates, AlphaCurve);
HWTimeSpec = hwtimespec(RateSpec.ValuationDate, VolDates, Compounding);
HWT = hwtree(HWVolSpec, RateSpec, HWTimeSpec);

Compute the price of the amortizing swap.

Price = swapbyhw(HWT, LegRate, Settle, Maturity, 'Principal', Principal)
Price =

    1.4574

Price a Forward Swap

Price a forward swap using the StartDate input argument to define the future starting date of the swap.

Create the RateSpec.

Rates = 0.0374;
ValuationDate = '1-Jan-2012';
StartDates = ValuationDate;
EndDates = '1-Jan-2018';
Compounding = 1;

RateSpec = intenvset('ValuationDate', ValuationDate,'StartDates', StartDates,...
'EndDates', EndDates,'Rates', Rates, 'Compounding', Compounding)
RateSpec = 

           FinObj: 'RateSpec'
      Compounding: 1
             Disc: 0.8023
            Rates: 0.0374
         EndTimes: 6
       StartTimes: 0
         EndDates: 737061
       StartDates: 734869
    ValuationDate: 734869
            Basis: 0
     EndMonthRule: 1

Build an HW tree.

VolDates = {'1-Jan-2013'; '1-Jan-2014';'1-Jan-2015';'1-Jan-2016';'1-Jan-2017';'1-Jan-2018'};
VolCurve = 0.1;
AlphaDates = '01-01-2018';
AlphaCurve = 0.1;

HWVolSpec = hwvolspec(RateSpec.ValuationDate, VolDates, VolCurve,...
AlphaDates, AlphaCurve);
HWTimeSpec = hwtimespec(RateSpec.ValuationDate, VolDates, Compounding);
HWT = hwtree(HWVolSpec, RateSpec, HWTimeSpec);

Compute the price of a forward swap that starts in a year (Jan 1, 2013) and matures in four years with a forward swap rate of 4.25%.

Settle ='1-Jan-2012';
Maturity = '1-Jan-2017';
StartDate = '1-Jan-2013';
LegRate = [0.0425 10];

Price = swapbyhw(HWT, LegRate, Settle, Maturity, 'StartDate', StartDate)
Price =

    1.4434

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

LegRate = [NaN 10];
[Price, ~,SwapRate] = swapbyhw(HWT, LegRate, Settle, Maturity, 'StartDate', StartDate)
Price =

     0


SwapRate =

    0.0384

More About

expand all

Amortizing Swap

In an amortizing swap, the notional principal decreases periodically because it is tied to an underlying financial instrument with a declining (amortizing) principal balance, such as a mortgage.

Forward Swap

Agreement to enter into an interest-rate swap arrangement on a fixed date in the future.

Was this topic helpful?