Products & Services Solutions Academia Support User Community Company

Learn more about Financial Derivatives Toolbox   

Computing Prices and Sensitivities Using Interest-Rate Models

Introduction

For purposes of illustration, this section relies on the HJM and BDT models. The HW and BK functions that perform price and sensitivity computations are not explicitly shown here. Functions that use the HW and BK models operate similarly to the BDT model.

Computing Instrument Prices

The portfolio pricing functions hjmprice and bdtprice calculate the price of any set of supported instruments, based on an interest-rate tree. The functions are capable of pricing these instrument types:

For example, the syntax for calling hjmprice is:

[Price, PriceTree] = hjmprice(HJMTree, InstSet, Options)

Similarly, the calling syntax for bdtprice is:

[Price, PriceTree] = bdtprice(BDTTree, InstSet, Options)

Each function requires two input arguments: the interest-rate tree and the set of instruments, InstSet. An optional argument Options further controls the pricing and the output displayed. (See Derivatives Pricing Options for information about the Options argument.)

HJMTree is the Heath-Jarrow-Morton tree sampling of a forward-rate process, created using hjmtree. BDTTree is the Black-Derman-Toy tree sampling of an interest-rate process, created using bdttree. See Building a Tree of Forward Rates to learn how to create these structures.

InstSet is the set of instruments to be priced. This structure represents the set of instruments to be priced independently using the model. Getting Started, explains how to create this variable.

Options is an options structure created with the function derivset. This structure defines how the tree is used to find the price of instruments in the portfolio, and how much additional information is displayed in the command window when calling the pricing function. If this input argument is not specified in the call to the pricing function, a default Options structure is used. The pricing options structure is described in Pricing Options Structure.

The portfolio pricing functions classify the instruments and call the appropriate instrument-specific pricing function for each of the instrument types. The HJM instrument-specific pricing functions are bondbyhjm, cfbyhjm, fixedbyhjm, floatbyhjm, optbndbyhjm, swapbyhjm, and swaptionbyhjm. A similarly named set of functions exists for BDT models. For a list of these, see Black-Derman-Toy Trees.

You can also use these functions directly to calculate the price of sets of instruments of the same type. See Functions — Alphabetical List for these individual functions for further information.

HJM Pricing Example

Consider the following example, which uses the portfolio and interest-rate data in the MAT-file deriv.mat included in the toolbox. Load the data into the MATLAB workspace.

load deriv.mat

Use the MATLAB whos command to display a list of the variables loaded from the MAT-file.

whos

Name              Size            Bytes  Class     Attributes

  BDTInstSet        1x1             15956  struct              
  BDTTree           1x1              5138  struct              
  BKInstSet         1x1             15946  struct              
  BKTree            1x1              5904  struct              
  CRRInstSet        1x1             12434  struct              
  CRRTree           1x1              5058  struct              
  EQPInstSet        1x1             12434  struct              
  EQPTree           1x1              5058  struct              
  HJMInstSet        1x1             15948  struct              
  HJMTree           1x1              5838  struct              
  HWInstSet         1x1             15946  struct              
  HWTree            1x1              5904  struct              
  ITTInstSet        1x1             12438  struct              
  ITTTree           1x1              8862  struct              
  ZeroInstSet       1x1             10282  struct              
  ZeroRateSpec      1x1              1580  struct         

HJMTree and HJMInstSet are the input arguments required to call the function hjmprice.

Use the function instdisp to examine the set of instruments contained in the variable HJMInstSet.

instdisp(HJMInstSet)

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    UnderInd OptSpec Strike ExerciseDates  AmericanOpt Name        Quantity
3     OptBond 2        call    101    01-Jan-2003    NaN         Option 101  -50     
 
Index Type  CouponRate Settle      Maturity    FixedReset Basis Principal Name     Quantity
4     Fixed 0.04       01-Jan-2000 01-Jan-2003 1          NaN   NaN       4% Fixed 80      
 
Index Type  Spread Settle      Maturity    FloatReset  Basis Principal Name       Quantity
5     Float 20     01-Jan-2000 01-Jan-2003 1           NaN   NaN       20BP Float 8    
 
Index Type Strike Settle         Maturity       CapReset Basis Principal Name   Quantity
6     Cap  0.03   01-Jan-2000    01-Jan-2004    1        NaN   NaN       3% Cap 30      
 
Index Type  Strike Settle      Maturity       FloorReset Basis Principal Name     Quantity
7     Floor 0.03   01-Jan-2000 01-Jan-2004    1          NaN   NaN       3% Floor 40      
 
Index Type LegRate   Settle   Maturity   LegReset Basis Principal LegType  Name    Quantity
8     Swap [0.06 20] 01-Jan-2000 01-Jan-2003  [1  1]   NaN   NaN    [NaN]  6%/20BP Swap 10

Note that there are eight instruments in this portfolio set: two bonds, one bond option, one fixed-rate note, one floating-rate note, one cap, one floor, and one swap. Each instrument has a corresponding index that identifies the instrument prices in the price vector returned by hjmprice.

