1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<meta name="robots" content="none">
<title>QuantLib: Financial instruments</title>
<link rel="stylesheet" href="quantlib.css" type="text/css">
<link rel="stylesheet" href="print.css" type="text/css" media="print">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<link rel="icon" href="favicon.ico" type="image/x-icon">
</head>
<body>
<div id="container">
<div id="header">
<img class="titleimage"
src="QL-title.jpg" width="212" height="47" border="0"
alt="QuantLib">
<br>
<h3 class="subtitle">A free/open-source library for quantitative finance</h3>
</div>
<div id="menu">
<h3 class="navbartitle">Version 0.9.0</h3>
<hr>
<h3 class="navbartitle">Getting started</h3>
<ul class="navbarlist">
<li class="navlink"><a href="index.html">Introduction</a></li>
<li class="navlink"><a href="overview.html">Project overview</a></li>
<li class="navlink"><a href="where.html">Where to get QuantLib</a></li>
<li class="navlink"><a href="install.html">Installation</a></li>
<li class="navlink"><a href="config.html">Configuration</a></li>
<li class="navlink"><a href="usage.html">Usage</a></li>
<li class="navlink"><a href="history.html">Version history</a></li>
<li class="navlink"><a href="resources.html">Additional resources</a></li>
<li class="navlink"><a href="group.html">The QuantLib group</a></li>
<li class="navlink"><a href="license.html">Copyright and license</a></li>
</ul>
<hr>
<h3 class="navbartitle">Reference manual</h3>
<ul class="navbarlist">
<li class="navlink"><a href="modules.html">Modules</a></li>
<li class="navlink"><a href="hierarchy.html">Class Hierarchy</a></li>
<li class="navlink"><a href="annotated.html">Compound List</a></li>
<li class="navlink"><a href="files.html">File List</a></li>
<li class="navlink"><a href="functions.html">Compound Members</a></li>
<li class="navlink"><a href="globals.html">File Members</a></li>
<li class="navlink"><a href="bug.html">Known Bugs</a></li>
<li class="navlink"><a href="caveats.html">Caveats</a></li>
<li class="navlink"><a href="test.html">Test Suite</a></li>
<li class="navlink"><a href="examples.html">Examples</a></li>
</ul>
</div>
<div id="content">
<!--Doxygen-generated content-->
<!-- Generated by Doxygen 1.5.4 -->
<h1>Financial instruments</h1><hr><a name="_details"></a><h2>Detailed Description</h2>
Since version 0.3.4, the <code>Instrument</code> class was reworked as shown in the following figure.<p>
<p>
<center><img src="instrument.png" alt="UML diagram"></center>
<p>
On the one hand, the checking of the expiration condition is now performed in a method <code>isExpired()</code> separated from the actual calculation, and a <code>setupExpired()</code> method is provided. The latter sets the NPV to 0.0 and can be extended in derived classes should any other results be returned.<p>
On the other hand, the pricing-engine machinery previously contained in the Option class was moved upwards to the Instrument class. Also, the <code>setupEngine()</code> method was replaced by a <code>setupArguments(Arguments*)</code> method. This allows one to cleanly implement containment of instruments with code such as:<p>
<div class="fragment"><pre class="fragment"> <span class="keyword">class </span>FooArguments : <span class="keyword">public</span> Arguments { ... };
<span class="keyword">class </span>Foo : <span class="keyword">public</span> Instrument {
<span class="keyword">public</span>:
<span class="keywordtype">void</span> setupArguments(Arguments*);
...
};
<span class="keyword">class </span>FooOptionArguments : <span class="keyword">public</span> FooArguments { ... };
<span class="keyword">class </span>FooOption : <span class="keyword">public</span> Option {
<span class="keyword">private</span>:
Foo underlying_;
<span class="keyword">public</span>:
<span class="keywordtype">void</span> setupArguments(Arguments* args) {
underlying_.setupArguments(args);
<span class="comment">// set the option-specific part</span>
}
...
};
</pre></div><p>
which was more difficult to write with <code>setupEngine()</code>.<p>
Therefore, there are now two ways to inherit from <code>Instrument</code>, namely:<p>
<ol type=1>
<li>implement the <code>isExpired</code> method, and completely override the <code>performCalculations</code> method so that it bypasses the pricing-engine machinery. If the class declared any other results beside <code>NPV_</code> and <code>errorEstimate_</code>, the <code>setupExpired</code> method should also be extended so that those results are set to a value suitable for an expired instrument. This was the migration path taken for all instruments not previously deriving from the <code>Option</code> class.</li><li>define suitable argument and result classes for the instrument and implement the <code>isExpired</code> and <code>setupArguments</code> methods, reusing the pricing-engine machinery provided by the default <code>performCalculations</code> method. The latter can be extended by first calling the default implementation and then performing any additional tasks required by the instrument---most often, copying additional results from the pricing engine results to the corresponding data members of the instrument. As in the previous case, the <code>setupExpired</code> method can be extended to account for such extra data members. </li></ol>
<p>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Classes</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">class </td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_digital_coupon.html">DigitalCoupon</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Digital-payoff coupon. <a href="class_quant_lib_1_1_digital_coupon.html#_details">More...</a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">class </td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_continuous_averaging_asian_option.html">ContinuousAveragingAsianOption</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Continuous-averaging Asian option. <a href="class_quant_lib_1_1_continuous_averaging_asian_option.html#_details">More...</a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">class </td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_discrete_averaging_asian_option.html">DiscreteAveragingAsianOption</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Discrete-averaging Asian option. <a href="class_quant_lib_1_1_discrete_averaging_asian_option.html#_details">More...</a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">class </td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_asset_swap.html">AssetSwap</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Bullet bond vs Libor swap. <a href="class_quant_lib_1_1_asset_swap.html#_details">More...</a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">class </td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_barrier_option.html">BarrierOption</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Barrier option on a single asset. <a href="class_quant_lib_1_1_barrier_option.html#_details">More...</a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">class </td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_basket_option.html">BasketOption</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Basket option on a number of assets. <a href="class_quant_lib_1_1_basket_option.html#_details">More...</a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">class </td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_bond.html">Bond</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Base bond class. <a href="class_quant_lib_1_1_bond.html#_details">More...</a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">class </td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_cms_rate_bond.html">CmsRateBond</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">CMS-rate bond. <a href="class_quant_lib_1_1_cms_rate_bond.html#_details">More...</a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">class </td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_fixed_rate_bond.html">FixedRateBond</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">fixed-rate bond <a href="class_quant_lib_1_1_fixed_rate_bond.html#_details">More...</a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">class </td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_floating_rate_bond.html">FloatingRateBond</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">floating-rate bond (possibly capped and/or floored) <a href="class_quant_lib_1_1_floating_rate_bond.html#_details">More...</a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">class </td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_zero_coupon_bond.html">ZeroCouponBond</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">zero-coupon bond <a href="class_quant_lib_1_1_zero_coupon_bond.html#_details">More...</a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">class </td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_cap_floor.html">CapFloor</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Base class for cap-like instruments. <a href="class_quant_lib_1_1_cap_floor.html#_details">More...</a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">class </td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_cap.html">Cap</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Concrete cap class. <a href="class_quant_lib_1_1_cap.html#_details">More...</a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">class </td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_floor.html">Floor</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Concrete floor class. <a href="class_quant_lib_1_1_floor.html#_details">More...</a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">class </td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_collar.html">Collar</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Concrete collar class. <a href="class_quant_lib_1_1_collar.html#_details">More...</a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">class </td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_cliquet_option.html">CliquetOption</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">cliquet (Ratchet) option <a href="class_quant_lib_1_1_cliquet_option.html#_details">More...</a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">class </td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_composite_instrument.html">CompositeInstrument</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Composite instrument <a href="class_quant_lib_1_1_composite_instrument.html#_details">More...</a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">class </td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_dividend_vanilla_option.html">DividendVanillaOption</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Single-asset vanilla option (no barriers) with discrete dividends. <a href="class_quant_lib_1_1_dividend_vanilla_option.html#_details">More...</a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">class </td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_european_option.html">EuropeanOption</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">European option on a single asset. <a href="class_quant_lib_1_1_european_option.html#_details">More...</a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">class </td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_fixed_rate_bond_forward.html">FixedRateBondForward</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Forward contract on a fixed-rate bond <a href="class_quant_lib_1_1_fixed_rate_bond_forward.html#_details">More...</a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">class </td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_forward.html">Forward</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Abstract base forward class. <a href="class_quant_lib_1_1_forward.html#_details">More...</a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">class </td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_forward_vanilla_option.html">ForwardVanillaOption</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Forward version of a vanilla option <a href="class_quant_lib_1_1_forward_vanilla_option.html#_details">More...</a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">class </td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_inflation_swap.html">InflationSwap</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Abstract base class for inflation swaps. <a href="class_quant_lib_1_1_inflation_swap.html#_details">More...</a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">class </td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_continuous_floating_lookback_option.html">ContinuousFloatingLookbackOption</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Continuous-floating lookback option. <a href="class_quant_lib_1_1_continuous_floating_lookback_option.html#_details">More...</a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">class </td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_continuous_fixed_lookback_option.html">ContinuousFixedLookbackOption</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Continuous-fixed lookback option. <a href="class_quant_lib_1_1_continuous_fixed_lookback_option.html#_details">More...</a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">class </td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_quanto_forward_vanilla_option.html">QuantoForwardVanillaOption</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Quanto version of a forward vanilla option. <a href="class_quant_lib_1_1_quanto_forward_vanilla_option.html#_details">More...</a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">class </td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_quanto_vanilla_option.html">QuantoVanillaOption</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">quanto version of a vanilla option <a href="class_quant_lib_1_1_quanto_vanilla_option.html#_details">More...</a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">class </td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_stock.html">Stock</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Simple stock class. <a href="class_quant_lib_1_1_stock.html#_details">More...</a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">class </td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_swap.html">Swap</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Interest rate swap. <a href="class_quant_lib_1_1_swap.html#_details">More...</a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">class </td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_swaption.html">Swaption</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Swaption class <a href="class_quant_lib_1_1_swaption.html#_details">More...</a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">class </td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_vanilla_option.html">VanillaOption</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Vanilla option (no discrete dividends, no barriers) on a single asset. <a href="class_quant_lib_1_1_vanilla_option.html#_details">More...</a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">class </td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_vanilla_swap.html">VanillaSwap</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Plain-vanilla swap. <a href="class_quant_lib_1_1_vanilla_swap.html#_details">More...</a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">class </td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_variance_swap.html">VarianceSwap</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Variance swap. <a href="class_quant_lib_1_1_variance_swap.html#_details">More...</a><br></td></tr>
</table>
</div>
<div class="footer">
<div class="endmatter">
Documentation generated by
<a href="http://www.doxygen.org">Doxygen</a> 1.5.4
</div>
</div>
</div>
</body>
</html>
|