File: _bonds_8cpp-example.html

package info (click to toggle)
quantlib-refman-html 1.2-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 84,552 kB
  • ctags: 5,132
  • sloc: makefile: 33
file content (642 lines) | stat: -rw-r--r-- 53,536 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
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
<!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>Bonds.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="185" height="50" 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 1.2</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="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="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="examples.html">Examples</a></li>
</ul>
</div>

<div id="content">
<!--Doxygen-generated content-->

<!-- Generated by Doxygen 1.7.6.1 -->
</div>
<div class="header">
  <div class="headertitle">
<div class="title">Bonds.cpp</div>  </div>
</div><!--header-->
<div class="contents">
<p>This example shows how to set up a term structure and then price some simple bonds. The last part is dedicated to peripherical computations such as "Yield to Price" or "Price to Yield"</p>
<div class="fragment"><pre class="fragment"><span class="comment">/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */</span>

<span class="comment">/*  This example shows how to set up a term structure and then price</span>
<span class="comment">    some simple bonds. The last part is dedicated to peripherical</span>
<span class="comment">    computations such as &quot;Yield to Price&quot; or &quot;Price to Yield&quot;</span>
<span class="comment"> */</span>

<span class="comment">// the only header you need to use QuantLib</span>
<span class="preprocessor">#include &lt;ql/quantlib.hpp&gt;</span>

<span class="preprocessor">#include &lt;boost/timer.hpp&gt;</span>
<span class="preprocessor">#include &lt;iostream&gt;</span>
<span class="preprocessor">#include &lt;iomanip&gt;</span>

<span class="keyword">using namespace </span>QuantLib;

<span class="preprocessor">#if defined(QL_ENABLE_SESSIONS)</span>
<span class="preprocessor"></span><span class="keyword">namespace </span>QuantLib {

<a name="a0"></a><a class="code" href="group__types.html#gab9c87440c314438e51a899a03d2442d0" title="integer number">Integer</a> sessionId() { <span class="keywordflow">return</span> 0; }

}
<span class="preprocessor">#endif</span>
<span class="preprocessor"></span>