Now use hjmprice to calculate the price of each instrument in the instrument set.

Price = hjmprice(HJMTree, HJMInstSet)
Warning: Not all cash flows are aligned with the tree. Result will 
be approximated.

Price =

   98.7159
   97.5280
    0.0486
   98.7159
  100.5529
    6.2831
    0.0486
    3.6923

BDT Pricing Example

Load the MAT-file deriv.mat into the MATLAB workspace.

load deriv.mat

Use the MATLAB whos command to display a list of the variables loaded from the MAT-file.

whos

 Name              Size            Bytes  Class     Attributes

  BDTInstSet        1x1             15956  struct              
  BDTTree           1x1              5138  struct              
  BKInstSet         1x1             15946  struct              
  BKTree            1x1              5904  struct              
  CRRInstSet        1x1             12434  struct              
  CRRTree           1x1              5058  struct              
  EQPInstSet        1x1             12434  struct              
  EQPTree           1x1              5058  struct              
  HJMInstSet        1x1             15948  struct              
  HJMTree           1x1              5838  struct              
  HWInstSet         1x1             15946  struct              
  HWTree            1x1              5904  struct              
  ITTInstSet        1x1             12438  struct              
  ITTTree           1x1              8862  struct              
  ZeroInstSet       1x1             10282  struct              
  ZeroRateSpec      1x1              1580  struct         

BDTTree and BDTInstSet are the input arguments required to call the function bdtprice.

Use the function instdisp to examine the set of instruments contained in the variable BDTInstSet.

instdisp(BDTInstSet)


Index Type CouponRate Settle       Maturity     Period Basis ........  Name    Quantity
1     Bond 0.1        01-Jan-2000  01-Jan-2003  1      NaN.........    10% bond  100 
2     Bond 0.1        01-Jan-2000  01-Jan-2004  2      NaN.........    10% bond  50 

Index Type    UnderInd OptSpec Strike ExerciseDates  AmericanOpt Name      Quantity
3     OptBond 1        call    9501   Jan-2002       NaN         Option 95   -50     
 
Index Type  CouponRate Settle      Maturity       FixedReset Basis Principal Name  Quantity
4     Fixed 0.10       01-Jan-2000 01-Jan-2003    1          NaN   NaN      10% Fixed 80 
 
Index Type  Spread Settle      Maturity    FloatReset  Basis Principal Name       Quantity
5     Float 20     01-Jan-2000 01-Jan-2003 1           NaN   NaN       20BP Float 8   
 
Index Type Strike Settle         Maturity       CapReset Basis Principal Name    Quantity
6     Cap  0.15   01-Jan-2000    01-Jan-2004    1        NaN   NaN       15% Cap 30   
 
Index Type  Strike Settle      Maturity       FloorReset Basis Principal Name    Quantity
7     Floor 0.09   01-Jan-2000 01-Jan-2004    1          NaN   NaN       9% Floor 40   
 
Index Type LegRate   Settle   Maturity  LegReset Basis Principal LegType Name   Quantity
8     Swap [0.15 10] 01-Jan-2000  01-Jan-2003  [1  1]  NaN   NaN  [NaN] 15%/10BP Swap 10 

Note that there are eight instruments in this portfolio set: two bonds, one bond option, one fixed-rate note, one floating-rate note, one cap, one floor, and one swap. Each instrument has a corresponding index that identifies the instrument prices in the price vector returned by bdtprice.

Now use bdtprice to calculate the price of each instrument in the instrument set.

Price = bdtprice(BDTTree, BDTInstSet)
Warning: Not all cash flows are aligned with the tree. Result will 
be approximated.

Price =

   95.5030
   93.9079
    1.7657
   95.5030
  100.4865
    1.4863
    0.0245
    7.4222

Price Vector Output

The prices in the output vector Price correspond to the prices at observation time zero (tObs = 0), which is defined as the valuation date of the interest-rate tree. The instrument indexing within Price is the same as the indexing within InstSet.

In the HJM example, the prices in the Price vector correspond to the instruments in this order.

InstNames = instget(HJMInstSet, 'FieldName','Name')

InstNames =

4% bond     
4% bond     
Option 101  
4% Fixed    
20BP Float  
3% Cap      
3% Floor    
6%/20BP Swap

Consequently, in the Price vector, the fourth element, 98.7159, represents the price of the fourth instrument (4% fixed-rate note); the sixth element, 6.2831, represents the price of the sixth instrument (3% cap).

In the BDT example, the prices in the Price vector correspond to the instruments in this order.

InstNames = instget(BDTInstSet, 'FieldName','Name')

InstNames =

10% Bond     
10% Bond     
Option 95    
10% Fixed    
20BP Float   
15% Cap      
9% Floor     
15%/10BP Swap

Consequently, in the Price vector, the fourth element, 95.5030, represents the price of the fourth instrument (10% fixed-rate note); the sixth element, 1.4863, represents the price of the sixth instrument (15% cap).

Price Tree Structure Output

If you call a pricing function with two output arguments, for example,

