| Contents | Index |
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 Diagnostics 'on'.
Options = derivset('ConstRate', 'off', 'Diagnostics', 'on')
Options =
Diagnostics: 'on'
Warnings: 'on'
ConstRate: 'off'
BarrierMethod: 'unenhanced'
To obtain the value of a specific property from the Options structure, use derivget.
CR = derivget(Options, 'ConstRate') CR = Off
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 January 1, 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.
size(BondPriceTree.PBush{end})
ans =
1 8
size(BondPriceTreeNoCR.PBush{end})
ans =
1 128
The differences become more obvious by examining the price trees with treeviewer.
treeviewer(BondPriceTree, BondPort)

treeviewer(BondPriceTreeNoCR, BondPort)

All = [Delta ./ Price, Gamma ./ Price, Vega ./ Price, Price]
All =
-2.76 10.43 0.00 98.72
-3.56 16.64 -0.00 97.53
-166.18 13235.59 700.96 0.05
-2.76 10.43 0.00 98.72
-0.01 0.03 0 100.55
46.95 1090.63 14.91 6.28
-969.85 173969.77 1926.72 0.05
-76.39 287.00 0.00 3.690
![]() | Pricing Options Structure | Bibliography | ![]() |
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 |