19#include <ql/exercise.hpp>
20#include <ql/shared_ptr.hpp>
28 const QuantLib::ext::shared_ptr<CommodityCashFlow>& shortAssetFlow,
29 const ext::shared_ptr<Exercise>& exercise,
const Real quantity,
30 const Real strikePrice, QuantLib::Option::Type type,
31 const QuantLib::Date& paymentDate,
32 const QuantLib::ext::shared_ptr<FxIndex>& longAssetFxIndex,
33 const QuantLib::ext::shared_ptr<FxIndex>& shortAssetFxIndex,
34 Settlement::Type delivery, Settlement::Method settlementMethod)
35 : Option(ext::shared_ptr<
Payoff>(), exercise), longAssetFlow_(longAssetFlow), shortAssetFlow_(shortAssetFlow),
36 quantity_(quantity), strikePrice_(strikePrice), type_(type), paymentDate_(paymentDate),
37 longAssetFxIndex_(longAssetFxIndex), shortAssetFxIndex_(shortAssetFxIndex), settlementType_(delivery),
38 settlementMethod_(settlementMethod) {
41 QL_REQUIRE(ext::dynamic_pointer_cast<CommodityIndexedCashFlow>(
longAssetFlow_) ||
42 QuantLib::ext::dynamic_pointer_cast<CommodityIndexedAverageCashFlow>(
longAssetFlow_),
43 "Expect commodity floating cashflows");
44 QL_REQUIRE(ext::dynamic_pointer_cast<CommodityIndexedCashFlow>(
shortAssetFlow_) ||
45 QuantLib::ext::dynamic_pointer_cast<CommodityIndexedAverageCashFlow>(
shortAssetFlow_),
46 "Expect commodity floating cashflows");
47 if (
auto avgFlow = QuantLib::ext::dynamic_pointer_cast<CommodityIndexedAverageCashFlow>(
longAssetFlow_)) {
48 QL_REQUIRE(exercise_->lastDate() >= avgFlow->indices().rbegin()->first,
49 "exercise Date hast to be after last observation date");
51 if (
auto avgFlow = QuantLib::ext::dynamic_pointer_cast<CommodityIndexedAverageCashFlow>(
shortAssetFlow_)) {
52 QL_REQUIRE(exercise_->lastDate() >= avgFlow->indices().rbegin()->first,
53 "exercise Date hast to be after last observation date");
72 Option::setupArguments(args);
76 QL_REQUIRE(
arguments != 0,
"wrong argument type");
77 QL_REQUIRE(
longAssetFlow_->gearing() > 0.0,
"The gearing on an APO must be positive");
96 : quantity(0.0), strikePrice(0.0), effectiveStrike(0.0), type(Option::Call), paymentDate(Date()),
97 longAssetFxIndex(nullptr), shortAssetFxIndex(nullptr), settlementType(Settlement::Physical),
98 settlementMethod(Settlement::PhysicalOTC) {}
101 QL_REQUIRE(longAssetFlow,
"underlying not set");
102 QL_REQUIRE(shortAssetFlow,
"underlying not set");
103 QL_REQUIRE(exercise,
"exercise not set");
104 QuantLib::Settlement::checkTypeAndMethodConsistency(settlementType, settlementMethod);
Arguments for commodity spread option calculation
Date longAssetLastPricingDate
QuantLib::ext::shared_ptr< CommodityCashFlow > longAssetFlow
QuantLib::ext::shared_ptr< FxIndex > longAssetFxIndex
QuantLib::ext::shared_ptr< CommodityCashFlow > shortAssetFlow
Settlement::Method settlementMethod
QuantLib::ext::shared_ptr< FxIndex > shortAssetFxIndex
Settlement::Type settlementType
void validate() const override
Date shortAssetLastPricingDate
QuantLib::Settlement::Type settlementType_
void setupArguments(PricingEngine::arguments *) const override
bool isExpired() const override
const QuantLib::ext::shared_ptr< CommodityCashFlow > & underlyingShortAssetFlow() const
const QuantLib::ext::shared_ptr< FxIndex > & shortAssetFxIndex() const
const QuantLib::ext::shared_ptr< FxIndex > & longAssetFxIndex() const
QuantLib::Settlement::Method settlementMethod_
QuantLib::ext::shared_ptr< CommodityCashFlow > longAssetFlow_
CommoditySpreadOption(const QuantLib::ext::shared_ptr< CommodityCashFlow > &longAssetCashflow, const QuantLib::ext::shared_ptr< CommodityCashFlow > &shortAssetCashflow, const ext::shared_ptr< Exercise > &exercise, const Real quantity, const Real strikePrice, Option::Type type, const QuantLib::Date &paymentDate=Date(), const QuantLib::ext::shared_ptr< FxIndex > &longAssetFxIndex=nullptr, const QuantLib::ext::shared_ptr< FxIndex > &shortAssetFxIndex=nullptr, Settlement::Type delivery=Settlement::Physical, Settlement::Method settlementMethod=Settlement::PhysicalOTC)
const QuantLib::ext::shared_ptr< CommodityCashFlow > & underlyingLongAssetFlow() const
QuantLib::ext::shared_ptr< CommodityCashFlow > shortAssetFlow_
QuantLib::ext::shared_ptr< FxIndex > longAssetFxIndex_
QuantLib::ext::shared_ptr< FxIndex > shortAssetFxIndex_
Real effectiveStrike() const
Cash flow dependent on the average commodity spot price or future's settlement price over a period....
Cash flow dependent on a single commodity spot price or future's settlement price.