30 ext::shared_ptr<CommodityIndex> index,
32 const ext::shared_ptr<SecondaryCosts>& secondaryCosts)
34 quantity_(
std::move(quantity)), tradePrice_(
std::move(tradePrice)), index_(
std::move(index)) {
54 Real quantityUomConversionFactor =
59 Real indexUomConversionFactor =
63 Real tradePriceUomConversionFactor =
68 Real tradePriceFxConversionFactor =
70 baseCurrency, evaluationDate);
71 Real indexPriceFxConversionFactor =
78 if (lastQuoteDate >= evaluationDate - 1) {
79 quoteValue =
index_->price(evaluationDate);
81 quoteValue =
index_->forwardPrice(evaluationDate);
82 std::ostringstream message;
83 message <<
"curve [" <<
index_->name()
84 <<
"] has last quote date of "
86 <<
" using forward price from ["
87 <<
index_->forwardCurve()->name() <<
"]";
92 "missing quote for [" <<
index_->name() <<
"]");
94 Real tradePriceValue =
96 * tradePriceFxConversionFactor;
97 Real quotePriceValue = quoteValue * indexUomConversionFactor
98 * indexPriceFxConversionFactor;
102 Real delta = (((quotePriceValue - tradePriceValue) * quantityAmount)
110 Real amount = i->second.value();
void addPricingError(PricingError::Level errorLevel, const std::string &error, const std::string &detail="") const
SecondaryCostAmounts secondaryCostAmounts_
UnitOfMeasure & unitOfMeasure()
const Money & amount() const
const UnitOfMeasure & unitOfMeasure() const
static Real calculateUomConversionFactor(const CommodityType &commodityType, const UnitOfMeasure &fromUnitOfMeasure, const UnitOfMeasure &toUnitOfMeasure)
void calculateSecondaryCostAmounts(const CommodityType &commodityType, Real totalQuantityValue, const Date &evaluationDate) const
static Real calculateFxConversionFactor(const Currency &fromCurrency, const Currency &toCurrency, const Date &evaluationDate)
void performCalculations() const override
bool isExpired() const override
returns whether the instrument might have value greater than zero.
CommodityUnitCost tradePrice_
EnergyFuture(Integer buySell, Quantity quantity, CommodityUnitCost tradePrice, ext::shared_ptr< CommodityIndex > index, const CommodityType &commodityType, const ext::shared_ptr< SecondaryCosts > &secondaryCosts)
ext::shared_ptr< CommodityIndex > index_
std::map< std::string, ext::any > additionalResults_
const Currency & currency() const
template class providing a null value for a given type.
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
const CommodityType & commodityType() const
const UnitOfMeasure & unitOfMeasure() const
DateProxy & evaluationDate()
the date at which pricing is to be performed.
static Settings & instance()
access to the unique instance
Unit of measure specification
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
detail::iso_date_holder iso_date(const Date &d)
output dates in ISO format (yyyy-mm-dd)
QL_INTEGER Integer
integer number
global repository for run-time library settings