File: swapvaluation_8cpp-example.html

package info (click to toggle)
quantlib-refman-html 0.9.0-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 60,592 kB
  • ctags: 7,595
  • sloc: makefile: 30
file content (845 lines) | stat: -rw-r--r-- 68,981 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
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<meta name="robots" content="none">
<title>QuantLib: swapvaluation.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.9.0</h3>

<hr>

<h3 class="navbartitle">Getting started</h3>
<ul class="navbarlist">
<li class="navlink"><a href="index.html">Introduction</a></li>
<li class="navlink"><a href="overview.html">Project overview</a></li>
<li class="navlink"><a href="where.html">Where to get QuantLib</a></li>
<li class="navlink"><a href="install.html">Installation</a></li>
<li class="navlink"><a href="config.html">Configuration</a></li>
<li class="navlink"><a href="usage.html">Usage</a></li>
<li class="navlink"><a href="history.html">Version history</a></li>
<li class="navlink"><a href="resources.html">Additional resources</a></li>
<li class="navlink"><a href="group.html">The QuantLib group</a></li>
<li class="navlink"><a href="license.html">Copyright and license</a></li>
</ul>

<hr>

<h3 class="navbartitle">Reference manual</h3>
<ul class="navbarlist">
<li class="navlink"><a href="modules.html">Modules</a></li>
<li class="navlink"><a href="hierarchy.html">Class Hierarchy</a></li>
<li class="navlink"><a href="annotated.html">Compound List</a></li>
<li class="navlink"><a href="files.html">File List</a></li>
<li class="navlink"><a href="functions.html">Compound Members</a></li>
<li class="navlink"><a href="globals.html">File Members</a></li>
<li class="navlink"><a href="bug.html">Known Bugs</a></li>
<li class="navlink"><a href="caveats.html">Caveats</a></li>
<li class="navlink"><a href="test.html">Test Suite</a></li>
<li class="navlink"><a href="examples.html">Examples</a></li>
</ul>
</div>

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

