|
21 | 21 | #include <ored/scripting/models/blackscholescg.hpp> |
22 | 22 | #include <ored/scripting/models/fdblackscholesbase.hpp> |
23 | 23 | #include <ored/scripting/models/gaussiancam.hpp> |
| 24 | +#include <ored/scripting/models/gaussiancamcg.hpp> |
24 | 25 | #include <ored/scripting/models/localvol.hpp> |
25 | 26 | #include <ored/scripting/engines/scriptedinstrumentpricingengine.hpp> |
26 | 27 | #include <ored/scripting/engines/scriptedinstrumentpricingenginecg.hpp> |
@@ -1278,7 +1279,7 @@ void ScriptedTradeEngineBuilder::buildGaussianCam(const std::string& id, const I |
1278 | 1279 | std::vector<boost::shared_ptr<EqBsData>> eqConfigs; |
1279 | 1280 | std::vector<boost::shared_ptr<CommoditySchwartzData>> comConfigs; |
1280 | 1281 | // TODO: populate comConfigs |
1281 | | - |
| 1282 | + |
1282 | 1283 | // calibration expiries and terms for IR, INF, FX, EQ parametrisations (this will only work for a fixed reference |
1283 | 1284 | // date, due to the way the cam builder and nested builders work, see ticket #940) |
1284 | 1285 | Date referenceDate = modelCurves_.front()->referenceDate(); |
@@ -1473,19 +1474,30 @@ void ScriptedTradeEngineBuilder::buildGaussianCam(const std::string& id, const I |
1473 | 1474 |
|
1474 | 1475 | std::string configurationInCcy = configuration(MarketContext::irCalibration); |
1475 | 1476 | std::string configurationXois = configuration(MarketContext::pricing); |
| 1477 | + auto discretization = useCg_ ? CrossAssetModel::Discretization::Euler : CrossAssetModel::Discretization::Exact; |
1476 | 1478 | auto camBuilder = boost::make_shared<CrossAssetModelBuilder>( |
1477 | 1479 | market_, |
1478 | 1480 | boost::make_shared<CrossAssetModelData>(irConfigs, fxConfigs, eqConfigs, infConfigs, crLgmConfigs, crCirConfigs, |
1479 | | - comConfigs, 0, camCorrelations, bootstrapTolerance_), |
| 1481 | + comConfigs, 0, camCorrelations, bootstrapTolerance_, "LGM", |
| 1482 | + discretization), |
1480 | 1483 | configurationInCcy, configurationXois, configurationXois, configurationInCcy, configurationInCcy, |
1481 | 1484 | configurationXois, !calibrate_ || zeroVolatility_, continueOnCalibrationError_, referenceCalibrationGrid_, |
1482 | 1485 | SalvagingAlgorithm::Spectral, id); |
1483 | 1486 |
|
1484 | | - // TODO hardcode timeStepsPerYear to 0 and exact discretisation (we might want Euler for AD...) |
1485 | | - model_ = boost::make_shared<GaussianCam>(camBuilder->model(), modelSize_, modelCcys_, modelCurves_, modelFxSpots_, |
1486 | | - modelIrIndices_, modelInfIndices_, modelIndices_, modelIndicesCurrencies_, |
1487 | | - simulationDates_, mcParams_, 0, iborFallbackConfig, std::vector<Size>(), |
1488 | | - conditionalExpectationModelStates); |
| 1487 | + // effective time steps per year: zero for exact evolution, otherwise the pricing engine parameter |
| 1488 | + if (useCg_) { |
| 1489 | + modelCG_ = boost::make_shared<GaussianCamCG>( |
| 1490 | + camBuilder->model(), modelSize_, modelCcys_, modelCurves_, modelFxSpots_, modelIrIndices_, modelInfIndices_, |
| 1491 | + modelIndices_, modelIndicesCurrencies_, simulationDates_, |
| 1492 | + camBuilder->model()->discretization() == CrossAssetModel::Discretization::Exact ? 0 : timeStepsPerYear_, |
| 1493 | + iborFallbackConfig, std::vector<Size>(), conditionalExpectationModelStates); |
| 1494 | + } else { |
| 1495 | + model_ = boost::make_shared<GaussianCam>( |
| 1496 | + camBuilder->model(), modelSize_, modelCcys_, modelCurves_, modelFxSpots_, modelIrIndices_, modelInfIndices_, |
| 1497 | + modelIndices_, modelIndicesCurrencies_, simulationDates_, mcParams_, |
| 1498 | + camBuilder->model()->discretization() == CrossAssetModel::Discretization::Exact ? 0 : timeStepsPerYear_, |
| 1499 | + iborFallbackConfig, std::vector<Size>(), conditionalExpectationModelStates); |
| 1500 | + } |
1489 | 1501 |
|
1490 | 1502 | modelBuilders_.insert(std::make_pair(id, camBuilder)); |
1491 | 1503 | } |
@@ -1526,11 +1538,20 @@ void ScriptedTradeEngineBuilder::buildGaussianCamAMC( |
1526 | 1538 | Handle<CrossAssetModel> projectedModel( |
1527 | 1539 | getProjectedCrossAssetModel(amcCam_, selectedComponents, projectedStateProcessIndices)); |
1528 | 1540 |
|
1529 | | - // TODO hardcode timeStepsPerYear to 1 and exact discretisation (we might want Euler for AD...) |
1530 | | - model_ = boost::make_shared<GaussianCam>(projectedModel, modelSize_, modelCcys_, modelCurves_, modelFxSpots_, |
1531 | | - modelIrIndices_, modelInfIndices_, modelIndices_, modelIndicesCurrencies_, |
1532 | | - simulationDates_, mcParams_, 1, iborFallbackConfig, |
1533 | | - projectedStateProcessIndices, conditionalExpectationModelStates); |
| 1541 | + // effective time steps per year: zero for exact evolution, otherwise the pricing engine parameter |
| 1542 | + if (useCg_) { |
| 1543 | + modelCG_ = boost::make_shared<GaussianCamCG>( |
| 1544 | + projectedModel, modelSize_, modelCcys_, modelCurves_, modelFxSpots_, modelIrIndices_, modelInfIndices_, |
| 1545 | + modelIndices_, modelIndicesCurrencies_, simulationDates_, |
| 1546 | + projectedModel->discretization() == CrossAssetModel::Discretization::Exact ? 0 : timeStepsPerYear_, |
| 1547 | + iborFallbackConfig, projectedStateProcessIndices, conditionalExpectationModelStates); |
| 1548 | + } else { |
| 1549 | + model_ = boost::make_shared<GaussianCam>( |
| 1550 | + projectedModel, modelSize_, modelCcys_, modelCurves_, modelFxSpots_, modelIrIndices_, modelInfIndices_, |
| 1551 | + modelIndices_, modelIndicesCurrencies_, simulationDates_, mcParams_, |
| 1552 | + projectedModel->discretization() == CrossAssetModel::Discretization::Exact ? 0 : timeStepsPerYear_, |
| 1553 | + iborFallbackConfig, projectedStateProcessIndices, conditionalExpectationModelStates); |
| 1554 | + } |
1534 | 1555 |
|
1535 | 1556 | DLOG("built GuassianCam model as projection of xva evolution model"); |
1536 | 1557 | for (auto const& p : projectedStateProcessIndices) |
|
0 commit comments