• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lballabio / QuantLib / 11352161829

15 Oct 2024 06:27PM UTC coverage: 72.784% (-0.002%) from 72.786%
11352161829

push

github

web-flow
Deprecate most of the `IndexManager` public interface. (#2096)

13 of 17 new or added lines in 9 files covered. (76.47%)

4 existing lines in 1 file now uncovered.

55141 of 75760 relevant lines covered (72.78%)

8704928.65 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/ql/experimental/commodities/commodityindex.cpp
1
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2

3
/*
4
 Copyright (C) 2008 J. Erik Radmall
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/experimental/commodities/commodityindex.hpp>
21
#include <ql/experimental/commodities/commoditypricinghelpers.hpp>
22
#include <utility>
23

24
namespace QuantLib {
25

26
    CommodityIndex::CommodityIndex(const std::string& indexName,
×
27
                                   CommodityType commodityType,
28
                                   Currency currency,
29
                                   UnitOfMeasure unitOfMeasure,
30
                                   Calendar calendar,
31
                                   Real lotQuantity,
32
                                   ext::shared_ptr<CommodityCurve> forwardCurve,
33
                                   ext::shared_ptr<ExchangeContracts> exchangeContracts,
34
                                   int nearbyOffset)
×
35
    : name_(indexName), commodityType_(std::move(commodityType)),
×
36
      unitOfMeasure_(std::move(unitOfMeasure)), currency_(std::move(currency)),
×
37
      calendar_(std::move(calendar)), lotQuantity_(lotQuantity),
×
38
      forwardCurve_(std::move(forwardCurve)), exchangeContracts_(std::move(exchangeContracts)),
×
39
      nearbyOffset_(nearbyOffset) {
×
40
        registerWith(Settings::instance().evaluationDate());
×
NEW
41
        registerWith(notifier());
×
42

43
        if (forwardCurve_ != nullptr)
×
44
            // registerWith(forwardCurve_);
45
            forwardCurveUomConversionFactor_ =
×
46
                CommodityPricingHelper::calculateUomConversionFactor(
×
47
                                                commodityType_,
48
                                                forwardCurve_->unitOfMeasure_,
×
49
                                                unitOfMeasure_);
50
    }
×
51

52
    std::ostream& operator<<(std::ostream& out, const CommodityIndex& index) {
×
53
        out << "[" << index.name_ << "] ("
54
            << index.currency_.code() << "/"
×
55
            << index.unitOfMeasure_.code() << ")";
×
56
        if (index.forwardCurve_ != nullptr)
×
57
            out << "; forward (" << (*index.forwardCurve_) << ")";
×
58
        return out;
×
59
    }
60

61
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc