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) {
27 checkNativeFixingsAllowed();
28 addFixings(dBegin: &fixingDate, dEnd: (&fixingDate)+1,
29 vBegin: &fixing,
30 forceOverwrite);
31 }
32
33 void Index::addFixings(const TimeSeries<Real>& t,
34 bool forceOverwrite) {
35 checkNativeFixingsAllowed();
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(dBegin: dates.begin(), dEnd: dates.end(),
41 vBegin: values.begin(),
42 forceOverwrite);
43 }
44
45 void Index::clearFixings() {
46 checkNativeFixingsAllowed();
47 IndexManager::instance().clearHistory(name: name());
48 }
49
50 void Index::checkNativeFixingsAllowed() {
51 QL_REQUIRE(allowsNativeFixings(),
52 "native fixings not allowed for " << name()
53 << "; refer to underlying indices instead");
54 }
55
56}
57
58

source code of quantlib/ql/index.cpp

Morty Proxy This is a proxified and sanitized view of the page, visit original site.