Financial Derivatives Toolbox | ![]() ![]() |
HJM Pricing Options Structure
The MATLAB structure Options
provides additional input to each pricing function. The Options
structure
You provide pricing options in an optional Options
argument passed to each pricing function. (See, for example, bondbyhjm
or hjmprice
.)
Default Structure
If you do not specify the Options
argument in the call to a pricing function, the function uses a default structure. To observe the default structure, use derivset
without any arguments.
The Options structure has three fields: Diagnostics
, Warnings
, and ConstRate
.
Diagnostics
indicates whether additional information is displayed if the HJM tree is modified. The default value for this option is 'off'
. If Diagnostics
is set to 'on'
and ConstRate
is set to 'off'
, the pricing functions display information such as the number of nodes in the last level of the HJM tree generated for pricing purposes.
Warnings
indicates whether to display warning messages when the input tree is not adequate for accurately pricing the instruments. The default value for this option is 'on'
. If both ConstRate
and Warnings
are 'on'
, a warning is displayed if any of the instruments in the input portfolio has a cash flow date between tree dates. If ConstRate
is 'off'
, and Warnings
is 'on'
, a warning is displayed if the tree is modified to match the cash flow dates on the instruments in the portfolio.
ConstRate
indicates whether the interest rates should be assumed constant between tree dates. By default this option is 'on'
, which is not an arbitrage-free assumption. Consequently the pricing functions return an approximate price for instruments featuring cash flows between tree dates. Instruments featuring cash flows only on tree nodes are not affected by this option and return exact (arbitrage-free) prices. When ConstRate
is 'off'
, the HJM pricing function finds the cash flow dates for all instruments in the portfolio. If these cash flows do not align exactly with the tree dates, a new tree is generated and used for pricing. This new tree features the same volatility and initial rate specifications of the input HJM tree but contains tree nodes for each date in which at least one instrument in the portfolio has a cash flow. Keep in mind that the number of nodes in an HJM tree grows exponentially with the number of tree dates. Consequently, setting ConstRate
'off'
dramatically increases the memory and CPU demands on the computer.
Customizing the Structure
Customize the Options structure by passing property name/property value pairs to the derivset
function.
As an example, consider an Options structure with ConstRate
'off'
and Diagonistics
'on'
.
Options = derivset('ConstRate', 'off', 'Diagnostics', 'on') Options = Diagnostics: 'on' Warnings: 'on' ConstRate: 'off'
To obtain the value of a specific property from the Options structure, use derivget
.
Note
Use derivset and derivget to construct the Options structure. These functions are guaranteed to remain unchanged, while the implementation of the structure itself may be modified in the future.
|
Now observe the effects of setting ConstRate
'off'
. Obtain the tree dates from the HJM tree.
TreeDates = [HJMTree.TimeSpec.ValuationDate;... HJMTree.TimeSpec.Maturity] TreeDates = 730486 730852 731217 731582 731947 datedisp(TreeDates) 01-Jan-2000 01-Jan-2001 01-Jan-2002 01-Jan-2003 01-Jan-2004
All instruments in HJMInstSet
settle on Jan 1st, 2000, and all have cash flows once a year, with the exception of the second bond, which features a period of 2. This bond has cash flows twice a year, with every other cash flow consequently falling between tree dates. You can extract this bond from the portfolio to compare how its price differs by setting ConstRate
to 'on'
and 'off'
.
BondPort = instselect(HJMInstSet, 'Index', 2); instdisp(BondPort) Index Type CouponRate Settle Maturity Period Basis... 1 Bond 0.04 01-Jan-2000 01-Jan-2004 2 NaN...
First price the bond with ConstRate
'on'
(default).
format long [BondPrice, BondPriceTree] = hjmprice(HJMTree, BondPort) Warning: Not all cash flows are aligned with the tree. Result will be approximated. BondPrice = 97.52801411736377 BondPriceTree = FinObj: 'HJMPriceTree' PBush: {1x5 cell} AIBush: {[0] [1x1x2 double] ... [1x4x2 double] [1x8 double]} tObs: [0 1 2 3 4]
Now recalculate the price of the bond setting ConstRate
'off'
.
OptionsNoCR = derivset('ConstR', 'off') OptionsNoCR = Diagnostics: 'off' Warnings: 'on' ConstRate: 'off' [BondPriceNoCR, BondPriceTreeNoCR] = hjmprice(HJMTree,... BondPort, OptionsNoCR) Warning: Not all cash flows are aligned with the tree. Rebuilding tree. BondPriceNoCR = 97.53342361674437 BondPriceTreeNoCR = FinObj: 'HJMPriceTree' PBush: {1x9 cell} AIBush: {1x9 cell} tObs: [0 0.5000 1 1.5000 2 2.5000 3 3.5000 4]
As indicated in the last warning, because the cash flows of the bond did not align with the tree dates, a new tree was generated for pricing the bond. This pricing method returns more accurate results since it guarantees that the process is arbitrage-free. It also takes longer to calculate and requires more memory. The tObs
field of the price tree structure indicates the increased memory usage. BondPriceTree.tObs
has only five elements, while BondPriceTreeNoCR.tObs
has nine. While this may not seem like a large difference, it has a dramatic effect on the number of states in the last node.
The differences become more obvious by examining the price trees with treeviewer
.
![]() | Using treeviewer to View Instrument Prices Through Time | Calculating Prices and Sensitivities | ![]() |