Skip to Main Content Skip to Search
Product Documentation

hjmprice - Instrument prices from Heath-Jarrow-Morton interest-rate tree

Syntax

Price = hjmprice(HJMTree, InstSet, Options)

Arguments

HJMTree

Heath-Jarrow-Morton tree sampling a forward-rate process. See hjmtree for information on creating HJMTree.

InstSet

Variable containing a collection of instruments. Instruments are categorized by type. Each type can have different data fields. The stored data field is a row vector or string for each instrument.

Options

(Optional) Derivatives pricing options structure created with derivset.

Description

Price = hjmprice(HJMTree, InstSet, Options) computes arbitrage-free prices for instruments using an interest-rate tree created with hjmtree. A subset of NINST instruments from a financial instrument variable, InstSet, are priced.

Price is a NINST-by-1 vector of prices for each instrument. The prices are computed by backward dynamic programming on the interest-rate tree. If an instrument cannot be priced, NaN is returned.

PriceTree is a MATLAB structure of trees containing vectors of instrument prices and accrued interest, and a vector of observation times for each node.

PriceTree.PBush contains the clean prices.

PriceTree.AIBush contains the accrued interest.

PriceTree.tObs contains the observation times.

hjmprice handles instrument types: 'Bond', 'CashFlow', 'OptBond', 'OptEmBond', 'Fixed', 'Float', 'Cap', 'Floor', 'RangeFloat', 'Swap'. See instadd to construct defined types.

Related single-type pricing functions are:

Examples

Load the HJM tree and instruments from the data file deriv.mat. Price the cap and bond instruments contained in the instrument set.

load deriv.mat; 
HJMSubSet = instselect(HJMInstSet,'Type', {'Bond', 'Cap'}); 

instdisp(HJMSubSet)

%Table of instrument portfolio partially displayed:
Index  Type  CouponRate Settle      Maturity     Period  Basis ... Name     Quantity
1      Bond  0.04       01-Jan-2000 01-Jan-2003  1        NaN  ... 4% bond  100
2      Bond  0.04       01-Jan-2000 01-Jan-2004  2        NaN  ... 4% bond   50
 
Index Type Strike Settle      Maturity     CapReset  Basis ...  Name      Quantity  
3     Cap  0.03   01-Jan-2000 01-Jan-2004  1         NaN   ...   3% Cap   30
     
[Price, PriceTree] = hjmprice(HJMTree, HJMSubSet)

Warning: Not all cash flows are aligned with the tree. Result will 
be approximated.

Price =

   98.7159
   97.5280
    6.2831

PriceTree = 

    FinObj: 'HJMPriceTree'
     PBush: {[3x1 double]  [3x1x2 double]  [3x2x2 double]  [3x4x2 double]  [3x8 double]}
    AIBush: {[3x1 double]  [3x1x2 double]  [3x2x2 double]  [3x4x2 double]  [3x8 double]}
      tObs: [0 1 2 3 4]

You can use treeviewer to see the prices of these three instruments along the price tree.

treeviewer(PriceTree, HJMSubSet)

 

Price the following multi-stepped coupon bonds using the following data:

% The data for the interest rate term structure is as follows:
Rates = [0.035; 0.042147; 0.047345; 0.052707];
ValuationDate = 'Jan-1-2010';
StartDates = ValuationDate;
EndDates = {'Jan-1-2011'; 'Jan-1-2012'; 'Jan-1-2013'; 'Jan-1-2014'};
Compounding = 1;

% Create RateSpec
RS = intenvset('ValuationDate', ValuationDate, 'StartDates', StartDates,...
'EndDates', EndDates,'Rates', Rates, 'Compounding', Compounding);

% Create a portfolio of stepped coupon bonds with different maturities
Settle = '01-Jan-2010';
Maturity = {'01-Jan-2011';'01-Jan-2012';'01-Jan-2013';'01-Jan-2014'};
CouponRate = {{'01-Jan-2011' .042;'01-Jan-2012' .05; '01-Jan-2013' .06; '01-Jan-2014' .07}};

