File: class_quant_lib_1_1_cashflows.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 (436 lines) | stat: -rw-r--r-- 25,507 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
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
<!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: Cashflows Class Reference</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 -->
<div class="nav">
<b>QuantLib</b>::<a class="el" href="class_quant_lib_1_1_cashflows.html">Cashflows</a></div>
<h1>Cashflows Class Reference</h1><!-- doxytag: class="QuantLib::Cashflows" --><code>#include &lt;ql/CashFlows/analysis.hpp&gt;</code>
<p>
<a href="class_quant_lib_1_1_cashflows-members.html">List of all members.</a><hr><a name="_details"></a><h2>Detailed Description</h2>
cashflows analysis functions 
<p>
<dl compact><dt><b><a class="el" href="todo.html#_todo000002">Todo:</a></b></dt><dd>add tests </dd></dl>

<p>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Static Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">static <a class="el" href="group__types.html#g4bdf4bfe76b9ffa6fa64c47d8bfa0c78">Real</a>&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_cashflows.html#0787b5a6401d359520d6b74c4250601e">npv</a> (const std::vector&lt; boost::shared_ptr&lt; <a class="el" href="class_quant_lib_1_1_cash_flow.html">CashFlow</a> &gt; &gt; &amp;, const <a class="el" href="class_quant_lib_1_1_handle.html">Handle</a>&lt; <a class="el" href="class_quant_lib_1_1_yield_term_structure.html">YieldTermStructure</a> &gt; &amp;)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">NPV of the cash flows.  <a href="#0787b5a6401d359520d6b74c4250601e"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">static <a class="el" href="group__types.html#g4bdf4bfe76b9ffa6fa64c47d8bfa0c78">Real</a>&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_cashflows.html#cb7212d4823e87c8065e3815a1700c45">npv</a> (const std::vector&lt; boost::shared_ptr&lt; <a class="el" href="class_quant_lib_1_1_cash_flow.html">CashFlow</a> &gt; &gt; &amp;, const <a class="el" href="class_quant_lib_1_1_interest_rate.html">InterestRate</a> &amp;, <a class="el" href="class_quant_lib_1_1_date.html">Date</a> settlementDate=<a class="el" href="class_quant_lib_1_1_date.html">Date</a>())</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">NPV of the cash flows.  <a href="#cb7212d4823e87c8065e3815a1700c45"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">static <a class="el" href="group__types.html#g4bdf4bfe76b9ffa6fa64c47d8bfa0c78">Real</a>&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_cashflows.html#9275953ec871b533c6f9dbd28028f4d8">bps</a> (const std::vector&lt; boost::shared_ptr&lt; <a class="el" href="class_quant_lib_1_1_cash_flow.html">CashFlow</a> &gt; &gt; &amp;, const <a class="el" href="class_quant_lib_1_1_handle.html">Handle</a>&lt; <a class="el" href="class_quant_lib_1_1_yield_term_structure.html">YieldTermStructure</a> &gt; &amp;)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Basis-point sensitivity of the cash flows.  <a href="#9275953ec871b533c6f9dbd28028f4d8"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">static <a class="el" href="group__types.html#g4bdf4bfe76b9ffa6fa64c47d8bfa0c78">Real</a>&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_cashflows.html#339005671cfd4aa3d655c5a973776ef3">bps</a> (const std::vector&lt; boost::shared_ptr&lt; <a class="el" href="class_quant_lib_1_1_cash_flow.html">CashFlow</a> &gt; &gt; &amp;, const <a class="el" href="class_quant_lib_1_1_interest_rate.html">InterestRate</a> &amp;, <a class="el" href="class_quant_lib_1_1_date.html">Date</a> settlementDate=<a class="el" href="class_quant_lib_1_1_date.html">Date</a>())</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Basis-point sensitivity of the cash flows.  <a href="#339005671cfd4aa3d655c5a973776ef3"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">static <a class="el" href="group__types.html#gede435af51236692b1107d7639581d39">Rate</a>&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_cashflows.html#ab6aff01e22a5a1d97ccde47a65a882f">irr</a> (const std::vector&lt; boost::shared_ptr&lt; <a class="el" href="class_quant_lib_1_1_cash_flow.html">CashFlow</a> &gt; &gt; &amp;, <a class="el" href="group__types.html#g4bdf4bfe76b9ffa6fa64c47d8bfa0c78">Real</a> marketPrice, const <a class="el" href="class_quant_lib_1_1_day_counter.html">DayCounter</a> &amp;dayCounter, Compounding compounding, <a class="el" href="group__datetime.html#g6d41db8ba0ea90d22df35889df452ada">Frequency</a> frequency=NoFrequency, <a class="el" href="class_quant_lib_1_1_date.html">Date</a> settlementDate=<a class="el" href="class_quant_lib_1_1_date.html">Date</a>(), <a class="el" href="group__types.html#g4bdf4bfe76b9ffa6fa64c47d8bfa0c78">Real</a> tolerance=1.0e-10, Size maxIterations=10000, Rate guess=0.05)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Internal rate of return.  <a href="#ab6aff01e22a5a1d97ccde47a65a882f"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">static <a class="el" href="group__types.html#g14fb8fca43a68f4168654e1f9f7e22f7">Time</a>&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_cashflows.html#4758e38bc3be6c9b70d36f8b6ca5dbdc">duration</a> (const std::vector&lt; boost::shared_ptr&lt; <a class="el" href="class_quant_lib_1_1_cash_flow.html">CashFlow</a> &gt; &gt; &amp;, const <a class="el" href="class_quant_lib_1_1_interest_rate.html">InterestRate</a> &amp;y, Duration::Type type=Duration::Modified, <a class="el" href="class_quant_lib_1_1_date.html">Date</a> settlementDate=<a class="el" href="class_quant_lib_1_1_date.html">Date</a>())</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Cash-flow duration.  <a href="#4758e38bc3be6c9b70d36f8b6ca5dbdc"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">static <a class="el" href="group__types.html#g4bdf4bfe76b9ffa6fa64c47d8bfa0c78">Real</a>&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_cashflows.html#0a537cb39484e47843ee6da7e5320754">convexity</a> (const std::vector&lt; boost::shared_ptr&lt; <a class="el" href="class_quant_lib_1_1_cash_flow.html">CashFlow</a> &gt; &gt; &amp;, const <a class="el" href="class_quant_lib_1_1_interest_rate.html">InterestRate</a> &amp;y, <a class="el" href="class_quant_lib_1_1_date.html">Date</a> settlementDate=<a class="el" href="class_quant_lib_1_1_date.html">Date</a>())</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Cash-flow convexity.  <a href="#0a537cb39484e47843ee6da7e5320754"></a><br></td></tr>
</table>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="0787b5a6401d359520d6b74c4250601e"></a><!-- doxytag: member="QuantLib::Cashflows::npv" ref="0787b5a6401d359520d6b74c4250601e" args="(const std::vector&lt; boost::shared_ptr&lt; CashFlow &gt; &gt; &amp;, const Handle&lt; YieldTermStructure &gt; &amp;)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">static <a class="el" href="group__types.html#g4bdf4bfe76b9ffa6fa64c47d8bfa0c78">Real</a> npv           </td>
          <td>(</td>
          <td class="paramtype">const std::vector&lt; boost::shared_ptr&lt; <a class="el" href="class_quant_lib_1_1_cash_flow.html">CashFlow</a> &gt; &gt; &amp;&nbsp;</td>
          <td class="paramname">, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="class_quant_lib_1_1_handle.html">Handle</a>&lt; <a class="el" href="class_quant_lib_1_1_yield_term_structure.html">YieldTermStructure</a> &gt; &amp;&nbsp;</td>
          <td class="paramname"></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"><code> [static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
NPV of the cash flows. 
<p>
The NPV is the sum of the cash flows, each discounted according to the given term structure. 
</div>
</div><p>
<a class="anchor" name="cb7212d4823e87c8065e3815a1700c45"></a><!-- doxytag: member="QuantLib::Cashflows::npv" ref="cb7212d4823e87c8065e3815a1700c45" args="(const std::vector&lt; boost::shared_ptr&lt; CashFlow &gt; &gt; &amp;, const InterestRate &amp;, Date settlementDate=Date())" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">static <a class="el" href="group__types.html#g4bdf4bfe76b9ffa6fa64c47d8bfa0c78">Real</a> npv           </td>
          <td>(</td>
          <td class="paramtype">const std::vector&lt; boost::shared_ptr&lt; <a class="el" href="class_quant_lib_1_1_cash_flow.html">CashFlow</a> &gt; &gt; &amp;&nbsp;</td>
          <td class="paramname">, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="class_quant_lib_1_1_interest_rate.html">InterestRate</a> &amp;&nbsp;</td>
          <td class="paramname">, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="class_quant_lib_1_1_date.html">Date</a>&nbsp;</td>
          <td class="paramname"> <em>settlementDate</em> = <code><a class="el" href="class_quant_lib_1_1_date.html">Date</a>()</code></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"><code> [static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
NPV of the cash flows. 
<p>
The NPV is the sum of the cash flows, each discounted according to the given constant interest rate. The result is affected by the choice of the interest-rate compounding and the relative frequency and day counter. 
</div>
</div><p>
<a class="anchor" name="9275953ec871b533c6f9dbd28028f4d8"></a><!-- doxytag: member="QuantLib::Cashflows::bps" ref="9275953ec871b533c6f9dbd28028f4d8" args="(const std::vector&lt; boost::shared_ptr&lt; CashFlow &gt; &gt; &amp;, const Handle&lt; YieldTermStructure &gt; &amp;)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">static <a class="el" href="group__types.html#g4bdf4bfe76b9ffa6fa64c47d8bfa0c78">Real</a> bps           </td>
          <td>(</td>
          <td class="paramtype">const std::vector&lt; boost::shared_ptr&lt; <a class="el" href="class_quant_lib_1_1_cash_flow.html">CashFlow</a> &gt; &gt; &amp;&nbsp;</td>
          <td class="paramname">, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="class_quant_lib_1_1_handle.html">Handle</a>&lt; <a class="el" href="class_quant_lib_1_1_yield_term_structure.html">YieldTermStructure</a> &gt; &amp;&nbsp;</td>
          <td class="paramname"></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"><code> [static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Basis-point sensitivity of the cash flows. 
<p>
The result is the change in NPV due to a uniform 1-basis-point change in the rate paid by the cash flows. The change for each coupon is discounted according to the given term structure. 
</div>
</div><p>
<a class="anchor" name="339005671cfd4aa3d655c5a973776ef3"></a><!-- doxytag: member="QuantLib::Cashflows::bps" ref="339005671cfd4aa3d655c5a973776ef3" args="(const std::vector&lt; boost::shared_ptr&lt; CashFlow &gt; &gt; &amp;, const InterestRate &amp;, Date settlementDate=Date())" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">static <a class="el" href="group__types.html#g4bdf4bfe76b9ffa6fa64c47d8bfa0c78">Real</a> bps           </td>
          <td>(</td>
          <td class="paramtype">const std::vector&lt; boost::shared_ptr&lt; <a class="el" href="class_quant_lib_1_1_cash_flow.html">CashFlow</a> &gt; &gt; &amp;&nbsp;</td>
          <td class="paramname">, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="class_quant_lib_1_1_interest_rate.html">InterestRate</a> &amp;&nbsp;</td>
          <td class="paramname">, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="class_quant_lib_1_1_date.html">Date</a>&nbsp;</td>
          <td class="paramname"> <em>settlementDate</em> = <code><a class="el" href="class_quant_lib_1_1_date.html">Date</a>()</code></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"><code> [static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Basis-point sensitivity of the cash flows. 
<p>
The result is the change in NPV due to a uniform 1-basis-point change in the rate paid by the cash flows. The change for each coupon is discounted according to the given constant interest rate. The result is affected by the choice of the interest-rate compounding and the relative frequency and day counter. 
</div>
</div><p>
<a class="anchor" name="ab6aff01e22a5a1d97ccde47a65a882f"></a><!-- doxytag: member="QuantLib::Cashflows::irr" ref="ab6aff01e22a5a1d97ccde47a65a882f" args="(const std::vector&lt; boost::shared_ptr&lt; CashFlow &gt; &gt; &amp;, Real marketPrice, const DayCounter &amp;dayCounter, Compounding compounding, Frequency frequency=NoFrequency, Date settlementDate=Date(), Real tolerance=1.0e-10, Size maxIterations=10000, Rate guess=0.05)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">static <a class="el" href="group__types.html#gede435af51236692b1107d7639581d39">Rate</a> irr           </td>
          <td>(</td>
          <td class="paramtype">const std::vector&lt; boost::shared_ptr&lt; <a class="el" href="class_quant_lib_1_1_cash_flow.html">CashFlow</a> &gt; &gt; &amp;&nbsp;</td>
          <td class="paramname">, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__types.html#g4bdf4bfe76b9ffa6fa64c47d8bfa0c78">Real</a>&nbsp;</td>
          <td class="paramname"> <em>marketPrice</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="class_quant_lib_1_1_day_counter.html">DayCounter</a> &amp;&nbsp;</td>
          <td class="paramname"> <em>dayCounter</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Compounding&nbsp;</td>
          <td class="paramname"> <em>compounding</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__datetime.html#g6d41db8ba0ea90d22df35889df452ada">Frequency</a>&nbsp;</td>
          <td class="paramname"> <em>frequency</em> = <code>NoFrequency</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="class_quant_lib_1_1_date.html">Date</a>&nbsp;</td>
          <td class="paramname"> <em>settlementDate</em> = <code><a class="el" href="class_quant_lib_1_1_date.html">Date</a>()</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__types.html#g4bdf4bfe76b9ffa6fa64c47d8bfa0c78">Real</a>&nbsp;</td>
          <td class="paramname"> <em>tolerance</em> = <code>1.0e-10</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Size&nbsp;</td>
          <td class="paramname"> <em>maxIterations</em> = <code>10000</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__types.html#gede435af51236692b1107d7639581d39">Rate</a>&nbsp;</td>
          <td class="paramname"> <em>guess</em> = <code>0.05</code></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"><code> [static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Internal rate of return. 
<p>
The IRR is the interest rate at which the NPV of the cash flows equals the given market price. The function verifies the theoretical existance of an IRR and numerically establishes the IRR to the desired precision. 
</div>
</div><p>
<a class="anchor" name="4758e38bc3be6c9b70d36f8b6ca5dbdc"></a><!-- doxytag: member="QuantLib::Cashflows::duration" ref="4758e38bc3be6c9b70d36f8b6ca5dbdc" args="(const std::vector&lt; boost::shared_ptr&lt; CashFlow &gt; &gt; &amp;, const InterestRate &amp;y, Duration::Type type=Duration::Modified, Date settlementDate=Date())" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">static <a class="el" href="group__types.html#g14fb8fca43a68f4168654e1f9f7e22f7">Time</a> duration           </td>
          <td>(</td>
          <td class="paramtype">const std::vector&lt; boost::shared_ptr&lt; <a class="el" href="class_quant_lib_1_1_cash_flow.html">CashFlow</a> &gt; &gt; &amp;&nbsp;</td>
          <td class="paramname">, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="class_quant_lib_1_1_interest_rate.html">InterestRate</a> &amp;&nbsp;</td>
          <td class="paramname"> <em>y</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Duration::Type&nbsp;</td>
          <td class="paramname"> <em>type</em> = <code>Duration::Modified</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="class_quant_lib_1_1_date.html">Date</a>&nbsp;</td>
          <td class="paramname"> <em>settlementDate</em> = <code><a class="el" href="class_quant_lib_1_1_date.html">Date</a>()</code></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"><code> [static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Cash-flow duration. 
<p>
The simple duration of a string of cash flows is defined as <p class="formulaDsp">
<img class="formulaDsp" alt="\[ D_{\mathrm{simple}} = \frac{\sum t_i c_i B(t_i)}{\sum c_i B(t_i)} \]" src="form_45.png">
<p>
 where <img class="formulaInl" alt="$ c_i $" src="form_46.png"> is the amount of the <img class="formulaInl" alt="$ i $" src="form_47.png">-th cash flow, <img class="formulaInl" alt="$ t_i $" src="form_48.png"> is its payment time, and <img class="formulaInl" alt="$ B(t_i) $" src="form_49.png"> is the corresponding discount according to the passed yield.<p>
The modified duration is defined as <p class="formulaDsp">
<img class="formulaDsp" alt="\[ D_{\mathrm{modified}} = -\frac{1}{P} \frac{\partial P}{\partial y} \]" src="form_50.png">
<p>
 where <img class="formulaInl" alt="$ P $" src="form_51.png"> is the present value of the cash flows according to the given IRR <img class="formulaInl" alt="$ y $" src="form_13.png">.<p>
The Macaulay duration is defined for a compounded IRR as <p class="formulaDsp">
<img class="formulaDsp" alt="\[ D_{\mathrm{Macaulay}} = \left( 1 + \frac{y}{N} \right) D_{\mathrm{modified}} \]" src="form_52.png">
<p>
 where <img class="formulaInl" alt="$ y $" src="form_13.png"> is the IRR and <img class="formulaInl" alt="$ N $" src="form_36.png"> is the number of cash flows per year. 
</div>
</div><p>
<a class="anchor" name="0a537cb39484e47843ee6da7e5320754"></a><!-- doxytag: member="QuantLib::Cashflows::convexity" ref="0a537cb39484e47843ee6da7e5320754" args="(const std::vector&lt; boost::shared_ptr&lt; CashFlow &gt; &gt; &amp;, const InterestRate &amp;y, Date settlementDate=Date())" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">static <a class="el" href="group__types.html#g4bdf4bfe76b9ffa6fa64c47d8bfa0c78">Real</a> convexity           </td>
          <td>(</td>
          <td class="paramtype">const std::vector&lt; boost::shared_ptr&lt; <a class="el" href="class_quant_lib_1_1_cash_flow.html">CashFlow</a> &gt; &gt; &amp;&nbsp;</td>
          <td class="paramname">, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="class_quant_lib_1_1_interest_rate.html">InterestRate</a> &amp;&nbsp;</td>
          <td class="paramname"> <em>y</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="class_quant_lib_1_1_date.html">Date</a>&nbsp;</td>
          <td class="paramname"> <em>settlementDate</em> = <code><a class="el" href="class_quant_lib_1_1_date.html">Date</a>()</code></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"><code> [static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Cash-flow convexity. 
<p>
The convexity of a string of cash flows is defined as <p class="formulaDsp">
<img class="formulaDsp" alt="\[ C = \frac{1}{P} \frac{\partial^2 P}{\partial y^2} \]" src="form_53.png">
<p>
 where <img class="formulaInl" alt="$ P $" src="form_51.png"> is the present value of the cash flows according to the given IRR <img class="formulaInl" alt="$ y $" src="form_13.png">. 
</div>
</div><p>

</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>