23QuantLib::ext::shared_ptr<CrossAssetModel>
25 const std::vector<std::pair<CrossAssetModel::AssetType, Size>>& selectedComponents,
26 std::vector<Size>& projectedStateProcessIndices) {
28 projectedStateProcessIndices.clear();
32 std::vector<QuantLib::ext::shared_ptr<Parametrization>> parametrizations;
33 std::vector<Size> correlationIndices;
40 for (
auto const& c : selectedComponents) {
41 parametrizations.push_back(model->parametrizations().at(model->idx(c.first, c.second)));
42 for (Size b = 0; b < model->brownians(c.first, c.second); ++b)
43 correlationIndices.push_back(model->cIdx(c.first, c.second, b));
44 for (Size p = 0; p < model->stateVariables(c.first, c.second); ++p)
45 projectedStateProcessIndices.push_back(model->pIdx(c.first, c.second, p));
50 Matrix correlation(correlationIndices.size(), correlationIndices.size());
51 for (Size j = 0; j < correlationIndices.size(); ++j) {
52 correlation(j, j) = 1.0;
53 for (Size k = 0; k < j; ++k) {
54 correlation(k, j) = correlation(j, k) =
55 model->correlation()(correlationIndices.at(j), correlationIndices.at(k));
61 return QuantLib::ext::make_shared<CrossAssetModel>(parametrizations, correlation, model->salvagingAlgorithm(),
62 model->measure(), model->discretization());
66 const QuantLib::ext::shared_ptr<CrossAssetModel>& projectedModel) {
68 std::vector<Size> stateProcessProjection(projectedModel->stateProcess()->size(), Null<Size>());
72 if (projectedModel->ir(j)->currency() == model->ir(i)->currency()) {
83 if (projectedModel->fx(j)->currency() == model->fx(i)->currency()) {
94 if (projectedModel->inf(j)->name() == model->inf(i)->name()) {
105 if (projectedModel->cr(j)->name() == model->cr(i)->name()) {
116 if (projectedModel->eq(j)->name() == model->eq(i)->name()) {
125 return stateProcessProjection;
QuantLib::ext::shared_ptr< CrossAssetModel > getProjectedCrossAssetModel(const QuantLib::ext::shared_ptr< CrossAssetModel > &model, const std::vector< std::pair< CrossAssetModel::AssetType, Size > > &selectedComponents, std::vector< Size > &projectedStateProcessIndices)
std::vector< Size > getStateProcessProjection(const QuantLib::ext::shared_ptr< CrossAssetModel > &model, const QuantLib::ext::shared_ptr< CrossAssetModel > &projectedModel)
cross asset model projection utils