19#include <ql/exercise.hpp>
20#include <ql/shared_ptr.hpp>
26 const ext::shared_ptr<Exercise>& exercise,
const Real quantity,
27 const Real strikePrice, QuantLib::Option::Type type,
28 QuantLib::Settlement::Type delivery,
29 QuantLib::Settlement::Method settlementMethod,
30 const Real barrierLevel, Barrier::Type barrierType,
31 Exercise::Type barrierStyle,
32 const QuantLib::ext::shared_ptr<FxIndex>& fxIndex)
33 : Option(ext::shared_ptr<
Payoff>(), exercise), flow_(flow), quantity_(quantity), strikePrice_(strikePrice),
34 type_(type), settlementType_(delivery), settlementMethod_(settlementMethod), fxIndex_(fxIndex),
35 barrierLevel_(barrierLevel), barrierType_(barrierType), barrierStyle_(barrierStyle) {
36 flow_->alwaysForwardNotifications();
52 if (refDate >=
flow_->indices().begin()->first) {
53 for (
const auto& kv :
flow_->indices()) {
55 if (refDate < kv.first) {
60 tmp += fxRate*kv.second->fixing(kv.first);
63 auto n =
flow_->indices().size();
64 QL_REQUIRE(n > 0,
"APO coupon accrued calculation has a degenerate coupon.");
72 Option::setupArguments(args);
76 QL_REQUIRE(
arguments != 0,
"wrong argument type");
77 QL_REQUIRE(
flow_->gearing() > 0.0,
"The gearing on an APO must be positive");
79 Date today = Settings::instance().evaluationDate();
97 : quantity(0.0), strikePrice(0.0), effectiveStrike(0.0), type(Option::Call), fxIndex(nullptr),
98 settlementType(Settlement::Physical), settlementMethod(Settlement::PhysicalOTC), barrierLevel(Null<Real>()),
99 barrierType(Barrier::DownIn), barrierStyle(Exercise::American) {}
102 QL_REQUIRE(flow,
"underlying not set");
103 QL_REQUIRE(exercise,
"exercise not set");
Arguments for commodity APO calculation
QuantLib::ext::shared_ptr< FxIndex > fxIndex
Exercise::Type barrierStyle
QuantLib::ext::shared_ptr< CommodityIndexedAverageCashFlow > flow
Settlement::Method settlementMethod
Settlement::Type settlementType
void validate() const override
Barrier::Type barrierType
Barrier::Type barrierType_
Real accrued(const Date &refDate) const
QuantLib::Settlement::Type settlementType_
QuantLib::ext::shared_ptr< FxIndex > fxIndex_
void setupArguments(PricingEngine::arguments *) const override
Settlement::Type settlementType() const
bool isExpired() const override
QuantLib::ext::shared_ptr< CommodityIndexedAverageCashFlow > flow_
Exercise::Type barrierStyle_
QuantLib::Settlement::Method settlementMethod_
CommodityAveragePriceOption(const QuantLib::ext::shared_ptr< CommodityIndexedAverageCashFlow > &flow, const ext::shared_ptr< Exercise > &exercise, const Real quantity, const Real strikePrice, Option::Type type, Settlement::Type delivery=Settlement::Physical, Settlement::Method settlementMethod=Settlement::PhysicalOTC, const Real barrierLevel=Null< Real >(), Barrier::Type barrierType=Barrier::Type::DownIn, Exercise::Type barrierStyle=Exercise::American, const QuantLib::ext::shared_ptr< FxIndex > &fxIndex=nullptr)
Settlement::Method settlementMethod() const
Real effectiveStrike() const