QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
index.cpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2006, 2007 StatPro Italia srl
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#include <ql/index.hpp>
21
22namespace QuantLib {
23
24 void Index::addFixing(const Date& fixingDate,
25 Real fixing,
26 bool forceOverwrite) {
28 addFixings(&fixingDate, (&fixingDate)+1,
29 &fixing,
30 forceOverwrite);
31 }
32
34 bool forceOverwrite) {
36 // is there a way of iterating over dates and values
37 // without having to make a copy?
38 std::vector<Date> dates = t.dates();
39 std::vector<Real> values = t.values();
40 addFixings(dates.begin(), dates.end(),
41 values.begin(),
42 forceOverwrite);
43 }
44
48 }
49
51 QL_REQUIRE(allowsNativeFixings(),
52 "native fixings not allowed for " << name()
53 << "; refer to underlying indices instead");
54 }
55
56}
57
Concrete date class.
Definition: date.hpp:125
virtual Real fixing(const Date &fixingDate, bool forecastTodaysFixing=false) const =0
returns the fixing at the given date
void clearFixings()
clears all stored historical fixings
Definition: index.cpp:45
virtual bool allowsNativeFixings()
check if index allows for native fixings.
Definition: index.hpp:72
virtual void addFixing(const Date &fixingDate, Real fixing, bool forceOverwrite=false)
stores the historical fixing at the given date
Definition: index.cpp:24
void addFixings(const TimeSeries< Real > &t, bool forceOverwrite=false)
stores historical fixings from a TimeSeries
Definition: index.cpp:33
virtual std::string name() const =0
Returns the name of the index.
void checkNativeFixingsAllowed()
check if index allows for native fixings
Definition: index.cpp:50
void clearHistory(const std::string &name)
clears the historical fixings of the index
static IndexManager & instance()
access to the unique instance
Definition: singleton.hpp:104
Container for historical data.
Definition: timeseries.hpp:51
QL_REAL Real
real number
Definition: types.hpp:50
Definition: any.hpp:35