36 const Currency& domCcy,
38 const Date& expiryDate,
const bool useFxSpot) {
40 QL_REQUIRE(assetClassUnderlying ==
AssetClass::FX,
"FX Option required");
43 std::string ccysStr = forCcy.code() +
"_" + domCcy.code();
45 DLOG(
"Building AMC FX option engine for ccys " << ccysStr <<
" (from externally given CAM)");
47 QL_REQUIRE(domCcy != forCcy,
"CamAmcFxOptionEngineBuilder: domCcy = forCcy = " << domCcy.code());
49 std::vector<Size> externalModelIndices;
50 std::vector<Handle<YieldTermStructure>> discountCurves;
51 std::vector<Size> cIdx;
52 std::vector<QuantLib::ext::shared_ptr<IrModel>> lgm;
53 std::vector<QuantLib::ext::shared_ptr<FxBsParametrization>> fx;
59 for (Size i = 0; i <
cam_->components(CrossAssetModel::AssetType::IR); ++i) {
60 if (i == 0 ||
cam_->irlgm1f(i)->currency() == domCcy ||
cam_->irlgm1f(i)->currency() == forCcy) {
61 lgm.push_back(
cam_->lgm(i));
62 externalModelIndices.push_back(
cam_->pIdx(CrossAssetModel::AssetType::IR, i));
63 cIdx.push_back(
cam_->cIdx(CrossAssetModel::AssetType::IR, i));
65 fx.push_back(
cam_->fxbs(i - 1));
66 externalModelIndices.push_back(
cam_->pIdx(CrossAssetModel::AssetType::FX, i - 1));
67 cIdx.push_back(
cam_->cIdx(CrossAssetModel::AssetType::FX, i - 1));
72 std::sort(externalModelIndices.begin(), externalModelIndices.end());
73 std::sort(cIdx.begin(), cIdx.end());
76 Matrix corr(cIdx.size(), cIdx.size(), 1.0);
77 for (Size i = 0; i < cIdx.size(); ++i) {
78 for (Size j = 0; j < i; ++j) {
79 corr(i, j) = corr(j, i) =
cam_->correlation()(cIdx[i], cIdx[j]);
82 Handle<CrossAssetModel>
model(QuantLib::ext::make_shared<CrossAssetModel>(lgm, fx, corr));
89 auto engine = QuantLib::ext::make_shared<McCamFxOptionEngine>(
Engine builder for FX Options.
const std::vector< Date > simulationDates_
QuantLib::ext::shared_ptr< PricingEngine > engineImpl(const string &assetName, const Currency &ccy, const AssetClass &assetClassUnderlying, const Date &expiryDate, const bool useFxSpot) override
const QuantLib::ext::shared_ptr< QuantExt::CrossAssetModel > cam_
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.
Currency parseCurrency(const string &s)
Convert text to QuantLib::Currency.
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