1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2006, 2007 Ferdinando Ametrano
5
6 This file is part of QuantLib, a free-software/open-source library
7 for financial quantitative analysts and developers - http://quantlib.org/
8
9 QuantLib is free software: you can redistribute it and/or modify it
10 under the terms of the QuantLib license. You should have received a
11 copy of the license along with this program; if not, please email
12 <quantlib-dev@lists.sf.net>. The license is also available online at
13 <http://quantlib.org/license.shtml>.
14
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the license for more details.
18*/
19
20/*! \file makecms.hpp
21 \brief Helper class to instantiate standard market CMS.
22*/
23
24#ifndef quantlib_makecms_hpp
25#define quantlib_makecms_hpp
26
27#include <ql/cashflows/cmscoupon.hpp>
28#include <ql/cashflows/couponpricer.hpp>
29#include <ql/pricingengine.hpp>
30
31namespace QuantLib {
32
33 class Swap;
34 class IborIndex;
35
36 //! helper class for instantiating CMS
37 /*! This class provides a more comfortable way
38 to instantiate standard market constant maturity swap.
39 */
40 class MakeCms {
41 public:
42 MakeCms(const Period& swapTenor,
43 const ext::shared_ptr<SwapIndex>& swapIndex,
44 const ext::shared_ptr<IborIndex>& iborIndex,
45 Spread iborSpread = 0.0,
46 const Period& forwardStart = 0*Days);
47
48 MakeCms(const Period& swapTenor,
49 const ext::shared_ptr<SwapIndex>& swapIndex,
50 Spread iborSpread = 0.0,
51 const Period& forwardStart = 0*Days);
52
53 operator Swap() const;
54 operator ext::shared_ptr<Swap>() const ;
55
56 MakeCms& receiveCms(bool flag = true);
57 MakeCms& withNominal(Real n);
58 MakeCms& withEffectiveDate(const Date&);
59
60 MakeCms& withCmsLegTenor(const Period& t);
61 MakeCms& withCmsLegCalendar(const Calendar& cal);
62 MakeCms& withCmsLegConvention(BusinessDayConvention bdc);
63 MakeCms& withCmsLegTerminationDateConvention(BusinessDayConvention);
64 MakeCms& withCmsLegRule(DateGeneration::Rule r);
65 MakeCms& withCmsLegEndOfMonth(bool flag = true);
66 MakeCms& withCmsLegFirstDate(const Date& d);
67 MakeCms& withCmsLegNextToLastDate(const Date& d);
68 MakeCms& withCmsLegDayCount(const DayCounter& dc);
69
70 MakeCms& withFloatingLegTenor(const Period& t);
71 MakeCms& withFloatingLegCalendar(const Calendar& cal);
72 MakeCms& withFloatingLegConvention(BusinessDayConvention bdc);
73 MakeCms& withFloatingLegTerminationDateConvention(
74 BusinessDayConvention bdc);
75 MakeCms& withFloatingLegRule(DateGeneration::Rule r);
76 MakeCms& withFloatingLegEndOfMonth(bool flag = true);
77 MakeCms& withFloatingLegFirstDate(const Date& d);
78 MakeCms& withFloatingLegNextToLastDate(const Date& d);
79 MakeCms& withFloatingLegDayCount(const DayCounter& dc);
80
81 MakeCms& withAtmSpread(bool flag = true);
82
83 MakeCms& withDiscountingTermStructure(
84 const Handle<YieldTermStructure>& discountingTermStructure);
85 MakeCms& withCmsCouponPricer(
86 const ext::shared_ptr<CmsCouponPricer>& couponPricer);
87
88 private:
89 Period swapTenor_;
90 ext::shared_ptr<SwapIndex> swapIndex_;
91 ext::shared_ptr<IborIndex> iborIndex_;
92 Spread iborSpread_;
93 bool useAtmSpread_;
94 Period forwardStart_;
95
96 Spread cmsSpread_;
97 Real cmsGearing_;
98 Rate cmsCap_, cmsFloor_;
99
100 Date effectiveDate_;
101 Calendar cmsCalendar_, floatCalendar_;
102
103 bool payCms_;
104 Real nominal_;
105 Period cmsTenor_, floatTenor_;
106 BusinessDayConvention cmsConvention_, cmsTerminationDateConvention_;
107 BusinessDayConvention floatConvention_, floatTerminationDateConvention_;
108 DateGeneration::Rule cmsRule_, floatRule_;
109 bool cmsEndOfMonth_, floatEndOfMonth_;
110 Date cmsFirstDate_, cmsNextToLastDate_;
111 Date floatFirstDate_, floatNextToLastDate_;
112 DayCounter cmsDayCount_, floatDayCount_;
113
114 ext::shared_ptr<PricingEngine> engine_;
115 ext::shared_ptr<CmsCouponPricer> couponPricer_;
116 };
117
118}
119
120#endif
121

source code of quantlib/ql/instruments/makecms.hpp