Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
swap.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/methods/montecarlo/lsmbasissystem.hpp>
22
25
26#include <set>
27
28namespace ore {
29namespace data {
30
31using namespace QuantLib;
32using namespace QuantExt;
33
34QuantLib::ext::shared_ptr<PricingEngine> CamAmcSwapEngineBuilder::buildMcEngine(const QuantLib::ext::shared_ptr<LGM>& lgm,
35 const Handle<YieldTermStructure>& discountCurve,
36 const std::vector<Date>& simulationDates,
37 const std::vector<Size>& externalModelIndices) {
38
39 return QuantLib::ext::make_shared<QuantExt::McLgmSwapEngine>(
40 lgm, parseSequenceType(engineParameter("Training.Sequence")),
41 parseSequenceType(engineParameter("Pricing.Sequence")), parseInteger(engineParameter("Training.Samples")),
42 parseInteger(engineParameter("Pricing.Samples")), parseInteger(engineParameter("Training.Seed")),
43 parseInteger(engineParameter("Pricing.Seed")), parseInteger(engineParameter("Training.BasisFunctionOrder")),
44 parsePolynomType(engineParameter("Training.BasisFunction")),
46 parseSobolRsgDirectionIntegers(engineParameter("SobolDirectionIntegers")), discountCurve, simulationDates,
47 externalModelIndices, parseBool(engineParameter("MinObsDate")),
48 parseRegressorModel(engineParameter("RegressorModel", {}, false, "Simple")),
49 parseRealOrNull(engineParameter("RegressionVarianceCutoff", {}, false, std::string())));
50}
51
52QuantLib::ext::shared_ptr<PricingEngine> CamAmcSwapEngineBuilder::engineImpl(const Currency& ccy,
53 const std::string& discountCurveName,
54 const std::string& securitySpread) {
55 DLOG("Building AMC Swap engine for ccy " << ccy << " (from externally given CAM)");
56
57 QL_REQUIRE(cam_ != nullptr, "LgmAmcSwapEngineBuilder::engineImpl: cam is null");
58 Size currIdx = cam_->ccyIndex(ccy);
59 auto lgm = cam_->lgm(currIdx);
60 std::vector<Size> modelIndex(1, cam_->pIdx(CrossAssetModel::AssetType::IR, currIdx));
61
62 // we assume that the given cam has pricing discount curves attached already
63 Handle<YieldTermStructure> discountCurve;
64 return buildMcEngine(lgm, discountCurve, simulationDates_, modelIndex);
65}
66
67} // namespace data
68} // namespace ore
Engine builder for Swaps.
const std::vector< Date > simulationDates_
Definition: swap.hpp:170
const QuantLib::ext::shared_ptr< QuantExt::CrossAssetModel > cam_
Definition: swap.hpp:169
virtual QuantLib::ext::shared_ptr< PricingEngine > engineImpl(const Currency &ccy, const std::string &discountCurve, const std::string &securitySpread) override
Definition: swap.cpp:52
QuantLib::ext::shared_ptr< PricingEngine > buildMcEngine(const QuantLib::ext::shared_ptr< QuantExt::LGM > &lgm, const Handle< YieldTermStructure > &discountCurve, const std::vector< Date > &simulationDates, const std::vector< Size > &externalModelIndices)
Definition: swap.cpp:34
std::string engineParameter(const std::string &p, const std::vector< std::string > &qualifiers={}, const bool mandatory=true, const std::string &defaultValue="") const
SequenceType parseSequenceType(const std::string &s)
Convert string to sequence type.
Definition: parsers.cpp:668
QuantLib::LsmBasisSystem::PolynomialType parsePolynomType(const std::string &s)
Convert text to QuantLib::LsmBasisSystem::PolynomialType.
Definition: parsers.cpp:527
bool parseBool(const string &s)
Convert text to bool.
Definition: parsers.cpp:144
SobolRsg::DirectionIntegers parseSobolRsgDirectionIntegers(const std::string &s)
Convert text to QuantLib::SobolRsg::DirectionIntegers.
Definition: parsers.cpp:579
Real parseRealOrNull(const string &s)
Convert text to Real, empty string to Null<Real>()
Definition: parsers.cpp:120
QuantExt::McMultiLegBaseEngine::RegressorModel parseRegressorModel(const std::string &s)
Convert text to QuantExt::McMultiLegBaseEngine::RegressorModel.
Definition: parsers.cpp:1418
SobolBrownianGenerator::Ordering parseSobolBrownianGeneratorOrdering(const std::string &s)
Convert text to QuantLib::SobolBrownianGenerator::Ordering.
Definition: parsers.cpp:567
Integer parseInteger(const string &s)
Convert text to QuantLib::Integer.
Definition: parsers.cpp:136
@ data
Definition: log.hpp:77
#define DLOG(text)
Logging Macro (Level = Debug)
Definition: log.hpp:554
Serializable Credit Default Swap.
Definition: namespaces.docs:23