20#include <qle/cashflows/mcgaussianformulabasedcouponpricer.hpp>
22#include <ql/math/matrixutilities/pseudosqrt.hpp>
24#include <boost/algorithm/string.hpp>
25#include <boost/make_shared.hpp>
32#include <boost/algorithm/string.hpp>
40 const std::string& paymentCcy,
41 const std::map<std::string, QuantLib::ext::shared_ptr<QuantLib::IborCouponPricer>>& iborPricers,
42 const std::map<std::string, QuantLib::ext::shared_ptr<QuantLib::CmsCouponPricer>>& cmsPricers,
43 const std::map<std::string, QuantLib::ext::shared_ptr<InterestRateIndex>>& indexMaps) {
50 ? SalvagingAlgorithm::Spectral
51 : SalvagingAlgorithm::None;
54 std::map<std::string, Handle<BlackVolTermStructure>> fxVols;
55 for (
auto const& i : indexMaps) {
56 std::string indexCcy = i.second->currency().code();
57 if (indexCcy != paymentCcy) {
64 std::map<std::pair<std::string, std::string>, Handle<QuantExt::CorrelationTermStructure>> correlation;
66 std::string index1, index2, indexQL1, indexQL2;
68 for (
auto it1 = indexMaps.begin(); it1 != std::prev(indexMaps.end(), 1); it1++) {
70 indexQL1 = it1->second->name();
71 for (
auto it2 = std::next(it1, 1); it2 != indexMaps.end(); it2++) {
73 indexQL2 = it2->second->name();
74 QuantLib::Handle<QuantExt::CorrelationTermStructure> corrCurve(
75 QuantLib::ext::make_shared<FlatCorrelation>(0, NullCalendar(), 0.0, Actual365Fixed()));
79 WLOG(
"no correlation curve found for " << index1 <<
", " << index2
80 <<
" found, fall back to zero correlation.");
82 correlation[std::make_pair(indexQL1, indexQL2)] = corrCurve;
86 std::string index, indexQL, indexCcy, fxIndex;
87 for (
auto const& it : indexMaps) {
89 indexQL = it.second->name();
90 std::vector<std::string> result;
91 boost::split(result, index, boost::is_any_of(
"-"));
93 if (indexCcy != paymentCcy) {
94 fxIndex =
"FX-" + fxSource +
"-" + indexCcy +
"-" + paymentCcy;
95 QuantLib::Handle<QuantExt::CorrelationTermStructure> corrCurve(
96 QuantLib::ext::make_shared<FlatCorrelation>(0, NullCalendar(), 0.0, Actual365Fixed()));
100 WLOG(
"no correlation curve found for " << index <<
", " << fxIndex
101 <<
" found, fall back to zero correlation.");
103 correlation[std::make_pair(indexQL,
"FX")] = corrCurve;
108 return QuantLib::ext::make_shared<QuantExt::MCGaussianFormulaBasedCouponPricer>(
109 paymentCcy, iborPricers, cmsPricers, fxVols, correlation, discount, samples, seed, useSobol, salvaging);
QuantLib::ext::shared_ptr< Market > market_
map< string, string > engineParameters_
const string & configuration(const MarketContext &key)
Return a configuration (or the default one if key not found)
map< string, string > modelParameters_
bool parseBool(const string &s)
Convert text to bool.
Integer parseInteger(const string &s)
Convert text to QuantLib::Integer.
Map text representations to QuantLib/QuantExt types.
#define WLOG(text)
Logging Macro (Level = Warning)
Serializable Credit Default Swap.
Map text representations to QuantLib/QuantExt types.