<span class="keywordtype">int</span> main(<span class="keywordtype">int</span>, <span class="keywordtype">char</span>* []) {

    <span class="keywordflow">try</span> {

        boost::timer timer;
        std::cout &lt;&lt; std::endl;

        <span class="comment">/*********************</span>
<span class="comment">         ***  MARKET DATA  ***</span>
<span class="comment">         *********************/</span>

        <a name="_a1"></a><a class="code" href="class_quant_lib_1_1_calendar.html" title="calendar class">Calendar</a> calendar = <a name="_a2"></a><a class="code" href="class_quant_lib_1_1_t_a_r_g_e_t.html" title="TARGET calendar">TARGET</a>();

        <a name="_a3"></a><a class="code" href="class_quant_lib_1_1_date.html" title="Concrete date class.">Date</a> settlementDate(18, September, 2008);
        <span class="comment">// must be a business day</span>
        settlementDate = calendar.<a name="a4"></a><a class="code" href="class_quant_lib_1_1_calendar.html#aee7c18511c7ee1bcda6124f43a37aa28">adjust</a>(settlementDate);

        <a class="code" href="group__types.html#gab9c87440c314438e51a899a03d2442d0" title="integer number">Integer</a> fixingDays = 3;
        <a name="a5"></a><a class="code" href="group__types.html#ga7e529c39c477ba1f5a22264d93e8457a" title="positive integer">Natural</a> settlementDays = 3;

        <a class="code" href="class_quant_lib_1_1_date.html" title="Concrete date class.">Date</a> todaysDate = calendar.<a name="a6"></a><a class="code" href="class_quant_lib_1_1_calendar.html#ac47bb82bf7b147cfacf373991c2905ea">advance</a>(settlementDate, -fixingDays, Days);
        <span class="comment">// nothing to do with Date::todaysDate</span>
        <a name="a7"></a><a class="code" href="class_quant_lib_1_1_singleton.html#ab7455b7e1235d292c444095842349291" title="access to the unique instance">Settings::instance</a>().<a name="a8"></a><a class="code" href="class_quant_lib_1_1_settings.html#a95055e9410ed0465a5f30d3ffc90c1d3" title="the date at which pricing is to be performed.">evaluationDate</a>() = todaysDate;

        std::cout &lt;&lt; <span class="stringliteral">&quot;Today: &quot;</span> &lt;&lt; todaysDate.<a name="a9"></a>weekday()
        &lt;&lt; <span class="stringliteral">&quot;, &quot;</span> &lt;&lt; todaysDate &lt;&lt; std::endl;

        std::cout &lt;&lt; <span class="stringliteral">&quot;Settlement date: &quot;</span> &lt;&lt; settlementDate.weekday()
        &lt;&lt; <span class="stringliteral">&quot;, &quot;</span> &lt;&lt; settlementDate &lt;&lt; std::endl;


        <span class="comment">// Building of the bonds discounting yield curve</span>

        <span class="comment">/*********************</span>
<span class="comment">         ***  RATE HELPERS ***</span>
<span class="comment">         *********************/</span>

        <span class="comment">// RateHelpers are built from the above quotes together with</span>
        <span class="comment">// other instrument dependant infos.  Quotes are passed in</span>
        <span class="comment">// relinkable handles which could be relinked to some other</span>
        <span class="comment">// data source later.</span>

        <span class="comment">// Common data</span>

        <span class="comment">// ZC rates for the short end</span>
         <a name="a10"></a><a class="code" href="group__types.html#gaede435af51236692b1107d7639581d39" title="interest rates">Rate</a> zc3mQuote=0.0096;
         <a class="code" href="group__types.html#gaede435af51236692b1107d7639581d39" title="interest rates">Rate</a> zc6mQuote=0.0145;
         <a class="code" href="group__types.html#gaede435af51236692b1107d7639581d39" title="interest rates">Rate</a> zc1yQuote=0.0194;

         boost::shared_ptr&lt;Quote&gt; zc3mRate(<span class="keyword">new</span> <a name="_a11"></a><a class="code" href="class_quant_lib_1_1_simple_quote.html" title="market element returning a stored value">SimpleQuote</a>(zc3mQuote));
         boost::shared_ptr&lt;Quote&gt; zc6mRate(<span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_simple_quote.html" title="market element returning a stored value">SimpleQuote</a>(zc6mQuote));
         boost::shared_ptr&lt;Quote&gt; zc1yRate(<span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_simple_quote.html" title="market element returning a stored value">SimpleQuote</a>(zc1yQuote));

         <a name="_a12"></a><a class="code" href="class_quant_lib_1_1_day_counter.html" title="day counter class">DayCounter</a> zcBondsDayCounter = <a name="_a13"></a><a class="code" href="class_quant_lib_1_1_actual365_fixed.html" title="Actual/365 (Fixed) day count convention.">Actual365Fixed</a>();

         boost::shared_ptr&lt;RateHelper&gt; zc3m(<span class="keyword">new</span> <a name="_a14"></a><a class="code" href="class_quant_lib_1_1_deposit_rate_helper.html" title="Rate helper for bootstrapping over deposit rates.">DepositRateHelper</a>(
                 <a name="_a15"></a><a class="code" href="class_quant_lib_1_1_handle.html">Handle&lt;Quote&gt;</a>(zc3mRate),
                 3*Months, fixingDays,
                 calendar, <a name="a16"></a><a class="code" href="group__datetime.html#ggaff46c5ae9385d20709bedade86edd368a013e092c359f6031cc0563fd413ce707">ModifiedFollowing</a>,
                 <span class="keyword">true</span>, zcBondsDayCounter));
         boost::shared_ptr&lt;RateHelper&gt; zc6m(<span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_deposit_rate_helper.html" title="Rate helper for bootstrapping over deposit rates.">DepositRateHelper</a>(
                 <a class="code" href="class_quant_lib_1_1_handle.html">Handle&lt;Quote&gt;</a>(zc6mRate),
                 6*Months, fixingDays,
                 calendar, <a class="code" href="group__datetime.html#ggaff46c5ae9385d20709bedade86edd368a013e092c359f6031cc0563fd413ce707">ModifiedFollowing</a>,
                 <span class="keyword">true</span>, zcBondsDayCounter));
         boost::shared_ptr&lt;RateHelper&gt; zc1y(<span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_deposit_rate_helper.html" title="Rate helper for bootstrapping over deposit rates.">DepositRateHelper</a>(
                 <a class="code" href="class_quant_lib_1_1_handle.html">Handle&lt;Quote&gt;</a>(zc1yRate),
                 1*Years, fixingDays,
                 calendar, <a class="code" href="group__datetime.html#ggaff46c5ae9385d20709bedade86edd368a013e092c359f6031cc0563fd413ce707">ModifiedFollowing</a>,
                 <span class="keyword">true</span>, zcBondsDayCounter));

        <span class="comment">// setup bonds</span>
        <a name="a17"></a><a class="code" href="group__types.html#ga4bdf4bfe76b9ffa6fa64c47d8bfa0c78" title="real number">Real</a> redemption = 100.0;

        <span class="keyword">const</span> <a class="code" href="group__types.html#gaf38bdb4c54463b1f456655efa95b5c77" title="size of a container">Size</a> numberOfBonds = 5;

        <a class="code" href="class_quant_lib_1_1_date.html" title="Concrete date class.">Date</a> issueDates[] = {
                <a class="code" href="class_quant_lib_1_1_date.html" title="Concrete date class.">Date</a> (15, March, 2005),
                <a class="code" href="class_quant_lib_1_1_date.html" title="Concrete date class.">Date</a> (15, June, 2005),
                <a class="code" href="class_quant_lib_1_1_date.html" title="Concrete date class.">Date</a> (30, June, 2006),
                <a class="code" href="class_quant_lib_1_1_date.html" title="Concrete date class.">Date</a> (15, November, 2002),
                <a class="code" href="class_quant_lib_1_1_date.html" title="Concrete date class.">Date</a> (15, May, 1987)
        };

        <a class="code" href="class_quant_lib_1_1_date.html" title="Concrete date class.">Date</a> maturities[] = {
                <a class="code" href="class_quant_lib_1_1_date.html" title="Concrete date class.">Date</a> (31, August, 2010),
                <a class="code" href="class_quant_lib_1_1_date.html" title="Concrete date class.">Date</a> (31, August, 2011),
                <a class="code" href="class_quant_lib_1_1_date.html" title="Concrete date class.">Date</a> (31, August, 2013),
                <a class="code" href="class_quant_lib_1_1_date.html" title="Concrete date class.">Date</a> (15, August, 2018),
                <a class="code" href="class_quant_lib_1_1_date.html" title="Concrete date class.">Date</a> (15, May, 2038)
        };

        <a class="code" href="group__types.html#ga4bdf4bfe76b9ffa6fa64c47d8bfa0c78" title="real number">Real</a> couponRates[] = {
                0.02375,
                0.04625,
                0.03125,
                0.04000,
                0.04500
        };

        <a class="code" href="group__types.html#ga4bdf4bfe76b9ffa6fa64c47d8bfa0c78" title="real number">Real</a> marketQuotes[] = {
                100.390625,
                106.21875,
                100.59375,
                101.6875,
                102.140625
        };

        std::vector&lt; boost::shared_ptr&lt;SimpleQuote&gt; &gt; quote;
        <span class="keywordflow">for</span> (<a class="code" href="group__types.html#gaf38bdb4c54463b1f456655efa95b5c77" title="size of a container">Size</a> i=0; i&lt;numberOfBonds; i++) {
            boost::shared_ptr&lt;SimpleQuote&gt; cp(<span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_simple_quote.html" title="market element returning a stored value">SimpleQuote</a>(marketQuotes[i]));
            quote.push_back(cp);
        }

        <a name="_a18"></a><a class="code" href="class_quant_lib_1_1_relinkable_handle.html">RelinkableHandle&lt;Quote&gt;</a> quoteHandle[numberOfBonds];
        <span class="keywordflow">for</span> (<a class="code" href="group__types.html#gaf38bdb4c54463b1f456655efa95b5c77" title="size of a container">Size</a> i=0; i&lt;numberOfBonds; i++) {
            quoteHandle[i].<a name="a19"></a>linkTo(quote[i]);
        }

        <span class="comment">// Definition of the rate helpers</span>
        std::vector&lt;boost::shared_ptr&lt;FixedRateBondHelper&gt; &gt; bondsHelpers;

        <span class="keywordflow">for</span> (<a class="code" href="group__types.html#gaf38bdb4c54463b1f456655efa95b5c77" title="size of a container">Size</a> i=0; i&lt;numberOfBonds; i++) {

            <a name="_a20"></a><a class="code" href="class_quant_lib_1_1_schedule.html" title="Payment schedule.">Schedule</a> schedule(issueDates[i], maturities[i], <a name="_a21"></a><a class="code" href="class_quant_lib_1_1_period.html">Period</a>(<a name="a22"></a><a class="code" href="group__datetime.html#gga6d41db8ba0ea90d22df35889df452adaad1a5868a1c314bb7f6ab68e2fa182b2d" title="twice a year">Semiannual</a>), <a name="_a23"></a><a class="code" href="class_quant_lib_1_1_united_states.html" title="United States calendars.">UnitedStates</a>(<a name="a24"></a><a class="code" href="class_quant_lib_1_1_united_states.html#abe41cfffd960e29a5d8b07be00aeda42a561f5c560b2b1a55abd84072867a8016" title="government-bond calendar">UnitedStates::GovernmentBond</a>),
                    <a name="a25"></a><a class="code" href="group__datetime.html#ggaff46c5ae9385d20709bedade86edd368a5fb8b90b7fdf1a3a228fbbc083e64547">Unadjusted</a>, <a class="code" href="group__datetime.html#ggaff46c5ae9385d20709bedade86edd368a5fb8b90b7fdf1a3a228fbbc083e64547">Unadjusted</a>, <a name="a26"></a><a class="code" href="struct_quant_lib_1_1_date_generation.html#a11fcd51ef86118f65e603c1474377a78a67e19347f85332c3bbfd61266cecbe4e">DateGeneration::Backward</a>, <span class="keyword">false</span>);

            boost::shared_ptr&lt;FixedRateBondHelper&gt; bondHelper(<span class="keyword">new</span> FixedRateBondHelper(
                    quoteHandle[i],
                    settlementDays,
                    100.0,
                    schedule,
                    std::vector&lt;Rate&gt;(1,couponRates[i]),
                    <a name="_a27"></a><a class="code" href="class_quant_lib_1_1_actual_actual.html" title="Actual/Actual day count.">ActualActual</a>(ActualActual::Bond),
                    <a class="code" href="group__datetime.html#ggaff46c5ae9385d20709bedade86edd368a5fb8b90b7fdf1a3a228fbbc083e64547">Unadjusted</a>,
                    redemption,
                    issueDates[i]));

            bondsHelpers.push_back(bondHelper);
        }

        <span class="comment">/*********************</span>
<span class="comment">         **  CURVE BUILDING **</span>
<span class="comment">         *********************/</span>

         <span class="comment">// Any DayCounter would be fine.</span>
         <span class="comment">// ActualActual::ISDA ensures that 30 years is 30.0</span>
         <a class="code" href="class_quant_lib_1_1_day_counter.html" title="day counter class">DayCounter</a> termStructureDayCounter =
             <a class="code" href="class_quant_lib_1_1_actual_actual.html" title="Actual/Actual day count.">ActualActual</a>(ActualActual::ISDA);

         <span class="keywordtype">double</span> tolerance = 1.0e-15;

         <span class="comment">// A depo-bond curve</span>
         std::vector&lt;boost::shared_ptr&lt;RateHelper&gt; &gt; bondInstruments;

         <span class="comment">// Adding the ZC bonds to the curve for the short end</span>
         bondInstruments.push_back(zc3m);
         bondInstruments.push_back(zc6m);
         bondInstruments.push_back(zc1y);

         <span class="comment">// Adding the Fixed rate bonds to the curve for the long end</span>
         <span class="keywordflow">for</span> (<a class="code" href="group__types.html#gaf38bdb4c54463b1f456655efa95b5c77" title="size of a container">Size</a> i=0; i&lt;numberOfBonds; i++) {
             bondInstruments.push_back(bondsHelpers[i]);
         }

         boost::shared_ptr&lt;YieldTermStructure&gt; bondDiscountingTermStructure(
                 <span class="keyword">new</span> <a name="_a28"></a><a class="code" href="class_quant_lib_1_1_piecewise_yield_curve.html" title="Piecewise yield term structure.">PiecewiseYieldCurve&lt;Discount,LogLinear&gt;</a>(
                         settlementDate, bondInstruments,
                         termStructureDayCounter,
                         tolerance));

         <span class="comment">// Building of the Libor forecasting curve</span>
         <span class="comment">// deposits</span>
         <a class="code" href="group__types.html#gaede435af51236692b1107d7639581d39" title="interest rates">Rate</a> d1wQuote=0.043375;
         <a class="code" href="group__types.html#gaede435af51236692b1107d7639581d39" title="interest rates">Rate</a> d1mQuote=0.031875;
         <a class="code" href="group__types.html#gaede435af51236692b1107d7639581d39" title="interest rates">Rate</a> d3mQuote=0.0320375;
         <a class="code" href="group__types.html#gaede435af51236692b1107d7639581d39" title="interest rates">Rate</a> d6mQuote=0.03385;
         <a class="code" href="group__types.html#gaede435af51236692b1107d7639581d39" title="interest rates">Rate</a> d9mQuote=0.0338125;
         <a class="code" href="group__types.html#gaede435af51236692b1107d7639581d39" title="interest rates">Rate</a> d1yQuote=0.0335125;
         <span class="comment">// swaps</span>
         <a class="code" href="group__types.html#gaede435af51236692b1107d7639581d39" title="interest rates">Rate</a> s2yQuote=0.0295;
         <a class="code" href="group__types.html#gaede435af51236692b1107d7639581d39" title="interest rates">Rate</a> s3yQuote=0.0323;
         <a class="code" href="group__types.html#gaede435af51236692b1107d7639581d39" title="interest rates">Rate</a> s5yQuote=0.0359;
         <a class="code" href="group__types.html#gaede435af51236692b1107d7639581d39" title="interest rates">Rate</a> s10yQuote=0.0412;
         <a class="code" href="group__types.html#gaede435af51236692b1107d7639581d39" title="interest rates">Rate</a> s15yQuote=0.0433;


         <span class="comment">/********************</span>
<span class="comment">          ***    QUOTES    ***</span>
<span class="comment">          ********************/</span>

         <span class="comment">// SimpleQuote stores a value which can be manually changed;</span>
         <span class="comment">// other Quote subclasses could read the value from a database</span>
         <span class="comment">// or some kind of data feed.</span>

         <span class="comment">// deposits</span>
         boost::shared_ptr&lt;Quote&gt; d1wRate(<span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_simple_quote.html" title="market element returning a stored value">SimpleQuote</a>(d1wQuote));
         boost::shared_ptr&lt;Quote&gt; d1mRate(<span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_simple_quote.html" title="market element returning a stored value">SimpleQuote</a>(d1mQuote));
         boost::shared_ptr&lt;Quote&gt; d3mRate(<span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_simple_quote.html" title="market element returning a stored value">SimpleQuote</a>(d3mQuote));
         boost::shared_ptr&lt;Quote&gt; d6mRate(<span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_simple_quote.html" title="market element returning a stored value">SimpleQuote</a>(d6mQuote));
         boost::shared_ptr&lt;Quote&gt; d9mRate(<span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_simple_quote.html" title="market element returning a stored value">SimpleQuote</a>(d9mQuote));
         boost::shared_ptr&lt;Quote&gt; d1yRate(<span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_simple_quote.html" title="market element returning a stored value">SimpleQuote</a>(d1yQuote));
         <span class="comment">// swaps</span>
         boost::shared_ptr&lt;Quote&gt; s2yRate(<span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_simple_quote.html" title="market element returning a stored value">SimpleQuote</a>(s2yQuote));
         boost::shared_ptr&lt;Quote&gt; s3yRate(<span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_simple_quote.html" title="market element returning a stored value">SimpleQuote</a>(s3yQuote));
         boost::shared_ptr&lt;Quote&gt; s5yRate(<span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_simple_quote.html" title="market element returning a stored value">SimpleQuote</a>(s5yQuote));
         boost::shared_ptr&lt;Quote&gt; s10yRate(<span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_simple_quote.html" title="market element returning a stored value">SimpleQuote</a>(s10yQuote));
         boost::shared_ptr&lt;Quote&gt; s15yRate(<span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_simple_quote.html" title="market element returning a stored value">SimpleQuote</a>(s15yQuote));

         <span class="comment">/*********************</span>
<span class="comment">          ***  RATE HELPERS ***</span>
<span class="comment">          *********************/</span>

         <span class="comment">// RateHelpers are built from the above quotes together with</span>
         <span class="comment">// other instrument dependant infos.  Quotes are passed in</span>
         <span class="comment">// relinkable handles which could be relinked to some other</span>
         <span class="comment">// data source later.</span>

         <span class="comment">// deposits</span>
         <a class="code" href="class_quant_lib_1_1_day_counter.html" title="day counter class">DayCounter</a> depositDayCounter = <a name="_a29"></a><a class="code" href="class_quant_lib_1_1_actual360.html" title="Actual/360 day count convention.">Actual360</a>();

         boost::shared_ptr&lt;RateHelper&gt; d1w(<span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_deposit_rate_helper.html" title="Rate helper for bootstrapping over deposit rates.">DepositRateHelper</a>(
                 <a class="code" href="class_quant_lib_1_1_handle.html">Handle&lt;Quote&gt;</a>(d1wRate),
                 1*Weeks, fixingDays,
                 calendar, <a class="code" href="group__datetime.html#ggaff46c5ae9385d20709bedade86edd368a013e092c359f6031cc0563fd413ce707">ModifiedFollowing</a>,
                 <span class="keyword">true</span>, depositDayCounter));
         boost::shared_ptr&lt;RateHelper&gt; d1m(<span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_deposit_rate_helper.html" title="Rate helper for bootstrapping over deposit rates.">DepositRateHelper</a>(
                 <a class="code" href="class_quant_lib_1_1_handle.html">Handle&lt;Quote&gt;</a>(d1mRate),
                 1*Months, fixingDays,
                 calendar, <a class="code" href="group__datetime.html#ggaff46c5ae9385d20709bedade86edd368a013e092c359f6031cc0563fd413ce707">ModifiedFollowing</a>,
                 <span class="keyword">true</span>, depositDayCounter));
         boost::shared_ptr&lt;RateHelper&gt; d3m(<span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_deposit_rate_helper.html" title="Rate helper for bootstrapping over deposit rates.">DepositRateHelper</a>(
                 <a class="code" href="class_quant_lib_1_1_handle.html">Handle&lt;Quote&gt;</a>(d3mRate),
                 3*Months, fixingDays,
                 calendar, <a class="code" href="group__datetime.html#ggaff46c5ae9385d20709bedade86edd368a013e092c359f6031cc0563fd413ce707">ModifiedFollowing</a>,
                 <span class="keyword">true</span>, depositDayCounter));
         boost::shared_ptr&lt;RateHelper&gt; d6m(<span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_deposit_rate_helper.html" title="Rate helper for bootstrapping over deposit rates.">DepositRateHelper</a>(
                 <a class="code" href="class_quant_lib_1_1_handle.html">Handle&lt;Quote&gt;</a>(d6mRate),
                 6*Months, fixingDays,
                 calendar, <a class="code" href="group__datetime.html#ggaff46c5ae9385d20709bedade86edd368a013e092c359f6031cc0563fd413ce707">ModifiedFollowing</a>,
                 <span class="keyword">true</span>, depositDayCounter));
         boost::shared_ptr&lt;RateHelper&gt; d9m(<span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_deposit_rate_helper.html" title="Rate helper for bootstrapping over deposit rates.">DepositRateHelper</a>(
                 <a class="code" href="class_quant_lib_1_1_handle.html">Handle&lt;Quote&gt;</a>(d9mRate),
                 9*Months, fixingDays,
                 calendar, <a class="code" href="group__datetime.html#ggaff46c5ae9385d20709bedade86edd368a013e092c359f6031cc0563fd413ce707">ModifiedFollowing</a>,
                 <span class="keyword">true</span>, depositDayCounter));
         boost::shared_ptr&lt;RateHelper&gt; d1y(<span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_deposit_rate_helper.html" title="Rate helper for bootstrapping over deposit rates.">DepositRateHelper</a>(
                 <a class="code" href="class_quant_lib_1_1_handle.html">Handle&lt;Quote&gt;</a>(d1yRate),
                 1*Years, fixingDays,
                 calendar, <a class="code" href="group__datetime.html#ggaff46c5ae9385d20709bedade86edd368a013e092c359f6031cc0563fd413ce707">ModifiedFollowing</a>,
                 <span class="keyword">true</span>, depositDayCounter));

         <span class="comment">// setup swaps</span>
         <a class="code" href="group__datetime.html#ga6d41db8ba0ea90d22df35889df452ada" title="Frequency of events.">Frequency</a> swFixedLegFrequency = <a name="a30"></a><a class="code" href="group__datetime.html#gga6d41db8ba0ea90d22df35889df452adaa508b18014c96e2d466c12b39d7f4e426" title="once a year">Annual</a>;
         <a class="code" href="group__datetime.html#gaff46c5ae9385d20709bedade86edd368" title="Business Day conventions.">BusinessDayConvention</a> swFixedLegConvention = <a class="code" href="group__datetime.html#ggaff46c5ae9385d20709bedade86edd368a5fb8b90b7fdf1a3a228fbbc083e64547">Unadjusted</a>;
         <a class="code" href="class_quant_lib_1_1_day_counter.html" title="day counter class">DayCounter</a> swFixedLegDayCounter = <a name="_a31"></a><a class="code" href="class_quant_lib_1_1_thirty360.html" title="30/360 day count convention">Thirty360</a>(Thirty360::European);
         boost::shared_ptr&lt;IborIndex&gt; swFloatingLegIndex(<span class="keyword">new</span> <a name="_a32"></a><a class="code" href="class_quant_lib_1_1_euribor6_m.html" title="6-months Euribor index">Euribor6M</a>);

         <span class="keyword">const</span> <a class="code" href="class_quant_lib_1_1_period.html">Period</a> forwardStart(1*Days);

         boost::shared_ptr&lt;RateHelper&gt; s2y(<span class="keyword">new</span> <a name="_a33"></a><a class="code" href="class_quant_lib_1_1_swap_rate_helper.html" title="Rate helper for bootstrapping over swap rates.">SwapRateHelper</a>(
                 <a class="code" href="class_quant_lib_1_1_handle.html">Handle&lt;Quote&gt;</a>(s2yRate), 2*Years,
                 calendar, swFixedLegFrequency,
                 swFixedLegConvention, swFixedLegDayCounter,
                 swFloatingLegIndex, <a class="code" href="class_quant_lib_1_1_handle.html">Handle&lt;Quote&gt;</a>(),forwardStart));
         boost::shared_ptr&lt;RateHelper&gt; s3y(<span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_swap_rate_helper.html" title="Rate helper for bootstrapping over swap rates.">SwapRateHelper</a>(
                 <a class="code" href="class_quant_lib_1_1_handle.html">Handle&lt;Quote&gt;</a>(s3yRate), 3*Years,
                 calendar, swFixedLegFrequency,
                 swFixedLegConvention, swFixedLegDayCounter,
                 swFloatingLegIndex, <a class="code" href="class_quant_lib_1_1_handle.html">Handle&lt;Quote&gt;</a>(),forwardStart));
         boost::shared_ptr&lt;RateHelper&gt; s5y(<span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_swap_rate_helper.html" title="Rate helper for bootstrapping over swap rates.">SwapRateHelper</a>(
                 <a class="code" href="class_quant_lib_1_1_handle.html">Handle&lt;Quote&gt;</a>(s5yRate), 5*Years,
                 calendar, swFixedLegFrequency,
                 swFixedLegConvention, swFixedLegDayCounter,
                 swFloatingLegIndex, <a class="code" href="class_quant_lib_1_1_handle.html">Handle&lt;Quote&gt;</a>(),forwardStart));
         boost::shared_ptr&lt;RateHelper&gt; s10y(<span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_swap_rate_helper.html" title="Rate helper for bootstrapping over swap rates.">SwapRateHelper</a>(
                 <a class="code" href="class_quant_lib_1_1_handle.html">Handle&lt;Quote&gt;</a>(s10yRate), 10*Years,
                 calendar, swFixedLegFrequency,
                 swFixedLegConvention, swFixedLegDayCounter,
                 swFloatingLegIndex, <a class="code" href="class_quant_lib_1_1_handle.html">Handle&lt;Quote&gt;</a>(),forwardStart));
         boost::shared_ptr&lt;RateHelper&gt; s15y(<span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_swap_rate_helper.html" title="Rate helper for bootstrapping over swap rates.">SwapRateHelper</a>(
                 <a class="code" href="class_quant_lib_1_1_handle.html">Handle&lt;Quote&gt;</a>(s15yRate), 15*Years,
                 calendar, swFixedLegFrequency,
                 swFixedLegConvention, swFixedLegDayCounter,
                 swFloatingLegIndex, <a class="code" href="class_quant_lib_1_1_handle.html">Handle&lt;Quote&gt;</a>(),forwardStart));


         <span class="comment">/*********************</span>
<span class="comment">          **  CURVE BUILDING **</span>
<span class="comment">          *********************/</span>

         <span class="comment">// Any DayCounter would be fine.</span>
         <span class="comment">// ActualActual::ISDA ensures that 30 years is 30.0</span>

         <span class="comment">// A depo-swap curve</span>
         std::vector&lt;boost::shared_ptr&lt;RateHelper&gt; &gt; depoSwapInstruments;
         depoSwapInstruments.push_back(d1w);
         depoSwapInstruments.push_back(d1m);
         depoSwapInstruments.push_back(d3m);
         depoSwapInstruments.push_back(d6m);
         depoSwapInstruments.push_back(d9m);
         depoSwapInstruments.push_back(d1y);
         depoSwapInstruments.push_back(s2y);
         depoSwapInstruments.push_back(s3y);
         depoSwapInstruments.push_back(s5y);
         depoSwapInstruments.push_back(s10y);
         depoSwapInstruments.push_back(s15y);
         boost::shared_ptr&lt;YieldTermStructure&gt; depoSwapTermStructure(
                 <span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_piecewise_yield_curve.html" title="Piecewise yield term structure.">PiecewiseYieldCurve&lt;Discount,LogLinear&gt;</a>(
                         settlementDate, depoSwapInstruments,
                         termStructureDayCounter,
                         tolerance));

         <span class="comment">// Term structures that will be used for pricing:</span>
         <span class="comment">// the one used for discounting cash flows</span>
         <a name="_a34"></a><a class="code" href="class_quant_lib_1_1_relinkable_handle.html">RelinkableHandle&lt;YieldTermStructure&gt;</a> discountingTermStructure;
         <span class="comment">// the one used for forward rate forecasting</span>
         <a class="code" href="class_quant_lib_1_1_relinkable_handle.html">RelinkableHandle&lt;YieldTermStructure&gt;</a> forecastingTermStructure;

         <span class="comment">/*********************</span>
<span class="comment">          * BONDS TO BE PRICED *</span>
<span class="comment">          **********************/</span>

         <span class="comment">// Common data</span>
         <a class="code" href="group__types.html#ga4bdf4bfe76b9ffa6fa64c47d8bfa0c78" title="real number">Real</a> faceAmount = 100;

         <span class="comment">// Pricing engine</span>
         boost::shared_ptr&lt;PricingEngine&gt; bondEngine(
                 <span class="keyword">new</span> DiscountingBondEngine(discountingTermStructure));

         <span class="comment">// Zero coupon bond</span>
         <a name="_a35"></a><a class="code" href="class_quant_lib_1_1_zero_coupon_bond.html" title="zero-coupon bond">ZeroCouponBond</a> zeroCouponBond(
                 settlementDays,
                 <a class="code" href="class_quant_lib_1_1_united_states.html" title="United States calendars.">UnitedStates</a>(<a class="code" href="class_quant_lib_1_1_united_states.html#abe41cfffd960e29a5d8b07be00aeda42a561f5c560b2b1a55abd84072867a8016" title="government-bond calendar">UnitedStates::GovernmentBond</a>),
                 faceAmount,
                 <a class="code" href="class_quant_lib_1_1_date.html" title="Concrete date class.">Date</a>(15,August,2013),
                 <a name="a36"></a><a class="code" href="group__datetime.html#ggaff46c5ae9385d20709bedade86edd368ab6a37af780aa2b97f8bbdc4d149dae18">Following</a>,
                 <a class="code" href="group__types.html#ga4bdf4bfe76b9ffa6fa64c47d8bfa0c78" title="real number">Real</a>(116.92),
                 <a class="code" href="class_quant_lib_1_1_date.html" title="Concrete date class.">Date</a>(15,August,2003));

         zeroCouponBond.setPricingEngine(bondEngine);

         <span class="comment">// Fixed 4.5% US Treasury Note</span>
         <a class="code" href="class_quant_lib_1_1_schedule.html" title="Payment schedule.">Schedule</a> fixedBondSchedule(<a class="code" href="class_quant_lib_1_1_date.html" title="Concrete date class.">Date</a>(15, May, 2007),
                 <a class="code" href="class_quant_lib_1_1_date.html" title="Concrete date class.">Date</a>(15,May,2017), <a class="code" href="class_quant_lib_1_1_period.html">Period</a>(<a class="code" href="group__datetime.html#gga6d41db8ba0ea90d22df35889df452adaad1a5868a1c314bb7f6ab68e2fa182b2d" title="twice a year">Semiannual</a>),
                 <a class="code" href="class_quant_lib_1_1_united_states.html" title="United States calendars.">UnitedStates</a>(<a class="code" href="class_quant_lib_1_1_united_states.html#abe41cfffd960e29a5d8b07be00aeda42a561f5c560b2b1a55abd84072867a8016" title="government-bond calendar">UnitedStates::GovernmentBond</a>),
                 <a class="code" href="group__datetime.html#ggaff46c5ae9385d20709bedade86edd368a5fb8b90b7fdf1a3a228fbbc083e64547">Unadjusted</a>, <a class="code" href="group__datetime.html#ggaff46c5ae9385d20709bedade86edd368a5fb8b90b7fdf1a3a228fbbc083e64547">Unadjusted</a>, <a class="code" href="struct_quant_lib_1_1_date_generation.html#a11fcd51ef86118f65e603c1474377a78a67e19347f85332c3bbfd61266cecbe4e">DateGeneration::Backward</a>, <span class="keyword">false</span>);

         <a name="_a37"></a><a class="code" href="class_quant_lib_1_1_fixed_rate_bond.html" title="fixed-rate bond">FixedRateBond</a> fixedRateBond(
                 settlementDays,
                 faceAmount,
                 fixedBondSchedule,
                 std::vector&lt;Rate&gt;(1, 0.045),
                 <a class="code" href="class_quant_lib_1_1_actual_actual.html" title="Actual/Actual day count.">ActualActual</a>(ActualActual::Bond),
                 <a class="code" href="group__datetime.html#ggaff46c5ae9385d20709bedade86edd368a013e092c359f6031cc0563fd413ce707">ModifiedFollowing</a>,
                 100.0, <a class="code" href="class_quant_lib_1_1_date.html" title="Concrete date class.">Date</a>(15, May, 2007));

         fixedRateBond.setPricingEngine(bondEngine);

         <span class="comment">// Floating rate bond (3M USD Libor + 0.1%)</span>
         <span class="comment">// Should and will be priced on another curve later...</span>

         <a class="code" href="class_quant_lib_1_1_relinkable_handle.html">RelinkableHandle&lt;YieldTermStructure&gt;</a> liborTermStructure;
         <span class="keyword">const</span> boost::shared_ptr&lt;IborIndex&gt; libor3m(
                 <span class="keyword">new</span> <a name="_a38"></a><a class="code" href="class_quant_lib_1_1_u_s_d_libor.html" title="USD LIBOR rate">USDLibor</a>(<a class="code" href="class_quant_lib_1_1_period.html">Period</a>(3,Months),liborTermStructure));
         libor3m-&gt;addFixing(<a class="code" href="class_quant_lib_1_1_date.html" title="Concrete date class.">Date</a>(17, July, 2008),0.0278625);

         <a class="code" href="class_quant_lib_1_1_schedule.html" title="Payment schedule.">Schedule</a> floatingBondSchedule(<a class="code" href="class_quant_lib_1_1_date.html" title="Concrete date class.">Date</a>(21, October, 2005),
                 <a class="code" href="class_quant_lib_1_1_date.html" title="Concrete date class.">Date</a>(21, October, 2010), <a class="code" href="class_quant_lib_1_1_period.html">Period</a>(<a name="a39"></a><a class="code" href="group__datetime.html#gga6d41db8ba0ea90d22df35889df452adaab4fce358383d1822f7596659e00b07f7" title="every third month">Quarterly</a>),
                 <a class="code" href="class_quant_lib_1_1_united_states.html" title="United States calendars.">UnitedStates</a>(<a name="a40"></a><a class="code" href="class_quant_lib_1_1_united_states.html#abe41cfffd960e29a5d8b07be00aeda42a3f2821f9809075eb575505bcc2525103" title="New York stock exchange calendar.">UnitedStates::NYSE</a>),
                 <a class="code" href="group__datetime.html#ggaff46c5ae9385d20709bedade86edd368a5fb8b90b7fdf1a3a228fbbc083e64547">Unadjusted</a>, <a class="code" href="group__datetime.html#ggaff46c5ae9385d20709bedade86edd368a5fb8b90b7fdf1a3a228fbbc083e64547">Unadjusted</a>, <a class="code" href="struct_quant_lib_1_1_date_generation.html#a11fcd51ef86118f65e603c1474377a78a67e19347f85332c3bbfd61266cecbe4e">DateGeneration::Backward</a>, <span class="keyword">true</span>);

         <a name="_a41"></a><a class="code" href="class_quant_lib_1_1_floating_rate_bond.html" title="floating-rate bond (possibly capped and/or floored)">FloatingRateBond</a> floatingRateBond(
                 settlementDays,
                 faceAmount,
                 floatingBondSchedule,
                 libor3m,
                 <a class="code" href="class_quant_lib_1_1_actual360.html" title="Actual/360 day count convention.">Actual360</a>(),
                 <a class="code" href="group__datetime.html#ggaff46c5ae9385d20709bedade86edd368a013e092c359f6031cc0563fd413ce707">ModifiedFollowing</a>,
                 <a class="code" href="group__types.html#ga7e529c39c477ba1f5a22264d93e8457a" title="positive integer">Natural</a>(2),
                 <span class="comment">// Gearings</span>
                 std::vector&lt;Real&gt;(1, 1.0),
                 <span class="comment">// Spreads</span>
                 std::vector&lt;Rate&gt;(1, 0.001),
                 <span class="comment">// Caps</span>
                 std::vector&lt;Rate&gt;(),
                 <span class="comment">// Floors</span>
                 std::vector&lt;Rate&gt;(),
                 <span class="comment">// Fixing in arrears</span>
                 <span class="keyword">true</span>,
                 <a class="code" href="group__types.html#ga4bdf4bfe76b9ffa6fa64c47d8bfa0c78" title="real number">Real</a>(100.0),
                 <a class="code" href="class_quant_lib_1_1_date.html" title="Concrete date class.">Date</a>(21, October, 2005));

         floatingRateBond.setPricingEngine(bondEngine);

         <span class="comment">// Coupon pricers</span>
         boost::shared_ptr&lt;IborCouponPricer&gt; pricer(<span class="keyword">new</span> <a name="_a42"></a><a class="code" href="class_quant_lib_1_1_black_ibor_coupon_pricer.html" title="Black-formula pricer for capped/floored Ibor coupons.">BlackIborCouponPricer</a>);

         <span class="comment">// optionLet volatilities</span>
         <a name="a43"></a><a class="code" href="group__types.html#gaaa95ab7fe66935e3f7535413fad2a7d3" title="volatility">Volatility</a> <a name="a44"></a><a class="code" href="group__manips.html#gac402ef7c87f63f7c603ee87210b5750c" title="output volatilities as percentages">volatility</a> = 0.0;
         <a name="_a45"></a><a class="code" href="class_quant_lib_1_1_handle.html">Handle&lt;OptionletVolatilityStructure&gt;</a> vol;
         vol = <a class="code" href="class_quant_lib_1_1_handle.html">Handle&lt;OptionletVolatilityStructure&gt;</a>(
                 boost::shared_ptr&lt;OptionletVolatilityStructure&gt;(<span class="keyword">new</span>
                         <a name="_a46"></a><a class="code" href="class_quant_lib_1_1_constant_optionlet_volatility.html" title="Constant caplet volatility, no time-strike dependence.">ConstantOptionletVolatility</a>(
                                 settlementDays,
                                 calendar,
                                 <a class="code" href="group__datetime.html#ggaff46c5ae9385d20709bedade86edd368a013e092c359f6031cc0563fd413ce707">ModifiedFollowing</a>,
                                 volatility,
                                 <a class="code" href="class_quant_lib_1_1_actual365_fixed.html" title="Actual/365 (Fixed) day count convention.">Actual365Fixed</a>())));

         pricer-&gt;setCapletVolatility(vol);
         setCouponPricer(floatingRateBond.cashflows(),pricer);

         <span class="comment">// Yield curve bootstrapping</span>
         forecastingTermStructure.<a name="a47"></a>linkTo(depoSwapTermStructure);
         discountingTermStructure.linkTo(bondDiscountingTermStructure);

         <span class="comment">// We are using the depo &amp; swap curve to estimate the future Libor rates</span>
         liborTermStructure.linkTo(depoSwapTermStructure);

         <span class="comment">/***************</span>
<span class="comment">          * BOND PRICING *</span>
<span class="comment">          ****************/</span>

         std::cout &lt;&lt; std::endl;

         <span class="comment">// write column headings</span>
         <a class="code" href="group__types.html#gaf38bdb4c54463b1f456655efa95b5c77" title="size of a container">Size</a> widths[] = { 18, 10, 10, 10 };

         std::cout &lt;&lt; std::setw(widths[0]) &lt;&lt;  <span class="stringliteral">&quot;                 &quot;</span>
         &lt;&lt; std::setw(widths[1]) &lt;&lt; <span class="stringliteral">&quot;ZC&quot;</span>
         &lt;&lt; std::setw(widths[2]) &lt;&lt; <span class="stringliteral">&quot;Fixed&quot;</span>
         &lt;&lt; std::setw(widths[3]) &lt;&lt; <span class="stringliteral">&quot;Floating&quot;</span>
         &lt;&lt; std::endl;

         std::string separator = <span class="stringliteral">&quot; | &quot;</span>;
         <a class="code" href="group__types.html#gaf38bdb4c54463b1f456655efa95b5c77" title="size of a container">Size</a> width = widths[0]
                             + widths[1]
                                      + widths[2]
                                               + widths[3];
         std::string rule(width, <span class="charliteral">&#39;-&#39;</span>), dblrule(width, <span class="charliteral">&#39;=&#39;</span>);
         std::string tab(8, <span class="charliteral">&#39; &#39;</span>);

         std::cout &lt;&lt; rule &lt;&lt; std::endl;

         std::cout &lt;&lt; std::fixed;
         std::cout &lt;&lt; std::setprecision(2);

         std::cout &lt;&lt; std::setw(widths[0]) &lt;&lt; <span class="stringliteral">&quot;Net present value&quot;</span>
         &lt;&lt; std::setw(widths[1]) &lt;&lt; zeroCouponBond.NPV()
         &lt;&lt; std::setw(widths[2]) &lt;&lt; fixedRateBond.NPV()
         &lt;&lt; std::setw(widths[3]) &lt;&lt; floatingRateBond.NPV()
         &lt;&lt; std::endl;

         std::cout &lt;&lt; std::setw(widths[0]) &lt;&lt; <span class="stringliteral">&quot;Clean price&quot;</span>
         &lt;&lt; std::setw(widths[1]) &lt;&lt; zeroCouponBond.cleanPrice()
         &lt;&lt; std::setw(widths[2]) &lt;&lt; fixedRateBond.cleanPrice()
         &lt;&lt; std::setw(widths[3]) &lt;&lt; floatingRateBond.cleanPrice()
         &lt;&lt; std::endl;

         std::cout &lt;&lt; std::setw(widths[0]) &lt;&lt; <span class="stringliteral">&quot;Dirty price&quot;</span>
         &lt;&lt; std::setw(widths[1]) &lt;&lt; zeroCouponBond.dirtyPrice()
         &lt;&lt; std::setw(widths[2]) &lt;&lt; fixedRateBond.dirtyPrice()
         &lt;&lt; std::setw(widths[3]) &lt;&lt; floatingRateBond.dirtyPrice()
         &lt;&lt; std::endl;

         std::cout &lt;&lt; std::setw(widths[0]) &lt;&lt; <span class="stringliteral">&quot;Accrued coupon&quot;</span>
         &lt;&lt; std::setw(widths[1]) &lt;&lt; zeroCouponBond.accruedAmount()
         &lt;&lt; std::setw(widths[2]) &lt;&lt; fixedRateBond.accruedAmount()
         &lt;&lt; std::setw(widths[3]) &lt;&lt; floatingRateBond.accruedAmount()
         &lt;&lt; std::endl;

         std::cout &lt;&lt; std::setw(widths[0]) &lt;&lt; <span class="stringliteral">&quot;Previous coupon&quot;</span>
         &lt;&lt; std::setw(widths[1]) &lt;&lt; <span class="stringliteral">&quot;N/A&quot;</span> <span class="comment">// zeroCouponBond</span>
         &lt;&lt; std::setw(widths[2]) &lt;&lt; <a name="a48"></a><a class="code" href="group__manips.html#gac63ea3dad10259db3764c7d15a61cde5" title="output rates and spreads as percentages">io::rate</a>(fixedRateBond.previousCouponRate())
         &lt;&lt; std::setw(widths[3]) &lt;&lt; <a class="code" href="group__manips.html#gac63ea3dad10259db3764c7d15a61cde5" title="output rates and spreads as percentages">io::rate</a>(floatingRateBond.previousCouponRate())
         &lt;&lt; std::endl;

         std::cout &lt;&lt; std::setw(widths[0]) &lt;&lt; <span class="stringliteral">&quot;Next coupon&quot;</span>
         &lt;&lt; std::setw(widths[1]) &lt;&lt; <span class="stringliteral">&quot;N/A&quot;</span> <span class="comment">// zeroCouponBond</span>
         &lt;&lt; std::setw(widths[2]) &lt;&lt; <a class="code" href="group__manips.html#gac63ea3dad10259db3764c7d15a61cde5" title="output rates and spreads as percentages">io::rate</a>(fixedRateBond.nextCouponRate())
         &lt;&lt; std::setw(widths[3]) &lt;&lt; <a class="code" href="group__manips.html#gac63ea3dad10259db3764c7d15a61cde5" title="output rates and spreads as percentages">io::rate</a>(floatingRateBond.nextCouponRate())
         &lt;&lt; std::endl;

         std::cout &lt;&lt; std::setw(widths[0]) &lt;&lt; <span class="stringliteral">&quot;Yield&quot;</span>
         &lt;&lt; std::setw(widths[1])
         &lt;&lt; <a class="code" href="group__manips.html#gac63ea3dad10259db3764c7d15a61cde5" title="output rates and spreads as percentages">io::rate</a>(zeroCouponBond.yield(<a class="code" href="class_quant_lib_1_1_actual360.html" title="Actual/360 day count convention.">Actual360</a>(),Compounded,<a class="code" href="group__datetime.html#gga6d41db8ba0ea90d22df35889df452adaa508b18014c96e2d466c12b39d7f4e426" title="once a year">Annual</a>))
         &lt;&lt; std::setw(widths[2])
         &lt;&lt; <a class="code" href="group__manips.html#gac63ea3dad10259db3764c7d15a61cde5" title="output rates and spreads as percentages">io::rate</a>(fixedRateBond.yield(<a class="code" href="class_quant_lib_1_1_actual360.html" title="Actual/360 day count convention.">Actual360</a>(),Compounded,<a class="code" href="group__datetime.html#gga6d41db8ba0ea90d22df35889df452adaa508b18014c96e2d466c12b39d7f4e426" title="once a year">Annual</a>))
         &lt;&lt; std::setw(widths[3])
         &lt;&lt; <a class="code" href="group__manips.html#gac63ea3dad10259db3764c7d15a61cde5" title="output rates and spreads as percentages">io::rate</a>(floatingRateBond.yield(<a class="code" href="class_quant_lib_1_1_actual360.html" title="Actual/360 day count convention.">Actual360</a>(),Compounded,<a class="code" href="group__datetime.html#gga6d41db8ba0ea90d22df35889df452adaa508b18014c96e2d466c12b39d7f4e426" title="once a year">Annual</a>))
         &lt;&lt; std::endl;

         std::cout &lt;&lt; std::endl;

         <span class="comment">// Other computations</span>
         std::cout &lt;&lt; <span class="stringliteral">&quot;Sample indirect computations (for the floating rate bond): &quot;</span> &lt;&lt; std::endl;
         std::cout &lt;&lt; rule &lt;&lt; std::endl;

         std::cout &lt;&lt; <span class="stringliteral">&quot;Yield to Clean Price: &quot;</span>
         &lt;&lt; floatingRateBond.cleanPrice(floatingRateBond.yield(<a class="code" href="class_quant_lib_1_1_actual360.html" title="Actual/360 day count convention.">Actual360</a>(),Compounded,<a class="code" href="group__datetime.html#gga6d41db8ba0ea90d22df35889df452adaa508b18014c96e2d466c12b39d7f4e426" title="once a year">Annual</a>),<a class="code" href="class_quant_lib_1_1_actual360.html" title="Actual/360 day count convention.">Actual360</a>(),Compounded,<a class="code" href="group__datetime.html#gga6d41db8ba0ea90d22df35889df452adaa508b18014c96e2d466c12b39d7f4e426" title="once a year">Annual</a>,settlementDate) &lt;&lt; std::endl;

         std::cout &lt;&lt; <span class="stringliteral">&quot;Clean Price to Yield: &quot;</span>
         &lt;&lt; <a class="code" href="group__manips.html#gac63ea3dad10259db3764c7d15a61cde5" title="output rates and spreads as percentages">io::rate</a>(floatingRateBond.yield(floatingRateBond.cleanPrice(),<a class="code" href="class_quant_lib_1_1_actual360.html" title="Actual/360 day count convention.">Actual360</a>(),Compounded,<a class="code" href="group__datetime.html#gga6d41db8ba0ea90d22df35889df452adaa508b18014c96e2d466c12b39d7f4e426" title="once a year">Annual</a>,settlementDate)) &lt;&lt; std::endl;

         <span class="comment">/* &quot;Yield to Price&quot;</span>
<span class="comment">            &quot;Price to Yield&quot; */</span>

         <a class="code" href="group__types.html#ga4bdf4bfe76b9ffa6fa64c47d8bfa0c78" title="real number">Real</a> seconds = timer.elapsed();
         <a class="code" href="group__types.html#gab9c87440c314438e51a899a03d2442d0" title="integer number">Integer</a> hours = int(seconds/3600);
         seconds -= hours * 3600;
         <a class="code" href="group__types.html#gab9c87440c314438e51a899a03d2442d0" title="integer number">Integer</a> minutes = int(seconds/60);
         seconds -= minutes * 60;
         std::cout &lt;&lt; <span class="stringliteral">&quot; \nRun completed in &quot;</span>;
         <span class="keywordflow">if</span> (hours &gt; 0)
             std::cout &lt;&lt; hours &lt;&lt; <span class="stringliteral">&quot; h &quot;</span>;
         <span class="keywordflow">if</span> (hours &gt; 0 || minutes &gt; 0)
             std::cout &lt;&lt; minutes &lt;&lt; <span class="stringliteral">&quot; m &quot;</span>;
         std::cout &lt;&lt; std::fixed &lt;&lt; std::setprecision(0)
         &lt;&lt; seconds &lt;&lt; <span class="stringliteral">&quot; s\n&quot;</span> &lt;&lt; std::endl;

         <span class="keywordflow">return</span> 0;

    } <span class="keywordflow">catch</span> (std::exception&amp; e) {
        std::cerr &lt;&lt; e.what() &lt;&lt; std::endl;
        <span class="keywordflow">return</span> 1;
    } <span class="keywordflow">catch</span> (...) {
        std::cerr &lt;&lt; <span class="stringliteral">&quot;unknown error&quot;</span> &lt;&lt; std::endl;
        <span class="keywordflow">return</span> 1;
    }
}

</pre></div> </div><!-- contents -->
</div><!-- contents -->

</div>

<div class="footer">
<div class="endmatter">
Documentation generated by
<a href="http://www.doxygen.org">Doxygen</a> 1.7.6.1
</div>
</div>

</div>

</body>
</html>