Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
mccamfxoptionengine.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2019 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
20
21#include <ql/cashflows/simplecashflow.hpp>
22
23namespace QuantExt {
24
25using namespace QuantLib;
26
28 const Handle<CrossAssetModel>& model, const Currency& domesticCcy, const Currency& foreignCcy,
29 const Currency& npvCcy, const SequenceType calibrationPathGenerator, const SequenceType pricingPathGenerator,
30 const Size calibrationSamples, const Size pricingSamples, const Size calibrationSeed, const Size pricingSeed,
31 const Size polynomOrder, const LsmBasisSystem::PolynomialType polynomType,
32 const SobolBrownianGenerator::Ordering ordering, const SobolRsg::DirectionIntegers directionIntegers,
33 const std::vector<Handle<YieldTermStructure>>& discountCurves, const std::vector<Date>& simulationDates,
34 const std::vector<Size>& externalModelIndices, const bool minimalObsDate, const RegressorModel regressorModel,
35 const Real regressionVarianceCutoff)
36 : McMultiLegBaseEngine(model, calibrationPathGenerator, pricingPathGenerator, calibrationSamples, pricingSamples,
37 calibrationSeed, pricingSeed, polynomOrder, polynomType, ordering, directionIntegers,
38 discountCurves, simulationDates, externalModelIndices, minimalObsDate, regressorModel,
39 regressionVarianceCutoff),
40 domesticCcy_(domesticCcy), foreignCcy_(foreignCcy), npvCcy_(npvCcy) {
41 registerWith(model_);
42 for (auto const& h : discountCurves)
43 registerWith(h);
44}
45
47
48 auto payoff = QuantLib::ext::dynamic_pointer_cast<StrikedTypePayoff>(arguments_.payoff);
49 QL_REQUIRE(payoff, "McCamFxOptionEngine: non-striked payoff given");
50 QL_REQUIRE(arguments_.exercise->type() == Exercise::European, "McCamFxOptionEngine: not an European option");
51 QL_REQUIRE(!arguments_.exercise->dates().empty(), "McCamFxOptionEngine: exercise dates are empty");
52
53 Date payDate = arguments_.exercise->dates().front() + 1;
54
55 Real w = payoff->optionType() == Option::Call ? 1.0 : -1.0;
56 Leg domesticLeg{QuantLib::ext::make_shared<SimpleCashFlow>(-w * payoff->strike(), payDate)};
57 Leg foreignLeg{QuantLib::ext::make_shared<SimpleCashFlow>(w, payDate)};
58
59 leg_ = {domesticLeg, foreignLeg};
61 payer_ = {false, false};
62 exercise_ = arguments_.exercise;
63 optionSettlement_ = Settlement::Cash;
64
66
67 // convert base ccy result from McMultiLegbaseEngine to desired npv currency
68 Real fxSpot = 1.0;
69 Size npvCcyIndex = model_->ccyIndex(npvCcy_);
70 if (npvCcyIndex > 0)
71 fxSpot = model_->fxbs(npvCcyIndex - 1)->fxSpotToday()->value();
72 results_.value = resultValue_ / fxSpot;
73 results_.additionalResults["underlyingNpv"] = resultUnderlyingNpv_ / fxSpot;
74 results_.additionalResults["amcCalculator"] = amcCalculator();
75} // calculate
76
77} // namespace QuantExt
const Instrument::results * results_
Definition: cdsoption.cpp:81
McCamFxOptionEngine(const Handle< CrossAssetModel > &model, const Currency &domesticCcy, const Currency &foreignCcy, const Currency &npvCcy, const SequenceType calibrationPathGenerator, const SequenceType pricingPathGenerator, const Size calibrationSamples, const Size pricingSamples, const Size calibrationSeed, const Size pricingSeed, const Size polynomOrder, const LsmBasisSystem::PolynomialType polynomType, const SobolBrownianGenerator::Ordering ordering=SobolBrownianGenerator::Steps, const SobolRsg::DirectionIntegers directionIntegers=SobolRsg::JoeKuoD7, const std::vector< Handle< YieldTermStructure > > &discountCurves=std::vector< Handle< YieldTermStructure > >(), const std::vector< Date > &simulationDates=std::vector< Date >(), const std::vector< Size > &externalModelIndices=std::vector< Size >(), const bool minimalObsDate=true, const RegressorModel regressorModel=RegressorModel::Simple, const Real regressionVarianceCutoff=Null< Real >())
QuantLib::ext::shared_ptr< Exercise > exercise_
Handle< CrossAssetModel > model_
QuantLib::ext::shared_ptr< AmcCalculator > amcCalculator() const
MC CAM engine for FX Option instrument.
Swap::arguments * arguments_