Financial Derivatives Toolbox    

Pricing and Sensitivity from HJM

This section explains how to use the Financial Derivatives Toolbox to compute prices and sensitivities of several financial instruments using the Heath-Jarrow-Morton (HJM) model. For information, see:

Pricing and the Price Tree

For the HJM model, the function hjmprice calculates the price of any set of supported instruments, based on an interest rate tree. The function is capable of pricing these instrument types:

The syntax used for calling hjmprice is

This function requires two input arguments: the interest rate tree, HJMTree, and the set of instruments, InstSet. An optional argument Options further controls the pricing and the output displayed.

HJMTree is the Heath-Jarrow-Morton tree sampling of a forward rate process, created using hjmtree. See Building an HJM Forward Rate Tree to learn how to create this structure.

InstSet is the set of instruments to be priced. This structure represents the set of instruments to be priced independently using the HJM model. The section Creating and Managing Instrument Portfolios explains how to create this variable.

Options is an options structure created with the function derivset. This structure defines how the HJM 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 hjmprice, a default Options structure is used.

hjmprice classifies the instruments and calls the appropriate pricing function for each one of the instrument types. The pricing functions are bondbyhjm, cfbyhjm, fixedbyhjm, floatbyhjm, optbndbyhjm, and swapbyhjm. You can also use these functions directly to calculate the price of sets of instruments of the same type. See the documentation for these individual functions for further information.

Example: HJM Pricing

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.

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

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

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

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 Vector

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 this example, the prices in the Price vector correspond to the instruments in the following order.

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

Price Tree Structure

If you call the hjmprice function with two output arguments, e.g.,

you generate a price tree along with the price information.

The optional 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, 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

Both PBush and AIBush are actually 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.

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


  Using HJM Trees in MATLAB Using treeviewer to View Instrument Prices Through Time