File: _repo_8cpp-example.html

package info (click to toggle)
quantlib-refman-html 0.3.14-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 43,500 kB
  • ctags: 8,975
  • sloc: makefile: 31
file content (316 lines) | stat: -rw-r--r-- 24,027 bytes parent folder | download
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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<meta name="robots" content="none">
<title>QuantLib: Repo.cpp</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.3.14</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="faq.html">Frequently asked questions</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="todo.html">Todo List</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="deprecated.html">Deprecated Features</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.1 -->
<h1>Repo.cpp</h1>This example evaluates a repo on a fixed-coupon bond.<p>
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */</span>
<a name="l00002"></a>00002 
<a name="l00020"></a>00020 <span class="comment">/* a Repo calculation done using the FixedCouponBondForward class</span>
<a name="l00021"></a>00021 <span class="comment">   cf. aaBondFwd() repo example at</span>
<a name="l00022"></a>00022 <span class="comment">   http://www.fincad.com/support/developerFunc/mathref/BFWD.htm</span>
<a name="l00023"></a>00023 <span class="comment"></span>
<a name="l00024"></a>00024 <span class="comment">   This repo is set up to use the repo rate to do all discounting</span>
<a name="l00025"></a>00025 <span class="comment">   (including the underlying bond income). Forward delivery price is</span>
<a name="l00026"></a>00026 <span class="comment">   also obtained using this repo rate. All this is done by supplying</span>
<a name="l00027"></a>00027 <span class="comment">   the FixedCouponBondForward constructor with a flat repo</span>
<a name="l00028"></a>00028 <span class="comment">   YieldTermStructure.</span>
<a name="l00029"></a>00029 <span class="comment">*/</span>
<a name="l00030"></a>00030 
<a name="l00031"></a>00031 <span class="comment">// the only header you need to use QuantLib</span>
<a name="l00032"></a>00032 <span class="preprocessor">#define BOOST_LIB_DIAGNOSTIC</span>
<a name="l00033"></a>00033 <span class="preprocessor"></span><span class="preprocessor">#  include &lt;ql/quantlib.hpp&gt;</span>
<a name="l00034"></a>00034 <span class="preprocessor">#undef BOOST_LIB_DIAGNOSTIC</span>
<a name="l00035"></a>00035 <span class="preprocessor"></span>
<a name="l00036"></a>00036 <span class="preprocessor">#ifdef BOOST_MSVC</span>
<a name="l00037"></a>00037 <span class="preprocessor"></span><span class="comment">/* Uncomment the following lines to unmask floating-point</span>
<a name="l00038"></a>00038 <span class="comment">   exceptions. Warning: unpredictable results can arise...</span>
<a name="l00039"></a>00039 <span class="comment"></span>
<a name="l00040"></a>00040 <span class="comment">   See http://www.wilmott.com/messageview.cfm?catid=10&amp;threadid=9481</span>
<a name="l00041"></a>00041 <span class="comment">   Is there anyone with a definitive word about this?</span>
<a name="l00042"></a>00042 <span class="comment">*/</span>
<a name="l00043"></a>00043 <span class="comment">// #include &lt;float.h&gt;</span>
<a name="l00044"></a>00044 <span class="comment">// namespace { unsigned int u = _controlfp(_EM_INEXACT, _MCW_EM); }</span>
<a name="l00045"></a>00045 <span class="preprocessor">#endif</span>
<a name="l00046"></a>00046 <span class="preprocessor"></span>
<a name="l00047"></a>00047 <span class="preprocessor">#include &lt;boost/timer.hpp&gt;</span>
<a name="l00048"></a>00048 <span class="preprocessor">#include &lt;iostream&gt;</span>
<a name="l00049"></a>00049 
<a name="l00050"></a>00050 <span class="keyword">using namespace </span>std;
<a name="l00051"></a>00051 <span class="keyword">using namespace </span>QuantLib;
<a name="l00052"></a>00052 
<a name="l00053"></a>00053 <span class="preprocessor">#if defined(QL_ENABLE_SESSIONS)</span>
<a name="l00054"></a>00054 <span class="preprocessor"></span><span class="keyword">namespace </span>QuantLib {
<a name="l00055"></a>00055 
<a name="l00056"></a>00056     <a name="a0"></a><a class="code" href="group__types.html#gb9c87440c314438e51a899a03d2442d0">Integer</a> sessionId() { <span class="keywordflow">return</span> 0; }
<a name="l00057"></a>00057 
<a name="l00058"></a>00058 }
<a name="l00059"></a>00059 <span class="preprocessor">#endif</span>
<a name="l00060"></a>00060 <span class="preprocessor"></span>
<a name="l00061"></a>00061 <span class="keywordtype">int</span> main(<span class="keywordtype">int</span>, <span class="keywordtype">char</span>* []) {
<a name="l00062"></a>00062 
<a name="l00063"></a>00063     <span class="keywordflow">try</span> {
<a name="l00064"></a>00064         <a name="a1"></a><a class="code" href="group__misc_macros.html#g11d8e34f54505b0bf6f550508278673d">QL_IO_INIT</a>
<a name="l00065"></a>00065 
<a name="l00066"></a>00066         boost::timer timer;
<a name="l00067"></a>00067         std::cout &lt;&lt; std::endl;
<a name="l00068"></a>00068 
<a name="l00069"></a>00069         <a name="_a2"></a><a class="code" href="class_quant_lib_1_1_date.html">Date</a> repoSettlementDate(14,February,2000);;
<a name="l00070"></a>00070         <a class="code" href="class_quant_lib_1_1_date.html">Date</a> repoDeliveryDate(15,August,2000);
<a name="l00071"></a>00071         <a name="a3"></a><a class="code" href="group__types.html#gede435af51236692b1107d7639581d39">Rate</a> repoRate = 0.05;
<a name="l00072"></a>00072         <a name="_a4"></a><a class="code" href="class_quant_lib_1_1_day_counter.html">DayCounter</a> repoDayCountConvention = <a name="_a5"></a><a class="code" href="class_quant_lib_1_1_actual360.html">Actual360</a>();
<a name="l00073"></a>00073         <a class="code" href="group__types.html#gb9c87440c314438e51a899a03d2442d0">Integer</a> repoSettlementDays = 0;
<a name="l00074"></a>00074         Compounding repoCompounding = Simple;
<a name="l00075"></a>00075         <a class="code" href="group__datetime.html#g6d41db8ba0ea90d22df35889df452ada">Frequency</a> repoCompoundFreq = <a name="a6"></a><a class="code" href="group__datetime.html#gg6d41db8ba0ea90d22df35889df452ada508b18014c96e2d466c12b39d7f4e426">Annual</a>;
<a name="l00076"></a>00076 
<a name="l00077"></a>00077         <span class="comment">// assume a ten year bond- this is irrelevant</span>
<a name="l00078"></a>00078         <a class="code" href="class_quant_lib_1_1_date.html">Date</a> bondIssueDate(15,September,1995);
<a name="l00079"></a>00079         <a class="code" href="class_quant_lib_1_1_date.html">Date</a> bondDatedDate(15,September,1995);
<a name="l00080"></a>00080         <a class="code" href="class_quant_lib_1_1_date.html">Date</a> bondMaturityDate(15,September,2005);
<a name="l00081"></a>00081         <a name="a7"></a><a class="code" href="group__types.html#g4bdf4bfe76b9ffa6fa64c47d8bfa0c78">Real</a> bondCoupon = 0.08;
<a name="l00082"></a>00082         <a class="code" href="group__datetime.html#g6d41db8ba0ea90d22df35889df452ada">Frequency</a> bondCouponFrequency = <a name="a8"></a><a class="code" href="group__datetime.html#gg6d41db8ba0ea90d22df35889df452adad1a5868a1c314bb7f6ab68e2fa182b2d">Semiannual</a>;
<a name="l00083"></a>00083         <span class="comment">// unknown what calendar fincad is using</span>
<a name="l00084"></a>00084         <a name="_a9"></a><a class="code" href="class_quant_lib_1_1_calendar.html">Calendar</a> bondCalendar = <a name="_a10"></a><a class="code" href="class_quant_lib_1_1_null_calendar.html">NullCalendar</a>();
<a name="l00085"></a>00085         <a class="code" href="class_quant_lib_1_1_day_counter.html">DayCounter</a> bondDayCountConvention = <a name="_a11"></a><a class="code" href="class_quant_lib_1_1_thirty360.html">Thirty360</a>(Thirty360::BondBasis);
<a name="l00086"></a>00086         <span class="comment">// unknown what fincad is using. this may affect accrued calculation</span>
<a name="l00087"></a>00087         <a class="code" href="group__types.html#gb9c87440c314438e51a899a03d2442d0">Integer</a> bondSettlementDays = 0;
<a name="l00088"></a>00088         <a class="code" href="group__datetime.html#gff46c5ae9385d20709bedade86edd368">BusinessDayConvention</a> bondBusinessDayConvention = <a name="a12"></a><a class="code" href="group__datetime.html#ggff46c5ae9385d20709bedade86edd3685fb8b90b7fdf1a3a228fbbc083e64547">Unadjusted</a>;
<a name="l00089"></a>00089         <a class="code" href="group__types.html#g4bdf4bfe76b9ffa6fa64c47d8bfa0c78">Real</a> bondCleanPrice = 89.97693786;
<a name="l00090"></a>00090         <a class="code" href="group__types.html#g4bdf4bfe76b9ffa6fa64c47d8bfa0c78">Real</a> bondRedemption = 100.0;
<a name="l00091"></a>00091         <a class="code" href="group__types.html#g4bdf4bfe76b9ffa6fa64c47d8bfa0c78">Real</a> faceAmount = 100.0;
<a name="l00092"></a>00092 
<a name="l00093"></a>00093 
<a name="l00094"></a>00094         Settings::instance().evaluationDate() = repoSettlementDate;
<a name="l00095"></a>00095 
<a name="l00096"></a>00096         <a name="_a13"></a><a class="code" href="class_quant_lib_1_1_handle.html">Handle&lt;YieldTermStructure&gt;</a> bondCurve;
<a name="l00097"></a>00097         bondCurve.<a name="a14"></a><a class="code" href="class_quant_lib_1_1_handle.html#7eec88ccb240dcc59ac81e7347c335bd">linkTo</a>(boost::shared_ptr&lt;YieldTermStructure&gt;(
<a name="l00098"></a>00098                                        <span class="keyword">new</span> <a name="_a15"></a><a class="code" href="class_quant_lib_1_1_flat_forward.html">FlatForward</a>(repoSettlementDate,
<a name="l00099"></a>00099                                                        .01, <span class="comment">// dummy rate</span>
<a name="l00100"></a>00100                                                        bondDayCountConvention,
<a name="l00101"></a>00101                                                        Compounded,
<a name="l00102"></a>00102                                                        bondCouponFrequency)));
<a name="l00103"></a>00103 
<a name="l00104"></a>00104 
<a name="l00105"></a>00105         boost::shared_ptr&lt;FixedCouponBond&gt; bond(
<a name="l00106"></a>00106                      <span class="keyword">new</span> <a name="_a16"></a><a class="code" href="class_quant_lib_1_1_fixed_coupon_bond.html">FixedCouponBond</a>(faceAmount,
<a name="l00107"></a>00107                                          bondIssueDate,
<a name="l00108"></a>00108                                          bondDatedDate,
<a name="l00109"></a>00109                                          bondMaturityDate,
<a name="l00110"></a>00110                                          bondSettlementDays,
<a name="l00111"></a>00111                                          std::vector&lt;Rate&gt;(1,bondCoupon),
<a name="l00112"></a>00112                                          bondCouponFrequency,
<a name="l00113"></a>00113                                          bondCalendar,
<a name="l00114"></a>00114                                          bondDayCountConvention,
<a name="l00115"></a>00115                                          bondBusinessDayConvention,
<a name="l00116"></a>00116                                          bondBusinessDayConvention,
<a name="l00117"></a>00117                                          bondRedemption,
<a name="l00118"></a>00118                                          bondCurve));
<a name="l00119"></a>00119 
<a name="l00120"></a>00120 
<a name="l00121"></a>00121         bondCurve.<a class="code" href="class_quant_lib_1_1_handle.html#7eec88ccb240dcc59ac81e7347c335bd">linkTo</a>(boost::shared_ptr&lt;YieldTermStructure&gt; (
<a name="l00122"></a>00122                    <span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_flat_forward.html">FlatForward</a>(repoSettlementDate,
<a name="l00123"></a>00123                                    bond-&gt;yield(bondCleanPrice,Compounded),
<a name="l00124"></a>00124                                    bondDayCountConvention,
<a name="l00125"></a>00125                                    Compounded,
<a name="l00126"></a>00126                                    bondCouponFrequency)));
<a name="l00127"></a>00127 
<a name="l00128"></a>00128         Position::Type fwdType = Position::Long;
<a name="l00129"></a>00129         <span class="keywordtype">double</span> dummyStrike = 91.5745;
<a name="l00130"></a>00130 
<a name="l00131"></a>00131         <a class="code" href="class_quant_lib_1_1_handle.html">Handle&lt;YieldTermStructure&gt;</a> repoCurve;
<a name="l00132"></a>00132         repoCurve.<a class="code" href="class_quant_lib_1_1_handle.html#7eec88ccb240dcc59ac81e7347c335bd">linkTo</a>(boost::shared_ptr&lt;YieldTermStructure&gt; (
<a name="l00133"></a>00133                                        <span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_flat_forward.html">FlatForward</a>(repoSettlementDate,
<a name="l00134"></a>00134                                                        repoRate,
<a name="l00135"></a>00135                                                        repoDayCountConvention,
<a name="l00136"></a>00136                                                        repoCompounding,
<a name="l00137"></a>00137                                                        repoCompoundFreq)));
<a name="l00138"></a>00138 
<a name="l00139"></a>00139 
<a name="l00140"></a>00140         <a name="_a17"></a><a class="code" href="class_quant_lib_1_1_fixed_coupon_bond_forward.html">FixedCouponBondForward</a> bondFwd(repoSettlementDate,
<a name="l00141"></a>00141                                        repoDeliveryDate,
<a name="l00142"></a>00142                                        fwdType,
<a name="l00143"></a>00143                                        dummyStrike,
<a name="l00144"></a>00144                                        repoSettlementDays,
<a name="l00145"></a>00145                                        repoDayCountConvention,
<a name="l00146"></a>00146                                        bondCalendar,
<a name="l00147"></a>00147                                        bondBusinessDayConvention,
<a name="l00148"></a>00148                                        bond,
<a name="l00149"></a>00149                                        repoCurve,
<a name="l00150"></a>00150                                        repoCurve);
<a name="l00151"></a>00151 
<a name="l00152"></a>00152 
<a name="l00153"></a>00153         cout &lt;&lt; <span class="stringliteral">"Underlying bond clean price: "</span>
<a name="l00154"></a>00154              &lt;&lt; bond-&gt;cleanPrice()
<a name="l00155"></a>00155              &lt;&lt; endl;
<a name="l00156"></a>00156         cout &lt;&lt; <span class="stringliteral">"Underlying bond dirty price: "</span>
<a name="l00157"></a>00157              &lt;&lt; bond-&gt;dirtyPrice()
<a name="l00158"></a>00158              &lt;&lt; endl;
<a name="l00159"></a>00159         cout &lt;&lt; <span class="stringliteral">"Underlying bond accrued at settlement: "</span>
<a name="l00160"></a>00160              &lt;&lt; bond-&gt;accruedAmount(repoSettlementDate)
<a name="l00161"></a>00161              &lt;&lt; endl;
<a name="l00162"></a>00162         cout &lt;&lt; <span class="stringliteral">"Underlying bond accrued at delivery:   "</span>
<a name="l00163"></a>00163              &lt;&lt; bond-&gt;accruedAmount(repoDeliveryDate)
<a name="l00164"></a>00164              &lt;&lt; endl;
<a name="l00165"></a>00165         cout &lt;&lt; <span class="stringliteral">"Underlying bond spot income: "</span>
<a name="l00166"></a>00166              &lt;&lt; bondFwd.spotIncome(repoCurve)
<a name="l00167"></a>00167              &lt;&lt; endl;
<a name="l00168"></a>00168         cout &lt;&lt; <span class="stringliteral">"Underlying bond fwd income:  "</span>
<a name="l00169"></a>00169              &lt;&lt; bondFwd.spotIncome(repoCurve)/
<a name="l00170"></a>00170                 repoCurve-&gt;discount(repoDeliveryDate)
<a name="l00171"></a>00171              &lt;&lt; endl;
<a name="l00172"></a>00172         cout &lt;&lt; <span class="stringliteral">"Repo strike: "</span>
<a name="l00173"></a>00173              &lt;&lt; dummyStrike
<a name="l00174"></a>00174              &lt;&lt; endl;
<a name="l00175"></a>00175         cout &lt;&lt; <span class="stringliteral">"Repo NPV:    "</span>
<a name="l00176"></a>00176              &lt;&lt; bondFwd.NPV()
<a name="l00177"></a>00177              &lt;&lt; endl;
<a name="l00178"></a>00178         cout &lt;&lt; <span class="stringliteral">"Repo clean forward price: "</span>
<a name="l00179"></a>00179              &lt;&lt; bondFwd.cleanForwardPrice()
<a name="l00180"></a>00180              &lt;&lt; endl;
<a name="l00181"></a>00181         cout &lt;&lt; <span class="stringliteral">"Repo dirty forward price: "</span>
<a name="l00182"></a>00182              &lt;&lt; bondFwd.forwardPrice()
<a name="l00183"></a>00183              &lt;&lt; endl;
<a name="l00184"></a>00184         cout &lt;&lt; <span class="stringliteral">"Repo implied yield: "</span>
<a name="l00185"></a>00185              &lt;&lt; bondFwd.impliedYield(bond-&gt;dirtyPrice(),
<a name="l00186"></a>00186                                      dummyStrike,
<a name="l00187"></a>00187                                      repoSettlementDate,
<a name="l00188"></a>00188                                      repoCompounding,
<a name="l00189"></a>00189                                      repoDayCountConvention)
<a name="l00190"></a>00190              &lt;&lt; endl;
<a name="l00191"></a>00191         cout &lt;&lt; <span class="stringliteral">"Market repo rate:   "</span>
<a name="l00192"></a>00192              &lt;&lt; repoCurve-&gt;zeroRate(repoDeliveryDate,
<a name="l00193"></a>00193                                     repoDayCountConvention,
<a name="l00194"></a>00194                                     repoCompounding,
<a name="l00195"></a>00195                                     repoCompoundFreq)
<a name="l00196"></a>00196              &lt;&lt; endl
<a name="l00197"></a>00197              &lt;&lt; endl;
<a name="l00198"></a>00198 
<a name="l00199"></a>00199         cout &lt;&lt; <span class="stringliteral">"Compare with example given at \n"</span>
<a name="l00200"></a>00200              &lt;&lt; <span class="stringliteral">"http://www.fincad.com/support/developerFunc/mathref/BFWD.htm"</span>
<a name="l00201"></a>00201              &lt;&lt;  endl;
<a name="l00202"></a>00202         cout &lt;&lt; <span class="stringliteral">"Clean forward price = 88.2408"</span>
<a name="l00203"></a>00203              &lt;&lt;  endl
<a name="l00204"></a>00204              &lt;&lt;  endl;
<a name="l00205"></a>00205         cout &lt;&lt; <span class="stringliteral">"In that example, it is unknown what bond calendar they are\n"</span>
<a name="l00206"></a>00206              &lt;&lt; <span class="stringliteral">"using, as well as settlement Days. For that reason, I have\n"</span>
<a name="l00207"></a>00207              &lt;&lt; <span class="stringliteral">"made the simplest possible assumptions here: NullCalendar\n"</span>
<a name="l00208"></a>00208              &lt;&lt; <span class="stringliteral">"and 0 settlement days."</span>
<a name="l00209"></a>00209              &lt;&lt; endl;
<a name="l00210"></a>00210 
<a name="l00211"></a>00211 
<a name="l00212"></a>00212         <a class="code" href="group__types.html#g4bdf4bfe76b9ffa6fa64c47d8bfa0c78">Real</a> seconds = timer.elapsed();
<a name="l00213"></a>00213         <a class="code" href="group__types.html#gb9c87440c314438e51a899a03d2442d0">Integer</a> hours = int(seconds/3600);
<a name="l00214"></a>00214         seconds -= hours * 3600;
<a name="l00215"></a>00215         <a class="code" href="group__types.html#gb9c87440c314438e51a899a03d2442d0">Integer</a> minutes = int(seconds/60);
<a name="l00216"></a>00216         seconds -= minutes * 60;
<a name="l00217"></a>00217         cout &lt;&lt; <span class="stringliteral">" \nRun completed in "</span>;
<a name="l00218"></a>00218         <span class="keywordflow">if</span> (hours &gt; 0)
<a name="l00219"></a>00219             cout &lt;&lt; hours &lt;&lt; <span class="stringliteral">" h "</span>;
<a name="l00220"></a>00220         <span class="keywordflow">if</span> (hours &gt; 0 || minutes &gt; 0)
<a name="l00221"></a>00221             cout &lt;&lt; minutes &lt;&lt; <span class="stringliteral">" m "</span>;
<a name="l00222"></a>00222         cout &lt;&lt; fixed &lt;&lt; setprecision(0)
<a name="l00223"></a>00223              &lt;&lt; seconds &lt;&lt; <span class="stringliteral">" s\n"</span> &lt;&lt; endl;
<a name="l00224"></a>00224 
<a name="l00225"></a>00225         <span class="keywordflow">return</span> 0;
<a name="l00226"></a>00226 
<a name="l00227"></a>00227     } <span class="keywordflow">catch</span> (exception&amp; e) {
<a name="l00228"></a>00228         cout &lt;&lt; e.what() &lt;&lt; endl;
<a name="l00229"></a>00229         <span class="keywordflow">return</span> 1;
<a name="l00230"></a>00230     } <span class="keywordflow">catch</span> (...) {
<a name="l00231"></a>00231         cout &lt;&lt; <span class="stringliteral">"unknown error"</span> &lt;&lt; endl;
<a name="l00232"></a>00232         <span class="keywordflow">return</span> 1;
<a name="l00233"></a>00233     }
<a name="l00234"></a>00234 }
<a name="l00235"></a>00235 
</pre></div> 
</div>

<div class="footer">

<table align="top" width="100%">
<tr>
<td align="middle" width="33%">
<strong>QuantLib.org</strong><br>
<a href="http://quantlib.org/">
<img src="QL-small.jpg" alt="QuantLib" align="middle" border=0>
</a>
</td>
<td align="middle" width="33%">
<strong>Hosted by</strong><br>
<a href="http://sourceforge.net"><img src=
"sfnetlogo.png" width="88" height="31"
border="0" alt="SourceForge.net Logo"></a>
</td>
<td align="middle" width="33%">
<strong>Documentation generated by</strong><br>
<a href="http://www.doxygen.org">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 width=110 height=53>
</a></td>
</tr>
</table>
</div>

</div>

</body>
</html>