QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
cmsratebond.cpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2007 Ferdinando Ametrano
5 Copyright (C) 2006, 2007 Chiara Fornarola
6 Copyright (C) 2007 StatPro Italia srl
7
8 This file is part of QuantLib, a free-software/open-source library
9 for financial quantitative analysts and developers - http://quantlib.org/
10
11 QuantLib is free software: you can redistribute it and/or modify it
12 under the terms of the QuantLib license. You should have received a
13 copy of the license along with this program; if not, please email
14 <quantlib-dev@lists.sf.net>. The license is also available online at
15 <http://quantlib.org/license.shtml>.
16
17 This program is distributed in the hope that it will be useful, but WITHOUT
18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19 FOR A PARTICULAR PURPOSE. See the license for more details.
20*/
21
22#include <ql/instruments/bonds/cmsratebond.hpp>
23#include <ql/cashflows/cmscoupon.hpp>
24#include <ql/cashflows/simplecashflow.hpp>
25#include <ql/indexes/swapindex.hpp>
26#include <ql/time/schedule.hpp>
27
28namespace QuantLib {
29
31 Natural settlementDays,
32 Real faceAmount,
33 const Schedule& schedule,
34 const ext::shared_ptr<SwapIndex>& index,
35 const DayCounter& paymentDayCounter,
36 BusinessDayConvention paymentConvention,
37 Natural fixingDays,
38 const std::vector<Real>& gearings,
39 const std::vector<Spread>& spreads,
40 const std::vector<Rate>& caps,
41 const std::vector<Rate>& floors,
42 bool inArrears,
43 Real redemption,
44 const Date& issueDate)
45 : Bond(settlementDays, schedule.calendar(), issueDate) {
46
47 maturityDate_ = schedule.endDate();
48
49 cashflows_ = CmsLeg(schedule, index)
50 .withNotionals(faceAmount)
51 .withPaymentDayCounter(paymentDayCounter)
52 .withPaymentAdjustment(paymentConvention)
53 .withFixingDays(fixingDays)
54 .withGearings(gearings)
55 .withSpreads(spreads)
56 .withCaps(caps)
57 .withFloors(floors)
58 .inArrears(inArrears);
59
60 addRedemptionsToCashflows(std::vector<Real>(1, redemption));
61
62 QL_ENSURE(!cashflows().empty(), "bond with no cashflows!");
63 QL_ENSURE(redemptions_.size() == 1, "multiple redemptions created");
64
65 registerWith(index);
66 }
67
68}
Base bond class.
Definition: bond.hpp:59
Leg redemptions_
Definition: bond.hpp:289
void addRedemptionsToCashflows(const std::vector< Real > &redemptions=std::vector< Real >())
Definition: bond.cpp:304
const Leg & cashflows() const
Definition: bond.hpp:330
Leg cashflows_
Definition: bond.hpp:288
const ext::shared_ptr< CashFlow > & redemption() const
Definition: bond.cpp:140
Date maturityDate_
Definition: bond.hpp:291
helper class building a sequence of capped/floored cms-rate coupons
Definition: cmscoupon.hpp:70
CmsLeg & withFloors(Rate floor)
Definition: cmscoupon.cpp:122
CmsLeg & withCaps(Rate cap)
Definition: cmscoupon.cpp:112
CmsLeg & withGearings(Real gearing)
Definition: cmscoupon.cpp:92
CmsLeg & withSpreads(Spread spread)
Definition: cmscoupon.cpp:102
CmsLeg & withPaymentDayCounter(const DayCounter &)
Definition: cmscoupon.cpp:72
CmsLeg & inArrears(bool flag=true)
Definition: cmscoupon.cpp:132
CmsLeg & withNotionals(Real notional)
Definition: cmscoupon.cpp:62
CmsLeg & withPaymentAdjustment(BusinessDayConvention)
Definition: cmscoupon.cpp:77
CmsLeg & withFixingDays(Natural fixingDays)
Definition: cmscoupon.cpp:82
CmsRateBond(Natural settlementDays, Real faceAmount, const Schedule &schedule, const ext::shared_ptr< SwapIndex > &index, const DayCounter &paymentDayCounter, BusinessDayConvention paymentConvention=Following, Natural fixingDays=Null< Natural >(), const std::vector< Real > &gearings={ 1.0 }, const std::vector< Spread > &spreads={ 0.0 }, const std::vector< Rate > &caps={}, const std::vector< Rate > &floors={}, bool inArrears=false, Real redemption=100.0, const Date &issueDate=Date())
Definition: cmsratebond.cpp:30
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
Definition: observable.hpp:228
Payment schedule.
Definition: schedule.hpp:40
const Date & endDate() const
Definition: schedule.hpp:184
BusinessDayConvention
Business Day conventions.
QL_REAL Real
real number
Definition: types.hpp:50
unsigned QL_INTEGER Natural
positive integer
Definition: types.hpp:43
Definition: any.hpp:35