Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
mccamcurrencyswapengine.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
21namespace QuantExt {
22
23using namespace QuantLib;
24
26 const Handle<CrossAssetModel>& model, const std::vector<Currency>& currencies, const Currency& npvCcy,
27 const SequenceType calibrationPathGenerator, const SequenceType pricingPathGenerator, const Size calibrationSamples,
28 const Size pricingSamples, const Size calibrationSeed, const Size pricingSeed, const Size polynomOrder,
29 const LsmBasisSystem::PolynomialType polynomType, const SobolBrownianGenerator::Ordering ordering,
30 const SobolRsg::DirectionIntegers directionIntegers, const std::vector<Handle<YieldTermStructure>>& discountCurves,
31 const std::vector<Date>& simulationDates, const std::vector<Size>& externalModelIndices, const bool minimalObsDate,
32 const RegressorModel regressorModel, const Real regressionVarianceCutoff)
33 : McMultiLegBaseEngine(model, calibrationPathGenerator, pricingPathGenerator, calibrationSamples, pricingSamples,
34 calibrationSeed, pricingSeed, polynomOrder, polynomType, ordering, directionIntegers,
35 discountCurves, simulationDates, externalModelIndices, minimalObsDate, regressorModel,
36 regressionVarianceCutoff),
37 currencies_(currencies), npvCcy_(npvCcy) {
38 registerWith(model_);
39 for (auto const& h : discountCurves)
40 registerWith(h);
41}
42
44
45 leg_ = arguments_.legs;
46 currency_ = arguments_.currency;
47 payer_.resize(arguments_.payer.size());
48 for (Size i = 0; i < arguments_.payer.size(); ++i) {
49 payer_[i] = QuantLib::close_enough(arguments_.payer[i], -1.0);
50 }
51 exercise_ = nullptr;
52
54
55 // convert base ccy result from McMultiLegbaseEngine to desired npv currency
56 Real fxSpot = 1.0;
57 Size npvCcyIndex = model_->ccyIndex(npvCcy_);
58 if (npvCcyIndex > 0)
59 fxSpot = model_->fxbs(npvCcyIndex - 1)->fxSpotToday()->value();
60 results_.value = resultValue_ / fxSpot;
61 results_.additionalResults["amcCalculator"] = amcCalculator();
62} // calculate
63
64} // namespace QuantExt
const Instrument::results * results_
Definition: cdsoption.cpp:81
McCamCurrencySwapEngine(const Handle< CrossAssetModel > &model, const std::vector< Currency > &currencies, 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 currency swaps.
Swap::arguments * arguments_