29 ext::shared_ptr<CatRisk> catRisk,
31 const ext::optional<bool>& includeSettlementDateFlows)
39 "discounting term structure handle is empty");
48 Real exhaustionProbability;
55 exhaustionProbability,
64 if (!includeRefDateFlows
77 const size_t MAX_PATHS = 10000;
78 lossProbability = 0.0;
79 exhaustionProbability = 0.0;
84 if (settlementDate ==
Date())
87 if (npvDate ==
Date())
88 npvDate = settlementDate;
93 ext::shared_ptr<CatSimulation> catSimulation =
catRisk_->newSimulation(effectiveDate, maturityDate);
94 std::vector<std::pair<Date, Real> > eventsPath;
96 Real riskFreeNPV =
pathNpv(includeSettlementDateFlows, settlementDate, notionalPath);
98 while(catSimulation->nextPath(eventsPath) && pathCount<MAX_PATHS)
101 if(notionalPath.
loss()>0) {
102 totalNPV +=
pathNpv(includeSettlementDateFlows, settlementDate, notionalPath);
104 if (notionalPath.
loss()==1)
105 exhaustionProbability+=1;
106 expectedLoss+=notionalPath.
loss();
108 totalNPV += riskFreeNPV;
112 lossProbability/=pathCount;
113 exhaustionProbability/=pathCount;
114 expectedLoss/=pathCount;
123 if (!cashflow->hasOccurred(settlementDate, includeSettlementDateFlows)) {
133 return cf->amount()*notionalPath.
notionalRate(cf->date());
bool includeSettlementDateFlows_
const YieldTermStructure & discountCurve_
Cash-flow analysis functions.
ext::shared_ptr< NotionalRisk > notionalRisk
Real exhaustionProbability
CatBond::results results_
CatBond::arguments arguments_
Shared handle to an observable.
Handle< YieldTermStructure > discountCurve_
MonteCarloCatBondEngine(ext::shared_ptr< CatRisk > catRisk, Handle< YieldTermStructure > discountCurve=Handle< YieldTermStructure >(), const ext::optional< bool > &includeSettlementDateFlows=ext::nullopt)
ext::shared_ptr< CatRisk > catRisk_
ext::optional< bool > includeSettlementDateFlows_
Real npv(bool includeSettlementDateFlows, Date settlementDate, Date npvDate, Real &lossProbability, Real &exhaustionProbability, Real &expectedLoss) const
Real pathNpv(bool includeSettlementDateFlows, Date settlementDate, const NotionalPath ¬ionalPath) const
Real cashFlowRiskyValue(const ext::shared_ptr< CashFlow > &cf, const NotionalPath ¬ionalPath) const
void calculate() const override
Rate notionalRate(const Date &date) const
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
bool & includeReferenceDateEvents()
DateProxy & evaluationDate()
the date at which pricing is to be performed.
static Settings & instance()
access to the unique instance
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Monte Carlo pricing engine for cat bonds.
Maps optional to either the boost or std implementation.