Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
commodityschwartzfutureoptionengine.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2022 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
21#include <ql/pricingengines/blackcalculator.hpp>
22
23namespace QuantExt {
24
26 const QuantLib::ext::shared_ptr<CommoditySchwartzModel>& model) : model_(model) {}
27
29
30 QL_REQUIRE(arguments_.exercise->type() == Exercise::European, "only European options are allowed");
31
32 QuantLib::ext::shared_ptr<StrikedTypePayoff> payoff = QuantLib::ext::dynamic_pointer_cast<StrikedTypePayoff>(arguments_.payoff);
33 QL_REQUIRE(payoff != NULL, "only striked payoff is allowed");
34
35 QuantLib::ext::shared_ptr<CommoditySchwartzParametrization> param = model_->parametrization();
36
37 Date expiry = arguments_.exercise->lastDate();
38 Time T = param->priceCurve()->timeFromReference(expiry);
39 if (T <= 0.0) {
40 // option is expired, we do not value any possibly non settled
41 // flows, i.e. set the npv to zero in this case
42 results_.value = 0.0;
43 return;
44 }
45 Real forward = param->priceCurve()->price(expiry);
46 // Var[ln F(T,T)] = Var[X(T)] = V(0,T) - V(T,T)
47 Real variance = param->VtT(0,T) - param->VtT(T,T);
48 BlackCalculator black(payoff, forward, std::sqrt(variance), 1.0);
49 results_.value = black.value();
50
51} // calculate()
52
53} // namespace QuantExt
const Instrument::results * results_
Definition: cdsoption.cpp:81
CommoditySchwartzFutureOptionEngine(const QuantLib::ext::shared_ptr< CommoditySchwartzModel > &model)
QuantLib::ext::shared_ptr< CommoditySchwartzModel > model_
commodity future options priced in the Schwartz model
analytics for the cross asset model
RandomVariable variance(const RandomVariable &r)
RandomVariable black(const RandomVariable &omega, const RandomVariable &t, const RandomVariable &strike, const RandomVariable &forward, const RandomVariable &impliedVol)
Swap::arguments * arguments_