Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
mccamfxforwardengine.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2023 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 Leg foreignLeg{QuantLib::ext::make_shared<SimpleCashFlow>(arguments_.nominal1, arguments_.payDate)};
49 Leg domesticLeg{QuantLib::ext::make_shared<SimpleCashFlow>(arguments_.nominal2, arguments_.payDate)};
50
51 leg_ = {foreignLeg, domesticLeg};
53 payer_ = {false, true};
54 exercise_ = nullptr;
55 includeSettlementDateFlows_ = arguments_.includeSettlementDateFlows;
56
58
59 // convert base ccy result from McMultiLegbaseEngine to desired npv currency
60 Real fxSpot = 1.0;
61 Size npvCcyIndex = model_->ccyIndex(npvCcy_);
62 if (npvCcyIndex > 0)
63 fxSpot = model_->fxbs(npvCcyIndex - 1)->fxSpotToday()->value();
64 results_.value = resultValue_ / fxSpot;
65 results_.additionalResults["underlyingNpv"] = resultUnderlyingNpv_ / fxSpot;
66 results_.additionalResults["amcCalculator"] = amcCalculator();
67
68} // calculate
69
70} // namespace QuantExt
const Instrument::results * results_
Definition: cdsoption.cpp:81
McCamFxForwardEngine(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 Forward instrument.
Swap::arguments * arguments_