21#include <ql/quotes/simplequote.hpp>
22#include <ql/termstructures/yield/flatforward.hpp>
28 const QuantLib::Handle<QuantLib::BlackVolTermStructure>& vol,
29 const QuantLib::ext::shared_ptr<QuantExt::CommodityAveragePriceOption>& apo,
30 const bool dontCalibrate)
32 Handle<Quote>(
QuantLib::ext::make_shared<SimpleQuote>(1.0)),
33 Handle<YieldTermStructure>(
QuantLib::ext::make_shared<
QuantLib::FlatForward>(
34 0, NullCalendar(), 0.0, Actual365Fixed())),
35 Handle<YieldTermStructure>(
QuantLib::ext::make_shared<
QuantLib::FlatForward>(
36 0, NullCalendar(), 0.0, Actual365Fixed())),
38 apo_(apo), dontCalibrate_(dontCalibrate) {}
45std::vector<QuantLib::ext::shared_ptr<GeneralizedBlackScholesProcess>>
53 std::vector<Real> times;
56 if (
apo_->underlyingFlow()->date() >
curves_.front()->referenceDate())
57 times.push_back(
curves_.front()->timeFromReference(
apo_->underlyingFlow()->date()));
63 std::vector<std::pair<Real, Real>> result;
66 auto vol =
processes_.front()->blackVolatility();
67 std::set<QuantLib::Date> expiries;
68 Real effectiveStrike =
apo_->effectiveStrike();
70 effectiveStrike -=
apo_->accrued(
curves_.front()->referenceDate());
76 for (
auto const& p :
apo_->underlyingFlow()->indices()) {
77 if (p.first >
curves_.front()->referenceDate()) {
78 if (
apo_->underlyingFlow()->useFuturePrice()) {
79 Date expiry = p.second->expiryDate();
80 if (expiries.find(expiry) == expiries.end()) {
81 result.push_back(std::make_pair(vol->timeFromReference(expiry), effectiveStrike));
82 expiries.insert(expiry);
85 if (expiries.find(p.first) == expiries.end()) {
86 result.push_back(std::make_pair(vol->timeFromReference(p.first), effectiveStrike));
87 expiries.insert(p.first);
const std::vector< QuantLib::ext::shared_ptr< GeneralizedBlackScholesProcess > > processes_
const std::vector< Handle< YieldTermStructure > > curves_
std::vector< QuantLib::ext::shared_ptr< GeneralizedBlackScholesProcess > > getCalibratedProcesses() const override
QuantLib::ext::shared_ptr< QuantExt::CommodityAveragePriceOption > apo_
std::vector< std::vector< std::pair< Real, Real > > > getVolTimesStrikes() const override
void setupDatesAndTimes() const override
std::vector< std::vector< Real > > getCurveTimes() const override
CommodityApoModelBuilder(const Handle< YieldTermStructure > &curve, const QuantLib::Handle< QuantLib::BlackVolTermStructure > &vol, const QuantLib::ext::shared_ptr< QuantExt::CommodityAveragePriceOption > &apo, const bool dontCalibrate)
model builder for commodityapos
Serializable Credit Default Swap.