37 bool operator()(
const Currency& c1,
const Currency& c2)
const {
return c1.code() < c2.code(); }
42 const Currency& base) {
44 std::set<Currency, CcyComp> allCurrencies(ccys.begin(), ccys.end());
45 allCurrencies.insert(base);
47 std::string ccysStr = base.code();
48 for (
auto const& c : ccys) {
49 ccysStr +=
"_" + c.code();
52 DLOG(
"Building multi leg option engine for ccys " << ccysStr <<
" (from externally given CAM)");
54 QL_REQUIRE(!ccys.empty(),
"CamMcMultiLegOptionEngineBuilder: no currencies given");
56 std::vector<Size> externalModelIndices;
57 std::vector<Handle<YieldTermStructure>> discountCurves;
58 std::vector<Size> cIdx;
59 std::vector<QuantLib::ext::shared_ptr<IrModel>> lgm;
60 std::vector<QuantLib::ext::shared_ptr<FxBsParametrization>> fx;
64 bool needBaseCcy = allCurrencies.size() > 1;
69 for (Size i = 0; i <
cam_->components(CrossAssetModel::AssetType::IR); ++i) {
70 if ((i == 0 && needBaseCcy) || std::find(allCurrencies.begin(), allCurrencies.end(),
71 cam_->irlgm1f(i)->currency()) != allCurrencies.end()) {
72 lgm.push_back(
cam_->lgm(i));
73 externalModelIndices.push_back(
cam_->pIdx(CrossAssetModel::AssetType::IR, i));
74 cIdx.push_back(
cam_->cIdx(CrossAssetModel::AssetType::IR, i));
76 fx.push_back(
cam_->fxbs(i - 1));
77 externalModelIndices.push_back(
cam_->pIdx(CrossAssetModel::AssetType::FX, i - 1));
78 cIdx.push_back(
cam_->cIdx(CrossAssetModel::AssetType::FX, i - 1));
83 std::sort(externalModelIndices.begin(), externalModelIndices.end());
84 std::sort(cIdx.begin(), cIdx.end());
87 Matrix corr(cIdx.size(), cIdx.size(), 1.0);
88 for (Size i = 0; i < cIdx.size(); ++i) {
89 for (Size j = 0; j < i; ++j) {
90 corr(i, j) = corr(j, i) =
cam_->correlation()(cIdx[i], cIdx[j]);
94 Handle<CrossAssetModel>
model(QuantLib::ext::make_shared<CrossAssetModel>(lgm, fx, corr));
101 auto engine = QuantLib::ext::make_shared<McCamCurrencySwapEngine>(
const std::vector< Date > simulationDates_
const QuantLib::ext::shared_ptr< QuantExt::CrossAssetModel > cam_
QuantLib::ext::shared_ptr< PricingEngine > engineImpl(const std::vector< Currency > &ccys, const Currency &base) override
const string & engine() const
Return the engine name.
const string & model() const
Return the model name.
std::string engineParameter(const std::string &p, const std::vector< std::string > &qualifiers={}, const bool mandatory=true, const std::string &defaultValue="") const
Build a cross asset model.
FX component data for the cross asset model.
SequenceType parseSequenceType(const std::string &s)
Convert string to sequence type.
QuantLib::LsmBasisSystem::PolynomialType parsePolynomType(const std::string &s)
Convert text to QuantLib::LsmBasisSystem::PolynomialType.
bool parseBool(const string &s)
Convert text to bool.
SobolRsg::DirectionIntegers parseSobolRsgDirectionIntegers(const std::string &s)
Convert text to QuantLib::SobolRsg::DirectionIntegers.
Real parseRealOrNull(const string &s)
Convert text to Real, empty string to Null<Real>()
QuantExt::McMultiLegBaseEngine::RegressorModel parseRegressorModel(const std::string &s)
Convert text to QuantExt::McMultiLegBaseEngine::RegressorModel.
SobolBrownianGenerator::Ordering parseSobolBrownianGeneratorOrdering(const std::string &s)
Convert text to QuantLib::SobolBrownianGenerator::Ordering.
Integer parseInteger(const string &s)
Convert text to QuantLib::Integer.
Linear Gauss Markov model data.
Classes and functions for log message handling.
#define DLOG(text)
Logging Macro (Level = Debug)
Serializable Credit Default Swap.
string conversion utilities