QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
forwardstructure.cpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2000, 2001, 2002, 2003 RiskMap srl
5 Copyright (C) 2003, 2004 StatPro Italia srl
6 Copyright (C) 2009 Ferdinando Ametrano
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/termstructures/yield/forwardstructure.hpp>
23
24namespace QuantLib {
25
27 : YieldTermStructure(dc) {}
28
30 const Date& refDate,
31 const Calendar& cal,
32 const DayCounter& dc,
33 const std::vector<Handle<Quote> >& jumps,
34 const std::vector<Date>& jumpDates)
35 : YieldTermStructure(refDate, cal, dc, jumps, jumpDates) {}
36
38 Natural settlDays,
39 const Calendar& cal,
40 const DayCounter& dc,
41 const std::vector<Handle<Quote> >& jumps,
42 const std::vector<Date>& jumpDates)
43 : YieldTermStructure(settlDays, cal, dc, jumps, jumpDates) {}
44
46 if (t == 0.0)
47 return forwardImpl(0.0);
48 // implement smarter integration if plan to use the following code
49 Rate sum = 0.5*forwardImpl(0.0);
50 Size N = 1000;
51 Time dt = t/N;
52 for (Time i=dt; i<t; i+=dt)
53 sum += forwardImpl(i);
54 sum += 0.5*forwardImpl(t);
55 return Rate(sum*dt/t);
56 }
57
58}
calendar class
Definition: calendar.hpp:61
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
virtual Rate zeroYieldImpl(Time) const
ForwardRateStructure(const DayCounter &dayCounter=DayCounter())
virtual Rate forwardImpl(Time) const =0
instantaneous forward-rate calculation
Shared handle to an observable.
Definition: handle.hpp:41
Interest-rate term structure.
Real Time
continuous quantity with 1-year units
Definition: types.hpp:62
unsigned QL_INTEGER Natural
positive integer
Definition: types.hpp:43
Real Rate
interest rates
Definition: types.hpp:70
std::size_t Size
size of a container
Definition: types.hpp:58
Definition: any.hpp:35