31 const std::vector<Date>& dates,
32 std::vector<Real> prices,
35 commodityType_(
std::move(commodityType)), unitOfMeasure_(
std::move(unitOfMeasure)),
36 currency_(
std::move(currency)), dates_(dates), data_(
std::move(prices)),
37 interpolator_(
ForwardFlat()), basisOfCurveUomConversionFactor_(1) {
46 "invalid date (" <<
dates_[i] <<
", vs "
64 commodityType_(
std::move(commodityType)), unitOfMeasure_(
std::move(unitOfMeasure)),
66 basisOfCurveUomConversionFactor_(1) {}
73 for (std::map<Date, Real>::const_iterator i =
prices.begin(); i !=
prices.end(); ++i) {
74 dates_.push_back(i->first);
75 data_.push_back(i->second);
90 const ext::shared_ptr<CommodityCurve>& basisOfCurve) {
Commodity term structure.
const ext::shared_ptr< CommodityCurve > & basisOfCurve() const
void setBasisOfCurve(const ext::shared_ptr< CommodityCurve > &basisOfCurve)
UnitOfMeasure unitOfMeasure_
Real basisOfCurveUomConversionFactor_
const std::vector< Real > & prices() const
std::vector< Date > dates_
CommodityCurve(std::string name, CommodityType commodityType, Currency currency, UnitOfMeasure unitOfMeasure, const Calendar &calendar, const std::vector< Date > &dates, std::vector< Real > prices, const DayCounter &dayCounter=Actual365Fixed())
std::vector< Time > times_
Interpolation interpolation_
CommodityType commodityType_
ForwardFlat interpolator_
void setPrices(std::map< Date, Real > &prices)
std::vector< Real > data_
ext::shared_ptr< CommodityCurve > basisOfCurve_
static Real calculateUomConversionFactor(const CommodityType &commodityType, const UnitOfMeasure &fromUnitOfMeasure, const UnitOfMeasure &toUnitOfMeasure)
const std::string & code() const
ISO 4217 three-letter code, e.g, "USD".
Time yearFraction(const Date &, const Date &, const Date &refPeriodStart=Date(), const Date &refPeriodEnd=Date()) const
Returns the period between two dates as a fraction of year.
Forward-flat interpolation factory and traits.
Interpolation interpolate(const I1 &xBegin, const I1 &xEnd, const I2 &yBegin) const
Basic term-structure functionality.
virtual DayCounter dayCounter() const
the day counter used for date/time conversion
Unit of measure specification
const std::string & code() const
code, e.g, "BBL", "MT"
Commodity pricing helpers.
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
std::size_t Size
size of a container
std::ostream & operator<<(std::ostream &out, GFunctionFactory::YieldCurveModel type)