<!-- Generated by Doxygen 1.5.4 -->
<h1>swapvaluation.cpp</h1>This is an example of using the QuantLib Term Structure for pricing a simple swap.<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 a simple</span>
<span class="comment">    swap.</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">#ifdef BOOST_MSVC</span>
<span class="preprocessor"></span><span class="comment">/* Uncomment the following lines to unmask floating-point</span>
<span class="comment">   exceptions. Warning: unpredictable results can arise...</span>
<span class="comment"></span>
<span class="comment">   See http://www.wilmott.com/messageview.cfm?catid=10&amp;threadid=9481</span>
<span class="comment">   Is there anyone with a definitive word about this?</span>
<span class="comment">*/</span>
<span class="comment">// #include &lt;float.h&gt;</span>
<span class="comment">// namespace { unsigned int u = _controlfp(_EM_INEXACT, _MCW_EM); }</span>
<span class="preprocessor">#endif</span>
<span class="preprocessor"></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#gb9c87440c314438e51a899a03d2442d0" 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>();
        <span class="comment">// uncommenting the following line generates an error</span>
        <span class="comment">// calendar = Tokyo();</span>
        <a name="_a3"></a><a class="code" href="class_quant_lib_1_1_date.html" title="Concrete date class.">Date</a> settlementDate(22, September, 2004);
        <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#ee7c18511c7ee1bcda6124f43a37aa28">adjust</a>(settlementDate);

        <a class="code" href="group__types.html#gb9c87440c314438e51a899a03d2442d0" title="integer number">Integer</a> fixingDays = 2;
        <a class="code" href="class_quant_lib_1_1_date.html" title="Concrete date class.">Date</a> todaysDate = calendar.<a name="a5"></a><a class="code" href="class_quant_lib_1_1_calendar.html#c47bb82bf7b147cfacf373991c2905ea">advance</a>(settlementDate, -fixingDays, Days);
        <span class="comment">// nothing to do with Date::todaysDate</span>
        Settings::instance().evaluationDate() = todaysDate;


        todaysDate = Settings::instance().evaluationDate();
        std::cout &lt;&lt; <span class="stringliteral">"Today: "</span> &lt;&lt; todaysDate.<a name="a6"></a><a class="code" href="class_quant_lib_1_1_date.html#baa5325a9945802025849f2ce19f216a">weekday</a>()
                  &lt;&lt; <span class="stringliteral">", "</span> &lt;&lt; todaysDate &lt;&lt; std::endl;

        std::cout &lt;&lt; <span class="stringliteral">"Settlement date: "</span> &lt;&lt; settlementDate.<a class="code" href="class_quant_lib_1_1_date.html#baa5325a9945802025849f2ce19f216a">weekday</a>()
                  &lt;&lt; <span class="stringliteral">", "</span> &lt;&lt; settlementDate &lt;&lt; std::endl;

        <span class="comment">// deposits</span>
        <a name="a7"></a><a class="code" href="group__types.html#gede435af51236692b1107d7639581d39" title="interest rates">Rate</a> d1wQuote=0.0382;
        <a class="code" href="group__types.html#gede435af51236692b1107d7639581d39" title="interest rates">Rate</a> d1mQuote=0.0372;
        <a class="code" href="group__types.html#gede435af51236692b1107d7639581d39" title="interest rates">Rate</a> d3mQuote=0.0363;
        <a class="code" href="group__types.html#gede435af51236692b1107d7639581d39" title="interest rates">Rate</a> d6mQuote=0.0353;
        <a class="code" href="group__types.html#gede435af51236692b1107d7639581d39" title="interest rates">Rate</a> d9mQuote=0.0348;
        <a class="code" href="group__types.html#gede435af51236692b1107d7639581d39" title="interest rates">Rate</a> d1yQuote=0.0345;
        <span class="comment">// FRAs</span>
        <a class="code" href="group__types.html#gede435af51236692b1107d7639581d39" title="interest rates">Rate</a> fra3x6Quote=0.037125;
        <a class="code" href="group__types.html#gede435af51236692b1107d7639581d39" title="interest rates">Rate</a> fra6x9Quote=0.037125;
        <a class="code" href="group__types.html#gede435af51236692b1107d7639581d39" title="interest rates">Rate</a> fra6x12Quote=0.037125;
        <span class="comment">// futures</span>
        <a name="a8"></a><a class="code" href="group__types.html#g4bdf4bfe76b9ffa6fa64c47d8bfa0c78" title="real number">Real</a> fut1Quote=96.2875;
        <a class="code" href="group__types.html#g4bdf4bfe76b9ffa6fa64c47d8bfa0c78" title="real number">Real</a> fut2Quote=96.7875;
        <a class="code" href="group__types.html#g4bdf4bfe76b9ffa6fa64c47d8bfa0c78" title="real number">Real</a> fut3Quote=96.9875;
        <a class="code" href="group__types.html#g4bdf4bfe76b9ffa6fa64c47d8bfa0c78" title="real number">Real</a> fut4Quote=96.6875;
        <a class="code" href="group__types.html#g4bdf4bfe76b9ffa6fa64c47d8bfa0c78" title="real number">Real</a> fut5Quote=96.4875;
        <a class="code" href="group__types.html#g4bdf4bfe76b9ffa6fa64c47d8bfa0c78" title="real number">Real</a> fut6Quote=96.3875;
        <a class="code" href="group__types.html#g4bdf4bfe76b9ffa6fa64c47d8bfa0c78" title="real number">Real</a> fut7Quote=96.2875;
        <a class="code" href="group__types.html#g4bdf4bfe76b9ffa6fa64c47d8bfa0c78" title="real number">Real</a> fut8Quote=96.0875;
        <span class="comment">// swaps</span>
        <a class="code" href="group__types.html#gede435af51236692b1107d7639581d39" title="interest rates">Rate</a> s2yQuote=0.037125;
        <a class="code" href="group__types.html#gede435af51236692b1107d7639581d39" title="interest rates">Rate</a> s3yQuote=0.0398;
        <a class="code" href="group__types.html#gede435af51236692b1107d7639581d39" title="interest rates">Rate</a> s5yQuote=0.0443;
        <a class="code" href="group__types.html#gede435af51236692b1107d7639581d39" title="interest rates">Rate</a> s10yQuote=0.05165;
        <a class="code" href="group__types.html#gede435af51236692b1107d7639581d39" title="interest rates">Rate</a> s15yQuote=0.055175;


        <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 name="_a9"></a><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">// FRAs</span>
        boost::shared_ptr&lt;Quote&gt; fra3x6Rate(<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>(fra3x6Quote));
        boost::shared_ptr&lt;Quote&gt; fra6x9Rate(<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>(fra6x9Quote));
        boost::shared_ptr&lt;Quote&gt; fra6x12Rate(<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>(fra6x12Quote));
        <span class="comment">// futures</span>
        boost::shared_ptr&lt;Quote&gt; fut1Price(<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>(fut1Quote));
        boost::shared_ptr&lt;Quote&gt; fut2Price(<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>(fut2Quote));
        boost::shared_ptr&lt;Quote&gt; fut3Price(<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>(fut3Quote));
        boost::shared_ptr&lt;Quote&gt; fut4Price(<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>(fut4Quote));
        boost::shared_ptr&lt;Quote&gt; fut5Price(<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>(fut5Quote));
        boost::shared_ptr&lt;Quote&gt; fut6Price(<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>(fut6Quote));
        boost::shared_ptr&lt;Quote&gt; fut7Price(<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>(fut7Quote));
        boost::shared_ptr&lt;Quote&gt; fut8Price(<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>(fut8Quote));
        <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 name="_a10"></a><a class="code" href="class_quant_lib_1_1_day_counter.html" title="day counter class">DayCounter</a> depositDayCounter = <a name="_a11"></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 name="_a12"></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="_a13"></a><a class="code" href="class_quant_lib_1_1_handle.html" title="Shared handle to an observable.">Handle&lt;Quote&gt;</a>(d1wRate),
            1*Weeks, fixingDays,
            calendar, <a name="a14"></a><a class="code" href="group__datetime.html#ggff46c5ae9385d20709bedade86edd368013e092c359f6031cc0563fd413ce707">ModifiedFollowing</a>,
            <span class="keyword">true</span>, fixingDays, 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" title="Shared handle to an observable.">Handle&lt;Quote&gt;</a>(d1mRate),
            1*Months, fixingDays,
            calendar, <a class="code" href="group__datetime.html#ggff46c5ae9385d20709bedade86edd368013e092c359f6031cc0563fd413ce707">ModifiedFollowing</a>,
            <span class="keyword">true</span>, fixingDays, 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" title="Shared handle to an observable.">Handle&lt;Quote&gt;</a>(d3mRate),
            3*Months, fixingDays,
            calendar, <a class="code" href="group__datetime.html#ggff46c5ae9385d20709bedade86edd368013e092c359f6031cc0563fd413ce707">ModifiedFollowing</a>,
            <span class="keyword">true</span>, fixingDays, 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" title="Shared handle to an observable.">Handle&lt;Quote&gt;</a>(d6mRate),
            6*Months, fixingDays,
            calendar, <a class="code" href="group__datetime.html#ggff46c5ae9385d20709bedade86edd368013e092c359f6031cc0563fd413ce707">ModifiedFollowing</a>,
            <span class="keyword">true</span>, fixingDays, 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" title="Shared handle to an observable.">Handle&lt;Quote&gt;</a>(d9mRate),
            9*Months, fixingDays,
            calendar, <a class="code" href="group__datetime.html#ggff46c5ae9385d20709bedade86edd368013e092c359f6031cc0563fd413ce707">ModifiedFollowing</a>,
            <span class="keyword">true</span>, fixingDays, 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" title="Shared handle to an observable.">Handle&lt;Quote&gt;</a>(d1yRate),
            1*Years, fixingDays,
            calendar, <a class="code" href="group__datetime.html#ggff46c5ae9385d20709bedade86edd368013e092c359f6031cc0563fd413ce707">ModifiedFollowing</a>,
            <span class="keyword">true</span>, fixingDays, depositDayCounter));


        <span class="comment">// setup FRAs</span>
        boost::shared_ptr&lt;RateHelper&gt; fra3x6(<span class="keyword">new</span> <a name="_a15"></a><a class="code" href="class_quant_lib_1_1_fra_rate_helper.html" title="Rate helper for bootstrapping over FRA rates.">FraRateHelper</a>(
            <a class="code" href="class_quant_lib_1_1_handle.html" title="Shared handle to an observable.">Handle&lt;Quote&gt;</a>(fra3x6Rate),
            3, 6, fixingDays, calendar, <a class="code" href="group__datetime.html#ggff46c5ae9385d20709bedade86edd368013e092c359f6031cc0563fd413ce707">ModifiedFollowing</a>,
            <span class="keyword">true</span>, fixingDays, depositDayCounter));
        boost::shared_ptr&lt;RateHelper&gt; fra6x9(<span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_fra_rate_helper.html" title="Rate helper for bootstrapping over FRA rates.">FraRateHelper</a>(
            <a class="code" href="class_quant_lib_1_1_handle.html" title="Shared handle to an observable.">Handle&lt;Quote&gt;</a>(fra6x9Rate),
            6, 9, fixingDays, calendar, <a class="code" href="group__datetime.html#ggff46c5ae9385d20709bedade86edd368013e092c359f6031cc0563fd413ce707">ModifiedFollowing</a>,
            <span class="keyword">true</span>, fixingDays, depositDayCounter));
        boost::shared_ptr&lt;RateHelper&gt; fra6x12(<span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_fra_rate_helper.html" title="Rate helper for bootstrapping over FRA rates.">FraRateHelper</a>(
            <a class="code" href="class_quant_lib_1_1_handle.html" title="Shared handle to an observable.">Handle&lt;Quote&gt;</a>(fra6x12Rate),
            6, 12, fixingDays, calendar, <a class="code" href="group__datetime.html#ggff46c5ae9385d20709bedade86edd368013e092c359f6031cc0563fd413ce707">ModifiedFollowing</a>,
            <span class="keyword">true</span>, fixingDays, depositDayCounter));


        <span class="comment">// setup futures</span>
        <a class="code" href="group__types.html#gede435af51236692b1107d7639581d39" title="interest rates">Rate</a> convexityAdjustment = 0.0;
        <a class="code" href="group__types.html#gb9c87440c314438e51a899a03d2442d0" title="integer number">Integer</a> futMonths = 3;
        <a class="code" href="class_quant_lib_1_1_date.html" title="Concrete date class.">Date</a> imm = IMM::nextDate(settlementDate);
        boost::shared_ptr&lt;RateHelper&gt; fut1(<span class="keyword">new</span> <a name="_a16"></a><a class="code" href="class_quant_lib_1_1_futures_rate_helper.html" title="Rate helper for bootstrapping over interest-rate futures prices.">FuturesRateHelper</a>(
            <a class="code" href="class_quant_lib_1_1_handle.html" title="Shared handle to an observable.">Handle&lt;Quote&gt;</a>(fut1Price),
            imm,
            futMonths, calendar, <a class="code" href="group__datetime.html#ggff46c5ae9385d20709bedade86edd368013e092c359f6031cc0563fd413ce707">ModifiedFollowing</a>,
            depositDayCounter, convexityAdjustment));
        imm = IMM::nextDate(imm+1);
        boost::shared_ptr&lt;RateHelper&gt; fut2(<span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_futures_rate_helper.html" title="Rate helper for bootstrapping over interest-rate futures prices.">FuturesRateHelper</a>(
            <a class="code" href="class_quant_lib_1_1_handle.html" title="Shared handle to an observable.">Handle&lt;Quote&gt;</a>(fut1Price),
            imm,
            futMonths, calendar, <a class="code" href="group__datetime.html#ggff46c5ae9385d20709bedade86edd368013e092c359f6031cc0563fd413ce707">ModifiedFollowing</a>,
            depositDayCounter, convexityAdjustment));
        imm = IMM::nextDate(imm+1);
        boost::shared_ptr&lt;RateHelper&gt; fut3(<span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_futures_rate_helper.html" title="Rate helper for bootstrapping over interest-rate futures prices.">FuturesRateHelper</a>(
            <a class="code" href="class_quant_lib_1_1_handle.html" title="Shared handle to an observable.">Handle&lt;Quote&gt;</a>(fut1Price),
            imm,
            futMonths, calendar, <a class="code" href="group__datetime.html#ggff46c5ae9385d20709bedade86edd368013e092c359f6031cc0563fd413ce707">ModifiedFollowing</a>,
            depositDayCounter, convexityAdjustment));
        imm = IMM::nextDate(imm+1);
        boost::shared_ptr&lt;RateHelper&gt; fut4(<span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_futures_rate_helper.html" title="Rate helper for bootstrapping over interest-rate futures prices.">FuturesRateHelper</a>(
            <a class="code" href="class_quant_lib_1_1_handle.html" title="Shared handle to an observable.">Handle&lt;Quote&gt;</a>(fut1Price),
            imm,
            futMonths, calendar, <a class="code" href="group__datetime.html#ggff46c5ae9385d20709bedade86edd368013e092c359f6031cc0563fd413ce707">ModifiedFollowing</a>,
            depositDayCounter, convexityAdjustment));
        imm = IMM::nextDate(imm+1);
        boost::shared_ptr&lt;RateHelper&gt; fut5(<span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_futures_rate_helper.html" title="Rate helper for bootstrapping over interest-rate futures prices.">FuturesRateHelper</a>(
            <a class="code" href="class_quant_lib_1_1_handle.html" title="Shared handle to an observable.">Handle&lt;Quote&gt;</a>(fut1Price),
            imm,
            futMonths, calendar, <a class="code" href="group__datetime.html#ggff46c5ae9385d20709bedade86edd368013e092c359f6031cc0563fd413ce707">ModifiedFollowing</a>,
            depositDayCounter, convexityAdjustment));
        imm = IMM::nextDate(imm+1);
        boost::shared_ptr&lt;RateHelper&gt; fut6(<span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_futures_rate_helper.html" title="Rate helper for bootstrapping over interest-rate futures prices.">FuturesRateHelper</a>(
            <a class="code" href="class_quant_lib_1_1_handle.html" title="Shared handle to an observable.">Handle&lt;Quote&gt;</a>(fut1Price),
            imm,
            futMonths, calendar, <a class="code" href="group__datetime.html#ggff46c5ae9385d20709bedade86edd368013e092c359f6031cc0563fd413ce707">ModifiedFollowing</a>,
            depositDayCounter, convexityAdjustment));
        imm = IMM::nextDate(imm+1);
        boost::shared_ptr&lt;RateHelper&gt; fut7(<span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_futures_rate_helper.html" title="Rate helper for bootstrapping over interest-rate futures prices.">FuturesRateHelper</a>(
            <a class="code" href="class_quant_lib_1_1_handle.html" title="Shared handle to an observable.">Handle&lt;Quote&gt;</a>(fut1Price),
            imm,
            futMonths, calendar, <a class="code" href="group__datetime.html#ggff46c5ae9385d20709bedade86edd368013e092c359f6031cc0563fd413ce707">ModifiedFollowing</a>,
            depositDayCounter, convexityAdjustment));
        imm = IMM::nextDate(imm+1);
        boost::shared_ptr&lt;RateHelper&gt; fut8(<span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_futures_rate_helper.html" title="Rate helper for bootstrapping over interest-rate futures prices.">FuturesRateHelper</a>(
            <a class="code" href="class_quant_lib_1_1_handle.html" title="Shared handle to an observable.">Handle&lt;Quote&gt;</a>(fut1Price),
            imm,
            futMonths, calendar, <a class="code" href="group__datetime.html#ggff46c5ae9385d20709bedade86edd368013e092c359f6031cc0563fd413ce707">ModifiedFollowing</a>,
            depositDayCounter, convexityAdjustment));


        <span class="comment">// setup swaps</span>
        <a class="code" href="group__datetime.html#g6d41db8ba0ea90d22df35889df452ada" title="Frequency of events.">Frequency</a> swFixedLegFrequency = <a name="a17"></a><a class="code" href="group__datetime.html#gg6d41db8ba0ea90d22df35889df452ada508b18014c96e2d466c12b39d7f4e426" title="once a year">Annual</a>;
        <a class="code" href="group__datetime.html#gff46c5ae9385d20709bedade86edd368" title="Business Day conventions.">BusinessDayConvention</a> swFixedLegConvention = <a name="a18"></a><a class="code" href="group__datetime.html#ggff46c5ae9385d20709bedade86edd3685fb8b90b7fdf1a3a228fbbc083e64547">Unadjusted</a>;
        <a class="code" href="class_quant_lib_1_1_day_counter.html" title="day counter class">DayCounter</a> swFixedLegDayCounter = <a name="_a19"></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="_a20"></a><a class="code" href="class_quant_lib_1_1_euribor6_m.html" title="6-months Euribor index">Euribor6M</a>);

        boost::shared_ptr&lt;RateHelper&gt; s2y(<span class="keyword">new</span> <a name="_a21"></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" title="Shared handle to an observable.">Handle&lt;Quote&gt;</a>(s2yRate), 2*Years,
            calendar, swFixedLegFrequency,
            swFixedLegConvention, swFixedLegDayCounter,
            swFloatingLegIndex));
        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" title="Shared handle to an observable.">Handle&lt;Quote&gt;</a>(s3yRate), 3*Years,
            calendar, swFixedLegFrequency,
            swFixedLegConvention, swFixedLegDayCounter,
            swFloatingLegIndex));
        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" title="Shared handle to an observable.">Handle&lt;Quote&gt;</a>(s5yRate), 5*Years,
            calendar, swFixedLegFrequency,
            swFixedLegConvention, swFixedLegDayCounter,
            swFloatingLegIndex));
        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" title="Shared handle to an observable.">Handle&lt;Quote&gt;</a>(s10yRate), 10*Years,
            calendar, swFixedLegFrequency,
            swFixedLegConvention, swFixedLegDayCounter,
            swFloatingLegIndex));
        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" title="Shared handle to an observable.">Handle&lt;Quote&gt;</a>(s15yRate), 15*Years,
            calendar, swFixedLegFrequency,
            swFixedLegConvention, swFixedLegDayCounter,
            swFloatingLegIndex));


        <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 name="_a22"></a><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-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 name="_a23"></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, depoSwapInstruments,
                                          termStructureDayCounter, tolerance));


        <span class="comment">// A depo-futures-swap curve</span>
        std::vector&lt;boost::shared_ptr&lt;RateHelper&gt; &gt; depoFutSwapInstruments;
        depoFutSwapInstruments.push_back(d1w);
        depoFutSwapInstruments.push_back(d1m);
        depoFutSwapInstruments.push_back(fut1);
        depoFutSwapInstruments.push_back(fut2);
        depoFutSwapInstruments.push_back(fut3);
        depoFutSwapInstruments.push_back(fut4);
        depoFutSwapInstruments.push_back(fut5);
        depoFutSwapInstruments.push_back(fut6);
        depoFutSwapInstruments.push_back(fut7);
        depoFutSwapInstruments.push_back(fut8);
        depoFutSwapInstruments.push_back(s3y);
        depoFutSwapInstruments.push_back(s5y);
        depoFutSwapInstruments.push_back(s10y);
        depoFutSwapInstruments.push_back(s15y);
        boost::shared_ptr&lt;YieldTermStructure&gt; depoFutSwapTermStructure(
            <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, depoFutSwapInstruments,
                                       termStructureDayCounter, tolerance));


        <span class="comment">// A depo-FRA-swap curve</span>
        std::vector&lt;boost::shared_ptr&lt;RateHelper&gt; &gt; depoFRASwapInstruments;
        depoFRASwapInstruments.push_back(d1w);
        depoFRASwapInstruments.push_back(d1m);
        depoFRASwapInstruments.push_back(d3m);
        depoFRASwapInstruments.push_back(fra3x6);
        depoFRASwapInstruments.push_back(fra6x9);
        depoFRASwapInstruments.push_back(fra6x12);
        depoFRASwapInstruments.push_back(s2y);
        depoFRASwapInstruments.push_back(s3y);
        depoFRASwapInstruments.push_back(s5y);
        depoFRASwapInstruments.push_back(s10y);
        depoFRASwapInstruments.push_back(s15y);
        boost::shared_ptr&lt;YieldTermStructure&gt; depoFRASwapTermStructure(
            <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, depoFRASwapInstruments,
                                       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="_a24"></a><a class="code" href="class_quant_lib_1_1_relinkable_handle.html" title="Relinkable handle to an observable.">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" title="Relinkable handle to an observable.">RelinkableHandle&lt;YieldTermStructure&gt;</a> forecastingTermStructure;


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

        <span class="comment">// constant nominal 1,000,000 Euro</span>
        <a class="code" href="group__types.html#g4bdf4bfe76b9ffa6fa64c47d8bfa0c78" title="real number">Real</a> nominal = 1000000.0;
        <span class="comment">// fixed leg</span>
        <a class="code" href="group__datetime.html#g6d41db8ba0ea90d22df35889df452ada" title="Frequency of events.">Frequency</a> fixedLegFrequency = <a class="code" href="group__datetime.html#gg6d41db8ba0ea90d22df35889df452ada508b18014c96e2d466c12b39d7f4e426" title="once a year">Annual</a>;
        <a class="code" href="group__datetime.html#gff46c5ae9385d20709bedade86edd368" title="Business Day conventions.">BusinessDayConvention</a> fixedLegConvention = <a class="code" href="group__datetime.html#ggff46c5ae9385d20709bedade86edd3685fb8b90b7fdf1a3a228fbbc083e64547">Unadjusted</a>;
        <a class="code" href="group__datetime.html#gff46c5ae9385d20709bedade86edd368" title="Business Day conventions.">BusinessDayConvention</a> floatingLegConvention = <a class="code" href="group__datetime.html#ggff46c5ae9385d20709bedade86edd368013e092c359f6031cc0563fd413ce707">ModifiedFollowing</a>;
        <a class="code" href="class_quant_lib_1_1_day_counter.html" title="day counter class">DayCounter</a> fixedLegDayCounter = <a class="code" href="class_quant_lib_1_1_thirty360.html" title="30/360 day count convention">Thirty360</a>(Thirty360::European);
        <a class="code" href="group__types.html#gede435af51236692b1107d7639581d39" title="interest rates">Rate</a> fixedRate = 0.04;
        <a class="code" href="class_quant_lib_1_1_day_counter.html" title="day counter class">DayCounter</a> floatingLegDayCounter = <a class="code" href="class_quant_lib_1_1_actual360.html" title="Actual/360 day count convention.">Actual360</a>();

        <span class="comment">// floating leg</span>
        <a class="code" href="group__datetime.html#g6d41db8ba0ea90d22df35889df452ada" title="Frequency of events.">Frequency</a> floatingLegFrequency = <a name="a25"></a><a class="code" href="group__datetime.html#gg6d41db8ba0ea90d22df35889df452adad1a5868a1c314bb7f6ab68e2fa182b2d" title="twice a year">Semiannual</a>;
        boost::shared_ptr&lt;IborIndex&gt; euriborIndex(
                                     <span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_euribor6_m.html" title="6-months Euribor index">Euribor6M</a>(forecastingTermStructure));
        <a name="a26"></a><a class="code" href="group__types.html#ge7427f4743503002b0c6eeeefae91a3d" title="spreads on interest rates">Spread</a> spread = 0.0;

        <a class="code" href="group__types.html#gb9c87440c314438e51a899a03d2442d0" title="integer number">Integer</a> lenghtInYears = 5;
        VanillaSwap::Type swapType = VanillaSwap::Payer;

        <a class="code" href="class_quant_lib_1_1_date.html" title="Concrete date class.">Date</a> maturity = settlementDate + lenghtInYears*Years;
        <a name="_a27"></a><a class="code" href="class_quant_lib_1_1_schedule.html" title="Payment schedule.">Schedule</a> fixedSchedule(settlementDate, maturity,
                               <a name="_a28"></a><a class="code" href="class_quant_lib_1_1_period.html">Period</a>(fixedLegFrequency),
                               calendar, fixedLegConvention,
                               fixedLegConvention,
                               DateGeneration::Forward, <span class="keyword">false</span>);
        <a class="code" href="class_quant_lib_1_1_schedule.html" title="Payment schedule.">Schedule</a> floatSchedule(settlementDate, maturity,
                               <a class="code" href="class_quant_lib_1_1_period.html">Period</a>(floatingLegFrequency),
                               calendar, floatingLegConvention,
                               floatingLegConvention,
                               DateGeneration::Forward, <span class="keyword">false</span>);
        <a name="_a29"></a><a class="code" href="class_quant_lib_1_1_vanilla_swap.html" title="Plain-vanilla swap.">VanillaSwap</a> spot5YearSwap(swapType, nominal,
            fixedSchedule, fixedRate, fixedLegDayCounter,
            floatSchedule, euriborIndex, spread,
            floatingLegDayCounter);

        <a class="code" href="class_quant_lib_1_1_date.html" title="Concrete date class.">Date</a> fwdStart = calendar.<a class="code" href="class_quant_lib_1_1_calendar.html#c47bb82bf7b147cfacf373991c2905ea">advance</a>(settlementDate, 1, Years);
        <a class="code" href="class_quant_lib_1_1_date.html" title="Concrete date class.">Date</a> fwdMaturity = fwdStart + lenghtInYears*Years;
        <a class="code" href="class_quant_lib_1_1_schedule.html" title="Payment schedule.">Schedule</a> fwdFixedSchedule(fwdStart, fwdMaturity,
                                  <a class="code" href="class_quant_lib_1_1_period.html">Period</a>(fixedLegFrequency),
                                  calendar, fixedLegConvention,
                                  fixedLegConvention,
                                  DateGeneration::Forward, <span class="keyword">false</span>);
        <a class="code" href="class_quant_lib_1_1_schedule.html" title="Payment schedule.">Schedule</a> fwdFloatSchedule(fwdStart, fwdMaturity,
                                  <a class="code" href="class_quant_lib_1_1_period.html">Period</a>(floatingLegFrequency),
                                  calendar, floatingLegConvention,
                                  floatingLegConvention,
                                  DateGeneration::Forward, <span class="keyword">false</span>);
        <a class="code" href="class_quant_lib_1_1_vanilla_swap.html" title="Plain-vanilla swap.">VanillaSwap</a> oneYearForward5YearSwap(swapType, nominal,
            fwdFixedSchedule, fixedRate, fixedLegDayCounter,
            fwdFloatSchedule, euriborIndex, spread,
            floatingLegDayCounter);


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

        <span class="comment">// utilities for reporting</span>
        std::vector&lt;std::string&gt; headers(4);
        headers[0] = <span class="stringliteral">"term structure"</span>;
        headers[1] = <span class="stringliteral">"net present value"</span>;
        headers[2] = <span class="stringliteral">"fair spread"</span>;
        headers[3] = <span class="stringliteral">"fair fixed rate"</span>;
        std::string separator = <span class="stringliteral">" | "</span>;
        <a name="a30"></a><a class="code" href="group__types.html#gf38bdb4c54463b1f456655efa95b5c77" title="size of a container">Size</a> width = headers[0].size() + separator.size()
                   + headers[1].size() + separator.size()
                   + headers[2].size() + separator.size()
                   + headers[3].size() + separator.size() - 1;
        std::string rule(width, <span class="charliteral">'-'</span>), dblrule(width, <span class="charliteral">'='</span>);
        std::string tab(8, <span class="charliteral">' '</span>);

        <span class="comment">// calculations</span>

        std::cout &lt;&lt; dblrule &lt;&lt; std::endl;
        std::cout &lt;&lt;  <span class="stringliteral">"5-year market swap-rate = "</span>
                  &lt;&lt; std::setprecision(2) &lt;&lt; <a name="a31"></a><a class="code" href="group__manips.html#gc63ea3dad10259db3764c7d15a61cde5" title="output rates and spreads as percentages">io::rate</a>(s5yRate-&gt;value())
                  &lt;&lt; std::endl;
        std::cout &lt;&lt; dblrule &lt;&lt; std::endl;

        std::cout &lt;&lt; tab &lt;&lt; <span class="stringliteral">"5-years swap paying "</span>
                  &lt;&lt; <a class="code" href="group__manips.html#gc63ea3dad10259db3764c7d15a61cde5" title="output rates and spreads as percentages">io::rate</a>(fixedRate) &lt;&lt; std::endl;
        std::cout &lt;&lt; headers[0] &lt;&lt; separator
                  &lt;&lt; headers[1] &lt;&lt; separator
                  &lt;&lt; headers[2] &lt;&lt; separator
                  &lt;&lt; headers[3] &lt;&lt; separator &lt;&lt; std::endl;
        std::cout &lt;&lt; rule &lt;&lt; std::endl;

        <a class="code" href="group__types.html#g4bdf4bfe76b9ffa6fa64c47d8bfa0c78" title="real number">Real</a> NPV;
        <a class="code" href="group__types.html#gede435af51236692b1107d7639581d39" title="interest rates">Rate</a> fairRate;
        <a class="code" href="group__types.html#ge7427f4743503002b0c6eeeefae91a3d" title="spreads on interest rates">Spread</a> fairSpread;

        boost::shared_ptr&lt;PricingEngine&gt; swapEngine(
                         <span class="keyword">new</span> DiscountingSwapEngine(discountingTermStructure));

        spot5YearSwap.setPricingEngine(swapEngine);
        oneYearForward5YearSwap.setPricingEngine(swapEngine);

        <span class="comment">// Of course, you're not forced to really use different curves</span>
        forecastingTermStructure.<a name="a32"></a><a class="code" href="class_quant_lib_1_1_relinkable_handle.html#7eec88ccb240dcc59ac81e7347c335bd">linkTo</a>(depoSwapTermStructure);
        discountingTermStructure.<a class="code" href="class_quant_lib_1_1_relinkable_handle.html#7eec88ccb240dcc59ac81e7347c335bd">linkTo</a>(depoSwapTermStructure);

        NPV = spot5YearSwap.NPV();
        fairSpread = spot5YearSwap.fairSpread();
        fairRate = spot5YearSwap.fairRate();

        std::cout &lt;&lt; std::setw(headers[0].size())
                  &lt;&lt; <span class="stringliteral">"depo-swap"</span> &lt;&lt; separator;
        std::cout &lt;&lt; std::setw(headers[1].size())
                  &lt;&lt; std::fixed &lt;&lt; std::setprecision(2) &lt;&lt; NPV &lt;&lt; separator;
        std::cout &lt;&lt; std::setw(headers[2].size())
                  &lt;&lt; <a class="code" href="group__manips.html#gc63ea3dad10259db3764c7d15a61cde5" title="output rates and spreads as percentages">io::rate</a>(fairSpread) &lt;&lt; separator;
        std::cout &lt;&lt; std::setw(headers[3].size())
                  &lt;&lt; <a class="code" href="group__manips.html#gc63ea3dad10259db3764c7d15a61cde5" title="output rates and spreads as percentages">io::rate</a>(fairRate) &lt;&lt; separator;
        std::cout &lt;&lt; std::endl;


        <span class="comment">// let's check that the 5 years swap has been correctly re-priced</span>
        <a name="a33"></a><a class="code" href="errors_8hpp.html#7a9bcab8006882bc7d5302a0861ab1a6" title="throw an error if the given pre-condition is not verified">QL_REQUIRE</a>(std::fabs(fairRate-s5yQuote)&lt;1e-8,
                   <span class="stringliteral">"5-years swap mispriced by "</span>
                   &lt;&lt; <a class="code" href="group__manips.html#gc63ea3dad10259db3764c7d15a61cde5" title="output rates and spreads as percentages">io::rate</a>(std::fabs(fairRate-s5yQuote)));


        forecastingTermStructure.<a class="code" href="class_quant_lib_1_1_relinkable_handle.html#7eec88ccb240dcc59ac81e7347c335bd">linkTo</a>(depoFutSwapTermStructure);
        discountingTermStructure.<a class="code" href="class_quant_lib_1_1_relinkable_handle.html#7eec88ccb240dcc59ac81e7347c335bd">linkTo</a>(depoFutSwapTermStructure);

        NPV = spot5YearSwap.NPV();
        fairSpread = spot5YearSwap.fairSpread();
        fairRate = spot5YearSwap.fairRate();

        std::cout &lt;&lt; std::setw(headers[0].size())
                  &lt;&lt; <span class="stringliteral">"depo-fut-swap"</span> &lt;&lt; separator;
        std::cout &lt;&lt; std::setw(headers[1].size())
                  &lt;&lt; std::fixed &lt;&lt; std::setprecision(2) &lt;&lt; NPV &lt;&lt; separator;
        std::cout &lt;&lt; std::setw(headers[2].size())
                  &lt;&lt; <a class="code" href="group__manips.html#gc63ea3dad10259db3764c7d15a61cde5" title="output rates and spreads as percentages">io::rate</a>(fairSpread) &lt;&lt; separator;
        std::cout &lt;&lt; std::setw(headers[3].size())
                  &lt;&lt; <a class="code" href="group__manips.html#gc63ea3dad10259db3764c7d15a61cde5" title="output rates and spreads as percentages">io::rate</a>(fairRate) &lt;&lt; separator;
        std::cout &lt;&lt; std::endl;

        <a class="code" href="errors_8hpp.html#7a9bcab8006882bc7d5302a0861ab1a6" title="throw an error if the given pre-condition is not verified">QL_REQUIRE</a>(std::fabs(fairRate-s5yQuote)&lt;1e-8,
                   <span class="stringliteral">"5-years swap mispriced!"</span>);


        forecastingTermStructure.<a class="code" href="class_quant_lib_1_1_relinkable_handle.html#7eec88ccb240dcc59ac81e7347c335bd">linkTo</a>(depoFRASwapTermStructure);
        discountingTermStructure.<a class="code" href="class_quant_lib_1_1_relinkable_handle.html#7eec88ccb240dcc59ac81e7347c335bd">linkTo</a>(depoFRASwapTermStructure);

        NPV = spot5YearSwap.NPV();
        fairSpread = spot5YearSwap.fairSpread();
        fairRate = spot5YearSwap.fairRate();

        std::cout &lt;&lt; std::setw(headers[0].size())
                  &lt;&lt; <span class="stringliteral">"depo-FRA-swap"</span> &lt;&lt; separator;
        std::cout &lt;&lt; std::setw(headers[1].size())
                  &lt;&lt; std::fixed &lt;&lt; std::setprecision(2) &lt;&lt; NPV &lt;&lt; separator;
        std::cout &lt;&lt; std::setw(headers[2].size())
                  &lt;&lt; <a class="code" href="group__manips.html#gc63ea3dad10259db3764c7d15a61cde5" title="output rates and spreads as percentages">io::rate</a>(fairSpread) &lt;&lt; separator;
        std::cout &lt;&lt; std::setw(headers[3].size())
                  &lt;&lt; <a class="code" href="group__manips.html#gc63ea3dad10259db3764c7d15a61cde5" title="output rates and spreads as percentages">io::rate</a>(fairRate) &lt;&lt; separator;
        std::cout &lt;&lt; std::endl;

        <a class="code" href="errors_8hpp.html#7a9bcab8006882bc7d5302a0861ab1a6" title="throw an error if the given pre-condition is not verified">QL_REQUIRE</a>(std::fabs(fairRate-s5yQuote)&lt;1e-8,
                   <span class="stringliteral">"5-years swap mispriced!"</span>);


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

        <span class="comment">// now let's price the 1Y forward 5Y swap</span>

        std::cout &lt;&lt; tab &lt;&lt; <span class="stringliteral">"5-years, 1-year forward swap paying "</span>
                  &lt;&lt; <a class="code" href="group__manips.html#gc63ea3dad10259db3764c7d15a61cde5" title="output rates and spreads as percentages">io::rate</a>(fixedRate) &lt;&lt; std::endl;
        std::cout &lt;&lt; headers[0] &lt;&lt; separator
                  &lt;&lt; headers[1] &lt;&lt; separator
                  &lt;&lt; headers[2] &lt;&lt; separator
                  &lt;&lt; headers[3] &lt;&lt; separator &lt;&lt; std::endl;
        std::cout &lt;&lt; rule &lt;&lt; std::endl;


        forecastingTermStructure.<a class="code" href="class_quant_lib_1_1_relinkable_handle.html#7eec88ccb240dcc59ac81e7347c335bd">linkTo</a>(depoSwapTermStructure);
        discountingTermStructure.<a class="code" href="class_quant_lib_1_1_relinkable_handle.html#7eec88ccb240dcc59ac81e7347c335bd">linkTo</a>(depoSwapTermStructure);

        NPV = oneYearForward5YearSwap.NPV();
        fairSpread = oneYearForward5YearSwap.fairSpread();
        fairRate = oneYearForward5YearSwap.fairRate();

        std::cout &lt;&lt; std::setw(headers[0].size())
                  &lt;&lt; <span class="stringliteral">"depo-swap"</span> &lt;&lt; separator;
        std::cout &lt;&lt; std::setw(headers[1].size())
                  &lt;&lt; std::fixed &lt;&lt; std::setprecision(2) &lt;&lt; NPV &lt;&lt; separator;
        std::cout &lt;&lt; std::setw(headers[2].size())
                  &lt;&lt; <a class="code" href="group__manips.html#gc63ea3dad10259db3764c7d15a61cde5" title="output rates and spreads as percentages">io::rate</a>(fairSpread) &lt;&lt; separator;
        std::cout &lt;&lt; std::setw(headers[3].size())
                  &lt;&lt; <a class="code" href="group__manips.html#gc63ea3dad10259db3764c7d15a61cde5" title="output rates and spreads as percentages">io::rate</a>(fairRate) &lt;&lt; separator;
        std::cout &lt;&lt; std::endl;


        forecastingTermStructure.<a class="code" href="class_quant_lib_1_1_relinkable_handle.html#7eec88ccb240dcc59ac81e7347c335bd">linkTo</a>(depoFutSwapTermStructure);
        discountingTermStructure.<a class="code" href="class_quant_lib_1_1_relinkable_handle.html#7eec88ccb240dcc59ac81e7347c335bd">linkTo</a>(depoFutSwapTermStructure);

        NPV = oneYearForward5YearSwap.NPV();
        fairSpread = oneYearForward5YearSwap.fairSpread();
        fairRate = oneYearForward5YearSwap.fairRate();

        std::cout &lt;&lt; std::setw(headers[0].size())
                  &lt;&lt; <span class="stringliteral">"depo-fut-swap"</span> &lt;&lt; separator;
        std::cout &lt;&lt; std::setw(headers[1].size())
                  &lt;&lt; std::fixed &lt;&lt; std::setprecision(2) &lt;&lt; NPV &lt;&lt; separator;
        std::cout &lt;&lt; std::setw(headers[2].size())
                  &lt;&lt; <a class="code" href="group__manips.html#gc63ea3dad10259db3764c7d15a61cde5" title="output rates and spreads as percentages">io::rate</a>(fairSpread) &lt;&lt; separator;
        std::cout &lt;&lt; std::setw(headers[3].size())
                  &lt;&lt; <a class="code" href="group__manips.html#gc63ea3dad10259db3764c7d15a61cde5" title="output rates and spreads as percentages">io::rate</a>(fairRate) &lt;&lt; separator;
        std::cout &lt;&lt; std::endl;


        forecastingTermStructure.<a class="code" href="class_quant_lib_1_1_relinkable_handle.html#7eec88ccb240dcc59ac81e7347c335bd">linkTo</a>(depoFRASwapTermStructure);
        discountingTermStructure.<a class="code" href="class_quant_lib_1_1_relinkable_handle.html#7eec88ccb240dcc59ac81e7347c335bd">linkTo</a>(depoFRASwapTermStructure);

        NPV = oneYearForward5YearSwap.NPV();
        fairSpread = oneYearForward5YearSwap.fairSpread();
        fairRate = oneYearForward5YearSwap.fairRate();

        std::cout &lt;&lt; std::setw(headers[0].size())
                  &lt;&lt; <span class="stringliteral">"depo-FRA-swap"</span> &lt;&lt; separator;
        std::cout &lt;&lt; std::setw(headers[1].size())
                  &lt;&lt; std::fixed &lt;&lt; std::setprecision(2) &lt;&lt; NPV &lt;&lt; separator;
        std::cout &lt;&lt; std::setw(headers[2].size())
                  &lt;&lt; <a class="code" href="group__manips.html#gc63ea3dad10259db3764c7d15a61cde5" title="output rates and spreads as percentages">io::rate</a>(fairSpread) &lt;&lt; separator;
        std::cout &lt;&lt; std::setw(headers[3].size())
                  &lt;&lt; <a class="code" href="group__manips.html#gc63ea3dad10259db3764c7d15a61cde5" title="output rates and spreads as percentages">io::rate</a>(fairRate) &lt;&lt; separator;
        std::cout &lt;&lt; std::endl;


        <span class="comment">// now let's say that the 5-years swap rate goes up to 4.60%.</span>
        <span class="comment">// A smarter market element--say, connected to a data source-- would</span>
        <span class="comment">// notice the change itself. Since we're using SimpleQuotes,</span>
        <span class="comment">// we'll have to change the value manually--which forces us to</span>
        <span class="comment">// downcast the handle and use the SimpleQuote</span>
        <span class="comment">// interface. In any case, the point here is that a change in the</span>
        <span class="comment">// value contained in the Quote triggers a new bootstrapping</span>
        <span class="comment">// of the curve and a repricing of the swap.</span>

        boost::shared_ptr&lt;SimpleQuote&gt; fiveYearsRate =
            boost::dynamic_pointer_cast&lt;<a class="code" href="class_quant_lib_1_1_simple_quote.html" title="market element returning a stored value">SimpleQuote</a>&gt;(s5yRate);
        fiveYearsRate-&gt;setValue(0.0460);

        std::cout &lt;&lt; dblrule &lt;&lt; std::endl;
        std::cout &lt;&lt;  <span class="stringliteral">"5-year market swap-rate = "</span>
                  &lt;&lt; <a class="code" href="group__manips.html#gc63ea3dad10259db3764c7d15a61cde5" title="output rates and spreads as percentages">io::rate</a>(s5yRate-&gt;value()) &lt;&lt; std::endl;
        std::cout &lt;&lt; dblrule &lt;&lt; std::endl;

        std::cout &lt;&lt; tab &lt;&lt; <span class="stringliteral">"5-years swap paying "</span>
                  &lt;&lt; <a class="code" href="group__manips.html#gc63ea3dad10259db3764c7d15a61cde5" title="output rates and spreads as percentages">io::rate</a>(fixedRate) &lt;&lt; std::endl;
        std::cout &lt;&lt; headers[0] &lt;&lt; separator
                  &lt;&lt; headers[1] &lt;&lt; separator
                  &lt;&lt; headers[2] &lt;&lt; separator
                  &lt;&lt; headers[3] &lt;&lt; separator &lt;&lt; std::endl;
        std::cout &lt;&lt; rule &lt;&lt; std::endl;

        <span class="comment">// now get the updated results</span>
        forecastingTermStructure.<a class="code" href="class_quant_lib_1_1_relinkable_handle.html#7eec88ccb240dcc59ac81e7347c335bd">linkTo</a>(depoSwapTermStructure);
        discountingTermStructure.<a class="code" href="class_quant_lib_1_1_relinkable_handle.html#7eec88ccb240dcc59ac81e7347c335bd">linkTo</a>(depoSwapTermStructure);

        NPV = spot5YearSwap.NPV();
        fairSpread = spot5YearSwap.fairSpread();
        fairRate = spot5YearSwap.fairRate();

        std::cout &lt;&lt; std::setw(headers[0].size())
                  &lt;&lt; <span class="stringliteral">"depo-swap"</span> &lt;&lt; separator;
        std::cout &lt;&lt; std::setw(headers[1].size())
                  &lt;&lt; std::fixed &lt;&lt; std::setprecision(2) &lt;&lt; NPV &lt;&lt; separator;
        std::cout &lt;&lt; std::setw(headers[2].size())
                  &lt;&lt; <a class="code" href="group__manips.html#gc63ea3dad10259db3764c7d15a61cde5" title="output rates and spreads as percentages">io::rate</a>(fairSpread) &lt;&lt; separator;
        std::cout &lt;&lt; std::setw(headers[3].size())
                  &lt;&lt; <a class="code" href="group__manips.html#gc63ea3dad10259db3764c7d15a61cde5" title="output rates and spreads as percentages">io::rate</a>(fairRate) &lt;&lt; separator;
        std::cout &lt;&lt; std::endl;

        <a class="code" href="errors_8hpp.html#7a9bcab8006882bc7d5302a0861ab1a6" title="throw an error if the given pre-condition is not verified">QL_REQUIRE</a>(std::fabs(fairRate-s5yRate-&gt;value())&lt;1e-8,
                   <span class="stringliteral">"5-years swap mispriced!"</span>);


        forecastingTermStructure.<a class="code" href="class_quant_lib_1_1_relinkable_handle.html#7eec88ccb240dcc59ac81e7347c335bd">linkTo</a>(depoFutSwapTermStructure);
        discountingTermStructure.<a class="code" href="class_quant_lib_1_1_relinkable_handle.html#7eec88ccb240dcc59ac81e7347c335bd">linkTo</a>(depoFutSwapTermStructure);

        NPV = spot5YearSwap.NPV();
        fairSpread = spot5YearSwap.fairSpread();
        fairRate = spot5YearSwap.fairRate();

        std::cout &lt;&lt; std::setw(headers[0].size())
                  &lt;&lt; <span class="stringliteral">"depo-fut-swap"</span> &lt;&lt; separator;
        std::cout &lt;&lt; std::setw(headers[1].size())
                  &lt;&lt; std::fixed &lt;&lt; std::setprecision(2) &lt;&lt; NPV &lt;&lt; separator;
        std::cout &lt;&lt; std::setw(headers[2].size())
                  &lt;&lt; <a class="code" href="group__manips.html#gc63ea3dad10259db3764c7d15a61cde5" title="output rates and spreads as percentages">io::rate</a>(fairSpread) &lt;&lt; separator;
        std::cout &lt;&lt; std::setw(headers[3].size())
                  &lt;&lt; <a class="code" href="group__manips.html#gc63ea3dad10259db3764c7d15a61cde5" title="output rates and spreads as percentages">io::rate</a>(fairRate) &lt;&lt; separator;
        std::cout &lt;&lt; std::endl;

        <a class="code" href="errors_8hpp.html#7a9bcab8006882bc7d5302a0861ab1a6" title="throw an error if the given pre-condition is not verified">QL_REQUIRE</a>(std::fabs(fairRate-s5yRate-&gt;value())&lt;1e-8,
                   <span class="stringliteral">"5-years swap mispriced!"</span>);


        forecastingTermStructure.<a class="code" href="class_quant_lib_1_1_relinkable_handle.html#7eec88ccb240dcc59ac81e7347c335bd">linkTo</a>(depoFRASwapTermStructure);
        discountingTermStructure.<a class="code" href="class_quant_lib_1_1_relinkable_handle.html#7eec88ccb240dcc59ac81e7347c335bd">linkTo</a>(depoFRASwapTermStructure);

        NPV = spot5YearSwap.NPV();
        fairSpread = spot5YearSwap.fairSpread();
        fairRate = spot5YearSwap.fairRate();

        std::cout &lt;&lt; std::setw(headers[0].size())
                  &lt;&lt; <span class="stringliteral">"depo-FRA-swap"</span> &lt;&lt; separator;
        std::cout &lt;&lt; std::setw(headers[1].size())
                  &lt;&lt; std::fixed &lt;&lt; std::setprecision(2) &lt;&lt; NPV &lt;&lt; separator;
        std::cout &lt;&lt; std::setw(headers[2].size())
                  &lt;&lt; <a class="code" href="group__manips.html#gc63ea3dad10259db3764c7d15a61cde5" title="output rates and spreads as percentages">io::rate</a>(fairSpread) &lt;&lt; separator;
        std::cout &lt;&lt; std::setw(headers[3].size())
                  &lt;&lt; <a class="code" href="group__manips.html#gc63ea3dad10259db3764c7d15a61cde5" title="output rates and spreads as percentages">io::rate</a>(fairRate) &lt;&lt; separator;
        std::cout &lt;&lt; std::endl;

        <a class="code" href="errors_8hpp.html#7a9bcab8006882bc7d5302a0861ab1a6" title="throw an error if the given pre-condition is not verified">QL_REQUIRE</a>(std::fabs(fairRate-s5yRate-&gt;value())&lt;1e-8,
                   <span class="stringliteral">"5-years swap mispriced!"</span>);

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

        <span class="comment">// the 1Y forward 5Y swap changes as well</span>

        std::cout &lt;&lt; tab &lt;&lt; <span class="stringliteral">"5-years, 1-year forward swap paying "</span>
                  &lt;&lt; <a class="code" href="group__manips.html#gc63ea3dad10259db3764c7d15a61cde5" title="output rates and spreads as percentages">io::rate</a>(fixedRate) &lt;&lt; std::endl;
        std::cout &lt;&lt; headers[0] &lt;&lt; separator
                  &lt;&lt; headers[1] &lt;&lt; separator
                  &lt;&lt; headers[2] &lt;&lt; separator
                  &lt;&lt; headers[3] &lt;&lt; separator &lt;&lt; std::endl;
        std::cout &lt;&lt; rule &lt;&lt; std::endl;


        forecastingTermStructure.<a class="code" href="class_quant_lib_1_1_relinkable_handle.html#7eec88ccb240dcc59ac81e7347c335bd">linkTo</a>(depoSwapTermStructure);
        discountingTermStructure.<a class="code" href="class_quant_lib_1_1_relinkable_handle.html#7eec88ccb240dcc59ac81e7347c335bd">linkTo</a>(depoSwapTermStructure);

        NPV = oneYearForward5YearSwap.NPV();
        fairSpread = oneYearForward5YearSwap.fairSpread();
        fairRate = oneYearForward5YearSwap.fairRate();

        std::cout &lt;&lt; std::setw(headers[0].size())
                  &lt;&lt; <span class="stringliteral">"depo-swap"</span> &lt;&lt; separator;
        std::cout &lt;&lt; std::setw(headers[1].size())
                  &lt;&lt; std::fixed &lt;&lt; std::setprecision(2) &lt;&lt; NPV &lt;&lt; separator;
        std::cout &lt;&lt; std::setw(headers[2].size())
                  &lt;&lt; <a class="code" href="group__manips.html#gc63ea3dad10259db3764c7d15a61cde5" title="output rates and spreads as percentages">io::rate</a>(fairSpread) &lt;&lt; separator;
        std::cout &lt;&lt; std::setw(headers[3].size())
                  &lt;&lt; <a class="code" href="group__manips.html#gc63ea3dad10259db3764c7d15a61cde5" title="output rates and spreads as percentages">io::rate</a>(fairRate) &lt;&lt; separator;
        std::cout &lt;&lt; std::endl;


        forecastingTermStructure.<a class="code" href="class_quant_lib_1_1_relinkable_handle.html#7eec88ccb240dcc59ac81e7347c335bd">linkTo</a>(depoFutSwapTermStructure);
        discountingTermStructure.<a class="code" href="class_quant_lib_1_1_relinkable_handle.html#7eec88ccb240dcc59ac81e7347c335bd">linkTo</a>(depoFutSwapTermStructure);

        NPV = oneYearForward5YearSwap.NPV();
        fairSpread = oneYearForward5YearSwap.fairSpread();
        fairRate = oneYearForward5YearSwap.fairRate();

        std::cout &lt;&lt; std::setw(headers[0].size())
                  &lt;&lt; <span class="stringliteral">"depo-fut-swap"</span> &lt;&lt; separator;
        std::cout &lt;&lt; std::setw(headers[1].size())
                  &lt;&lt; std::fixed &lt;&lt; std::setprecision(2) &lt;&lt; NPV &lt;&lt; separator;
        std::cout &lt;&lt; std::setw(headers[2].size())
                  &lt;&lt; <a class="code" href="group__manips.html#gc63ea3dad10259db3764c7d15a61cde5" title="output rates and spreads as percentages">io::rate</a>(fairSpread) &lt;&lt; separator;
        std::cout &lt;&lt; std::setw(headers[3].size())
                  &lt;&lt; <a class="code" href="group__manips.html#gc63ea3dad10259db3764c7d15a61cde5" title="output rates and spreads as percentages">io::rate</a>(fairRate) &lt;&lt; separator;
        std::cout &lt;&lt; std::endl;


        forecastingTermStructure.<a class="code" href="class_quant_lib_1_1_relinkable_handle.html#7eec88ccb240dcc59ac81e7347c335bd">linkTo</a>(depoFRASwapTermStructure);
        discountingTermStructure.<a class="code" href="class_quant_lib_1_1_relinkable_handle.html#7eec88ccb240dcc59ac81e7347c335bd">linkTo</a>(depoFRASwapTermStructure);

        NPV = oneYearForward5YearSwap.NPV();
        fairSpread = oneYearForward5YearSwap.fairSpread();
        fairRate = oneYearForward5YearSwap.fairRate();

        std::cout &lt;&lt; std::setw(headers[0].size())
                  &lt;&lt; <span class="stringliteral">"depo-FRA-swap"</span> &lt;&lt; separator;
        std::cout &lt;&lt; std::setw(headers[1].size())
                  &lt;&lt; std::fixed &lt;&lt; std::setprecision(2) &lt;&lt; NPV &lt;&lt; separator;
        std::cout &lt;&lt; std::setw(headers[2].size())
                  &lt;&lt; <a class="code" href="group__manips.html#gc63ea3dad10259db3764c7d15a61cde5" title="output rates and spreads as percentages">io::rate</a>(fairSpread) &lt;&lt; separator;
        std::cout &lt;&lt; std::setw(headers[3].size())
                  &lt;&lt; <a class="code" href="group__manips.html#gc63ea3dad10259db3764c7d15a61cde5" title="output rates and spreads as percentages">io::rate</a>(fairRate) &lt;&lt; separator;
        std::cout &lt;&lt; std::endl;

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

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

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

</pre></div> 
</div>

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

</div>

</body>
</html>