24#include <ql/currencies/europe.hpp>
25#include <ql/experimental/credit/onefactorgaussiancopula.hpp>
26#include <ql/experimental/credit/randomdefaultmodel.hpp>
31static DefaultProbKey dummyDefaultProbKey() {
32 Currency currency = QuantLib::EURCurrency();
33 Seniority seniority = NoSeniority;
34 QuantLib::ext::shared_ptr<DefaultType> defaultType(
new DefaultType());
35 vector<QuantLib::ext::shared_ptr<DefaultType>> defaultTypes(1, defaultType);
36 DefaultProbKey key(defaultTypes, currency, seniority);
50 string lossDistributionPeriods_str =
engineParameter(
"LossDistributionPeriods");
51 std::vector<string> lossDistributionPeriods_vec =
parseListOfValues(lossDistributionPeriods_str);
52 std::vector<QuantLib::Period> lossDistributionPeriods;
53 for (Size i = 0; i < lossDistributionPeriods_vec.size(); i++)
54 lossDistributionPeriods.push_back(
parsePeriod(lossDistributionPeriods_vec[i]));
56 QuantLib::ext::shared_ptr<SimpleQuote> correlationQuote(
new SimpleQuote(corr));
57 Handle<Quote> correlationHandle = Handle<Quote>(correlationQuote);
58 QuantLib::ext::shared_ptr<OneFactorCopula> gaussianCopula(
new OneFactorGaussianCopula(correlationHandle));
59 RelinkableHandle<OneFactorCopula> copula(gaussianCopula);
61 vector<DefaultProbKey> keys(pool->size(), dummyDefaultProbKey());
63 QuantLib::ext::shared_ptr<RandomDefaultModel> rdm(
new GaussianRandomDefaultModel(pool, keys, copula, 1.e-6, seed));
65 return QuantLib::ext::make_shared<QuantExt::MonteCarloCBOEngine>(rdm, samples, bins, errorTolerance,
66 lossDistributionPeriods);
const string & engine() const
Return the engine name.
std::string engineParameter(const std::string &p, const std::vector< std::string > &qualifiers={}, const bool mandatory=true, const std::string &defaultValue="") const
Period parsePeriod(const string &s)
Convert text to QuantLib::Period.
Real parseReal(const string &s)
Convert text to Real.
Integer parseInteger(const string &s)
Convert text to QuantLib::Integer.
std::vector< string > parseListOfValues(string s, const char escape, const char delim, const char quote)
Serializable Credit Default Swap.