ISet = instbond(CouponRate, Settle, Maturity, 1);
instdisp(ISet)  

%Table of instrument portfolio partially displayed:
Index Type CouponRate Settle         Maturity   Period Basis EndMonthRule ... Face
1   Bond [Cell]     01-Jan-2010    01-Jan-2011    1      0     1          ... 100 
2   Bond [Cell]     01-Jan-2010    01-Jan-2012    1      0     1          ... 100 
3   Bond [Cell]     01-Jan-2010    01-Jan-2013    1      0     1          ... 100 
4   Bond [Cell]     01-Jan-2010    01-Jan-2014    1      0     1          ... 100 


% Build the tree with the following data
Volatility = [.2; .19; .18; .17];
CurveTerm = [ 1;  2;   3;   4];
HJMTimeSpec = hjmtimespec(ValuationDate, EndDates);
HJMVolSpec = hjmvolspec('Proportional', Volatility, CurveTerm, 1e6);
HJMT = hjmtree(HJMVolSpec,RS,HJMTimeSpec);

% Compute the price of the  stepped coupon bonds
PHJM = hjmprice(HJMT, ISet) 

%Table of instrument portfolio partially displayed:
Index Type CouponRate Settle Maturity Period Basis EndMonthRule ... Face
1  Bond [Cell] 01-Jan-2010  01-Jan-2011    1   0     1          ... 100 
2  Bond [Cell] 01-Jan-2010  01-Jan-2012    1   0     1          ... 100 
3  Bond [Cell] 01-Jan-2010  01-Jan-2013    1   0     1          ... 100 
4  Bond [Cell] 01-Jan-2010  01-Jan-2014    1   0     1          ... 100 

PHJM =

  100.6763
  100.7368
  100.9266
  101.0115

 

Price a portfolio of stepped callable bonds and stepped vanilla bonds using the following data:

% Price a portfolio of stepped callable bonds and stepped vanilla bonds 
% using the following data.

% The data for the interest rate term structure is as follows:
Rates = [0.035; 0.042147; 0.047345; 0.052707];
ValuationDate = 'Jan-1-2010';
StartDates = ValuationDate;
EndDates = {'Jan-1-2011'; 'Jan-1-2012'; 'Jan-1-2013'; 'Jan-1-2014'};
Compounding = 1;

%Create RateSpec
RS = intenvset('ValuationDate', ValuationDate, 'StartDates', StartDates,...
'EndDates', EndDates,'Rates', Rates, 'Compounding', Compounding);

% Create an instrument portfolio of 3 stepped callable bonds and three
% stepped vanilla bonds
Settle = '01-Jan-2010';
Maturity = {'01-Jan-2012';'01-Jan-2013';'01-Jan-2014'};
CouponRate = {{'01-Jan-2011' .042;'01-Jan-2012' .05; '01-Jan-2013' .06; '01-Jan-2014' .07}};
OptSpec='call';
Strike=100;
ExerciseDates='01-Jan-2011'; %Callable in one year

% Bonds with embedded option 
ISet = instoptembnd(CouponRate, Settle, Maturity, OptSpec, Strike,...
ExerciseDates, 'Period', 1);
                    
% Vanilla bonds 
ISet = instbond(ISet, CouponRate, Settle, Maturity, 1);

% Display the instrument portfolio
instdisp(ISet)  

%Table of instrument portfolio partially displayed:
Index Type      CouponRate Settle         Maturity   OptSpec Strike ExerciseDates ... AmericanOpt
1   OptEmBond [Cell]     01-Jan-2010    01-Jan-2012    call    100    01-Jan-2011 ... 0
2   OptEmBond [Cell]     01-Jan-2010    01-Jan-2013    call    100    01-Jan-2011 ... 0
3   OptEmBond [Cell]     01-Jan-2010    01-Jan-2014    call    100    01-Jan-2011 ... 0
 
Index Type CouponRate Settle         Maturity    Period Basis EndMonthRule ... Face
4   Bond [Cell]     01-Jan-2010    01-Jan-2012    1      0     1           ... 100 
5   Bond [Cell]     01-Jan-2010    01-Jan-2013    1      0     1           ... 100 
6   Bond [Cell]     01-Jan-2010    01-Jan-2014    1      0     1           ... 100 


% Build the tree with the following data
Volatility = [.2; .19; .18; .17];
CurveTerm = [ 1;  2;   3;   4];
HJMTimeSpec = hjmtimespec(ValuationDate, EndDates);
HJMVolSpec = hjmvolspec('Proportional', Volatility, CurveTerm, 1e6);
HJMT = hjmtree(HJMVolSpec,RS,HJMTimeSpec);

%The first three rows corresponds to the price of the stepped callable bonds
% and the last three rows corresponds to the price of the stepped vanilla bonds.
PHJM = hjmprice(HJMT, ISet)  

PHJM =

  100.3682
  100.1557
   99.9232
  100.7368
  100.9266
  101.0115

 

Compute the price of a portfolio using the following data:

% The data for the interest rate term structure is as follows:
Rates = [0.035; 0.042147; 0.047345; 0.052707];
ValuationDate = 'Jan-1-2011';
StartDates = ValuationDate;
EndDates = {'Jan-1-2012'; 'Jan-1-2013'; 'Jan-1-2014'; 'Jan-1-2015'};
Compounding = 1;

%  Create RateSpec
RS = intenvset('ValuationDate', ValuationDate, 'StartDates',...
StartDates, 'EndDates', EndDates,'Rates', Rates, 'Compounding', Compounding);

% Create an instrument portfolio with two range notes and a floating rate
% note with the following data:
Spread = 200;
Settle = 'Jan-1-2011';
Maturity = 'Jan-1-2014';

% First Range Note:
RateSched(1).Dates = {'Jan-1-2012'; 'Jan-1-2013'  ; 'Jan-1-2014'};
RateSched(1).Rates  = [0.045 0.055; 0.0525  0.0675; 0.06 0.08];

% Second Range Note:
RateSched(2).Dates = {'Jan-1-2012'; 'Jan-1-2013' ; 'Jan-1-2014'};
RateSched(2).Rates  = [0.048 0.059; 0.055  0.068 ; 0.07 0.09];

% Create InstSet
InstSet = instadd('RangeFloat', Spread, Settle, Maturity, RateSched);

% Add a floating-rate note
InstSet = instadd(InstSet, 'Float', Spread, Settle, Maturity);

% Display the portfolio instrument
instdisp(InstSet)

Index Type      Spread Settle       Maturity   RateSched FloatReset Basis Principal EndMonthRule
1     RangeFloat 200    01-Jan-2011  01-Jan-2014 [Struct]  1          0     100       1   
2     RangeFloat 200    01-Jan-2011  01-Jan-2014 [Struct]  1          0     100       1   
 
Index Type  Spread Settle         Maturity       FloatReset Basis Principal EndMonthRule
3     Float 200    01-Jan-2011    01-Jan-2014    1          0     100       1           

% The data to build the tree is as follows:
Volatility = [.2; .19; .18; .17];
CurveTerm = [ 1;  2;   3;   4];
MaTree = {'Jan-1-2012'; 'Jan-1-2013'; 'Jan-1-2014'; 'Jan-1-2015'};
HJMTS = hjmtimespec(ValuationDate, MaTree);
HJMVS = hjmvolspec('Proportional', Volatility, CurveTerm, 1e6);
HJMT = hjmtree(HJMVS, RS, HJMTS);

% Price the portfolio 
Price = hjmprice(HJMT, InstSet)

Price =

   91.1555
   90.6656
  105.5147

See Also

hjmsens | hjmtree | hjmvolspec | instadd | intenvprice | intenvsens

  


Free Interactive Computational Finance CD

View demos and recorded presentations led by industry experts.

Now On Demand
Network with industry peers and learn the latest applications of the leading software product for computational finance.

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