[Price, PriceTree] = hjmprice(HJMTree, HJMInstSet) 

you generate a price tree along with the price information.

The optional output price tree structure PriceTree holds all the pricing information.

HJM Price Tree.   In the HJM example, the first field of this structure, FinObj, indicates that this structure represents a price tree. The second field, PBush, is the tree holding the price of the instruments in each node of the tree. The third field, AIBush, is the tree holding the accrued interest of the instruments in each node of the tree. Finally, the fourth field, tObs, represents the observation time of each level of PBush and AIBush, with units in terms of compounding periods.

In this example, the price tree looks like

PriceTree = 

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

Both PBush and AIBush are 1-by-5 cell arrays, consistent with the five observation times of tObs. The data display has been shortened here to fit on a single line.

Using the command line interface, you can directly examine PriceTree.PBush, the field within the PriceTree structure that contains the price tree with the price vectors at every state. The first node represents tObs = 0, corresponding to the valuation date.

PriceTree.PBush{1}

ans =

   98.7159
   97.5280
    0.0486
   98.7159
  100.5529
    6.2831
    0.0486
    3.6923

With this interface, you can observe the prices for all instruments in the portfolio at a specific time.

BDT Price Tree.   The BDT output price tree structure PriceTree holds all the pricing information. The first field of this structure, FinObj, indicates that this structure represents a price tree. The second field, PTree, is the tree holding the price of the instruments in each node of the tree. The third field, AITree, is the tree holding the accrued interest of the instruments in each node of the tree. The fourth field, tObs, represents the observation time of each level of PTree and AITree, with units in terms of compounding periods.

You can directly examine the field within the PriceTree structure, which contains the price tree with the price vectors at every state. The first node represents tObs = 0, corresponding to the valuation date.

[Price, PriceTree] = bdtprice(BDTTree, BDTInstSet)

PriceTree.PTree{1}

ans =

   95.5030
   93.9079
    1.7657
   95.5030
  100.4865
    1.4863
    0.0245
    7.4222

Computing Instrument Sensitivities

Sensitivities can be reported either as dollar price changes or percentage price changes. The delta, gamma, and vega sensitivities that the toolbox computes are dollar sensitivities.

The functions hjmsens and bdtsens compute the delta, gamma, and vega sensitivities of instruments using an interest-rate tree. They also optionally return the calculated price for each instrument. The sensitivity functions require the same two input arguments used by the pricing functions (HJMTree and HJMInstSet for HJM; BDTTree and BDTInstSet for BDT).

Sensitivity functions calculate the dollar value of delta and gamma by shifting the observed forward yield curve by 100 basis points in each direction, and the dollar value of vega by shifting the volatility process by 1%. To obtain the per-dollar value of the sensitivities, divide the dollar sensitivity by the price of the corresponding instrument.

HJM Sensitivities Example

The calling syntax for the function is:

[Delta, Gamma, Vega, Price] = hjmsens(HJMTree, HJMInstSet)

Use the previous example data to calculate the price of instruments.

load deriv.mat
[Delta, Gamma, Vega, Price] = hjmsens(HJMTree, HJMInstSet);
Warning: Not all cash flows are aligned with the tree. Result will
be approximated.

You can conveniently examine the sensitivities and the prices by arranging them into a single matrix.

All = [Delta, Gamma, Vega, Price]

All =

       -272.65       1029.90          0.00         98.72
       -347.43       1622.69         -0.04         97.53
         -8.08        643.40         34.07          0.05
       -272.65       1029.90          0.00         98.72
         -1.04          3.31             0        100.55
        294.97       6852.56         93.69          6.28
        -47.16       8459.99         93.69          0.05
       -282.05       1059.68          0.00          3.69

As with the prices, each row of the sensitivity vectors corresponds to the similarly indexed instrument in HJMInstSet. To view the per-dollar sensitivities, divide each dollar sensitivity by the corresponding instrument price.

BDT Sensitivities Example

The calling syntax for the function is:

[Delta, Gamma, Vega, Price] = bdtsens(BDTTree, BDTInstSet);

Arrange the sensitivities and prices into a single matrix.

All = [Delta, Gamma, Vega, Price]

All =

     -232.67       803.71      -0.00       95.50
     -281.05      1181.93      -0.01       93.91
      -50.54       246.02       5.31        1.77
     -232.67       803.71          0       95.50
        0.84         2.45          0      100.49
       78.38       748.98      13.54        1.49
       -4.36       382.06       2.50        0.02
     -253.23       863.81          0        7.42

To view the per-dollar sensitivities, divide each dollar sensitivity by the corresponding instrument price.

All = [Delta ./ Price, Gamma ./ Price, Vega ./ Price, Price]

All =

       -2.44         8.42      -0.00       95.50
       -2.99        12.59      -0.00       93.91
      -28.63       139.34       3.01        1.77
       -2.44         8.42          0       95.50
        0.01         0.02          0      100.49
       52.73       503.92       9.11        1.49
     -177.89     15577.42     101.87        0.02
      -34.12       116.38          0        7.42
  


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-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS