Skip to content

Commit

Permalink
Added zero-coupon and floating-rate bonds
Browse files Browse the repository at this point in the history
  • Loading branch information
lballabio committed Feb 10, 2005
1 parent d3dc311 commit 9fdfce3
Show file tree
Hide file tree
Showing 9 changed files with 413 additions and 7 deletions.
7 changes: 7 additions & 0 deletions News.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,11 @@ Changes since release 0.3.8:
messages, as in:
QL_FAIL("forward at date " << d << " is " << io::rate(f));

- Improved Bond class
- yield-related calculation can be performed with either compounded or
continuous compounding
- added theoretical price based on discount curve
- fixed-rate coupon bonds can define different rates for each coupon
- added zero-coupon and floating-rate bonds


8 changes: 6 additions & 2 deletions ql/Instruments/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ include_HEADERS = \
dividendvanillaoption.hpp \
europeanoption.hpp \
fixedcouponbond.hpp \
floatingratebond.hpp \
forwardvanillaoption.hpp \
multiassetoption.hpp \
oneassetoption.hpp \
Expand All @@ -25,7 +26,8 @@ include_HEADERS = \
stock.hpp \
swap.hpp \
swaption.hpp \
vanillaoption.hpp
vanillaoption.hpp \
zerocouponbond.hpp

EXTRA_DIST=makefile.mak

Expand All @@ -39,6 +41,7 @@ libInstruments_la_SOURCES = \
dividendvanillaoption.cpp \
europeanoption.cpp \
fixedcouponbond.cpp \
floatingratebond.cpp \
forwardvanillaoption.cpp \
multiassetoption.cpp \
oneassetoption.cpp \
Expand All @@ -49,6 +52,7 @@ libInstruments_la_SOURCES = \
stock.cpp \
swap.cpp \
swaption.cpp \
vanillaoption.cpp
vanillaoption.cpp \
zerocouponbond.cpp

noinst_LTLIBRARIES = libInstruments.la
2 changes: 2 additions & 0 deletions ql/Instruments/all.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <ql/Instruments/dividendvanillaoption.hpp>
#include <ql/Instruments/europeanoption.hpp>
#include <ql/Instruments/fixedcouponbond.hpp>
#include <ql/Instruments/floatingratebond.hpp>
#include <ql/Instruments/forwardvanillaoption.hpp>
#include <ql/Instruments/multiassetoption.hpp>
#include <ql/Instruments/oneassetoption.hpp>
Expand All @@ -40,6 +41,7 @@
#include <ql/Instruments/swap.hpp>
#include <ql/Instruments/swaption.hpp>
#include <ql/Instruments/vanillaoption.hpp>
#include <ql/Instruments/zerocouponbond.hpp>


#endif
5 changes: 3 additions & 2 deletions ql/Instruments/fixedcouponbond.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
Copyright (C) 2004 Jeff Yu
Copyright (C) 2004 M-Dimension Consulting Inc.
Copyright (C) 2005 StatPro Italia srl
This file is part of QuantLib, a free-software/open-source library
for financial quantitative analysts and developers - http://quantlib.org/
Expand Down Expand Up @@ -67,7 +68,7 @@ namespace QuantLib {
BusinessDayConvention convention,
Real redemption,
const Handle<YieldTermStructure>& discountCurve,
const Date& stub)
const Date& stub, bool fromEnd)
: Bond(dayCounter, calendar, convention, settlementDays, discountCurve) {

issueDate_ = issueDate;
Expand All @@ -80,7 +81,7 @@ namespace QuantLib {

Schedule schedule(calendar, datedDate, maturityDate,
couponFrequency, convention,
stub, true);
stub, fromEnd);

cashFlows_ = FixedRateCouponVector(schedule, convention,
std::vector<Real>(1, 100.0),
Expand Down
11 changes: 8 additions & 3 deletions ql/Instruments/fixedcouponbond.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
Copyright (C) 2004 Jeff Yu
Copyright (C) 2004 M-Dimension Consulting Inc.
Copyright (C) 2005 StatPro Italia srl
This file is part of QuantLib, a free-software/open-source library
for financial quantitative analysts and developers - http://quantlib.org/
Expand All @@ -23,12 +24,15 @@
#define quantlib_fixed_coupon_bond_hpp

#include <ql/Instruments/bond.hpp>
#include <ql/schedule.hpp>

namespace QuantLib {

//! fixed-coupon bond
/*! \ingroup instruments */
/*! \ingroup instruments
\test calculations are tested by checking results against
cached values.
*/
class FixedCouponBond : public Bond {
public:
#ifndef QL_DISABLE_DEPRECATED
Expand Down Expand Up @@ -58,7 +62,8 @@ namespace QuantLib {
Real redemption = 100.0,
const Handle<YieldTermStructure>& discountCurve
= Handle<YieldTermStructure>(),
const Date& stub = Date());
const Date& stub = Date(),
bool fromEnd = true);
};

}
Expand Down
44 changes: 44 additions & 0 deletions ql/Instruments/zerocouponbond.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
Copyright (C) 2005 StatPro Italia srl
This file is part of QuantLib, a free-software/open-source library
for financial quantitative analysts and developers - http://quantlib.org/
QuantLib is free software: you can redistribute it and/or modify it under the
terms of the QuantLib license. You should have received a copy of the
license along with this program; if not, please email quantlib-dev@lists.sf.net
The license is also available online at http://quantlib.org/html/license.html
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the license for more details.
*/

#include <ql/Instruments/zerocouponbond.hpp>
#include <ql/CashFlows/simplecashflow.hpp>

namespace QuantLib {

ZeroCouponBond::ZeroCouponBond(
const Date& issueDate,
const Date& maturityDate,
Integer settlementDays,
const DayCounter& dayCounter,
const Calendar& calendar,
BusinessDayConvention convention,
Real redemption,
const Handle<YieldTermStructure>& discountCurve)
: Bond(dayCounter, calendar, convention, settlementDays, discountCurve) {

issueDate_ = datedDate_ = issueDate;
maturityDate_ = maturityDate;
frequency_ = Once;

redemption_ = boost::shared_ptr<CashFlow>(
new SimpleCashFlow(redemption,maturityDate));

cashFlows_ = std::vector<boost::shared_ptr<CashFlow> >();
}

};

50 changes: 50 additions & 0 deletions ql/Instruments/zerocouponbond.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
Copyright (C) 2005 StatPro Italia srl
This file is part of QuantLib, a free-software/open-source library
for financial quantitative analysts and developers - http://quantlib.org/
QuantLib is free software: you can redistribute it and/or modify it under the
terms of the QuantLib license. You should have received a copy of the
license along with this program; if not, please email quantlib-dev@lists.sf.net
The license is also available online at http://quantlib.org/html/license.html
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the license for more details.
*/

/*! \file zerocouponbond.hpp
\brief zero-coupon bond
*/

#ifndef quantlib_zero_coupon_bond_hpp
#define quantlib_zero_coupon_bond_hpp

#include <ql/Instruments/bond.hpp>

namespace QuantLib {

//! zero-coupon bond
/*! \ingroup instruments
\test calculations are tested by checking results against
cached values.
*/
class ZeroCouponBond : public Bond {
public:
ZeroCouponBond(const Date& issueDate,
const Date& maturityDate,
Integer settlementDays,
const DayCounter& dayCounter,
const Calendar& calendar,
BusinessDayConvention convention = Following,
Real redemption = 100.0,
const Handle<YieldTermStructure>& discountCurve
= Handle<YieldTermStructure>());
};

}


#endif
Loading

0 comments on commit 9fdfce3

Please sign in to comment.