QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
energycommodity.hpp
Go to the documentation of this file.
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/*! \file energycommodity.hpp
21 \brief Energy commodity
22*/
23
24#ifndef quantlib_energy_commodity_hpp
25#define quantlib_energy_commodity_hpp
26
32#include <ql/time/date.hpp>
33#include <ql/money.hpp>
34
35namespace QuantLib {
36
43 bool unrealized = false;
44
49 bool unrealized);
50 };
51
52 typedef std::map<Date, EnergyDailyPosition> EnergyDailyPositions;
53
54 #ifndef __DOXYGEN__
55 std::ostream& operator<<(std::ostream& out,
56 const EnergyDailyPositions& dailyPositions);
57 #endif
58
59
60
61 //! Energy commodity class
62 /*! \ingroup instruments */
63 class EnergyCommodity : public Commodity {
64 public:
65 class arguments;
66 class results;
67 class engine;
68
88
90 const ext::shared_ptr<SecondaryCosts>& secondaryCosts);
91
92 virtual Quantity quantity() const = 0;
93 const CommodityType& commodityType() const;
94
95 void setupArguments(PricingEngine::arguments*) const override;
96 void fetchResults(const PricingEngine::results*) const override;
97
98 protected:
99 static Real calculateFxConversionFactor(const Currency& fromCurrency,
100 const Currency& toCurrency,
101 const Date& evaluationDate);
104 const UnitOfMeasure& fromUnitOfMeasure,
105 const UnitOfMeasure& toUnitOfMeasure);
107 const CommodityUnitCost& unitCost,
108 const Date& evaluationDate) const;
110 Real totalQuantityValue,
111 const Date& evaluationDate) const;
112
114 };
115
116
118 public:
121 void validate() const override {}
122 };
123
125 public:
129 void reset() override { Instrument::results::reset(); }
130 };
131
133 : public GenericEngine<EnergyCommodity::arguments,
134 EnergyCommodity::results> {};
135
136}
137
138#endif
Commodity base class.
Definition: commodity.hpp:63
const ext::shared_ptr< SecondaryCosts > & secondaryCosts() const
Currency specification
Definition: currency.hpp:36
Concrete date class.
Definition: date.hpp:125
Energy commodity class.
static Real calculateUomConversionFactor(const CommodityType &commodityType, const UnitOfMeasure &fromUnitOfMeasure, const UnitOfMeasure &toUnitOfMeasure)
virtual Quantity quantity() const =0
void setupArguments(PricingEngine::arguments *) const override
Real calculateUnitCost(const CommodityType &commodityType, const CommodityUnitCost &unitCost, const Date &evaluationDate) const
void calculateSecondaryCostAmounts(const CommodityType &commodityType, Real totalQuantityValue, const Date &evaluationDate) const
void fetchResults(const PricingEngine::results *) const override
static Real calculateFxConversionFactor(const Currency &fromCurrency, const Currency &toCurrency, const Date &evaluationDate)
const CommodityType & commodityType() const
template base class for option pricing engines
Amount of a commodity.
Definition: quantity.hpp:34
Unit of measure specification
Commodity base class.
commodity type
Commodity unit cost.
date- and time-related classes, typedefs and enumerations
QL_REAL Real
real number
Definition: types.hpp:50
cash amount in a given currency
Definition: any.hpp:35
std::ostream & operator<<(std::ostream &out, GFunctionFactory::YieldCurveModel type)
std::map< Date, EnergyDailyPosition > EnergyDailyPositions
Amount of a commodity.
Unit of measure.