20#include <ql/experimental/credit/nthtodefault.hpp>
21#include <ql/experimental/credit/lossdistribution.hpp>
22#include <ql/instruments/claim.hpp>
23#include <ql/cashflows/fixedratecoupon.hpp>
24#include <ql/termstructures/yieldtermstructure.hpp>
25#include <ql/event.hpp>
26#include <ql/experimental/credit/basket.hpp>
32 const ext::shared_ptr<Basket>& basket,
40 bool settlePremiumAccrual
42 : basket_(basket), n_(n),
43 side_(side), nominal_(nominal),
44 premiumSchedule_(premiumSchedule), premiumRate_(premiumRate),
45 upfrontRate_(upfrontRate),
46 dayCounter_(dayCounter), settlePremiumAccrual_(settlePremiumAccrual)
48 QL_REQUIRE(n_ <= basket_->size(),
49 "NTD order provided is larger than the basket size.");
54 "Basket did not exist before contract start.");
75 "fair premium not available");
82 "premium leg not available");
84 "upfront value not available");
91 "protection leg not available");
98 "error estimate not available");
115 QL_REQUIRE(
arguments !=
nullptr,
"wrong argument type");
130 QL_REQUIRE(
results !=
nullptr,
"wrong result type");
150 QL_REQUIRE(
basket && !
basket->names().empty(),
"no basket given");
152 QL_REQUIRE(premiumRate !=
Null<Real>(),
"no premium rate given");
153 QL_REQUIRE(upfrontRate !=
Null<Real>(),
"no upfront rate given");
154 QL_REQUIRE(notional !=
Null<Real>(),
"no notional given");
155 QL_REQUIRE(ntdOrder !=
Null<Size>(),
"no NTD order given");
virtual bool hasOccurred(const Date &refDate=Date(), ext::optional< bool > includeRefDate=ext::nullopt) const
returns true if an event has already occurred before a date
helper class building a sequence of fixed rate coupons
FixedRateLeg & withNotionals(Real)
FixedRateLeg & withPaymentAdjustment(BusinessDayConvention)
FixedRateLeg & withCouponRates(Rate, const DayCounter &paymentDayCounter, Compounding comp=Simple, Frequency freq=Annual)
std::map< std::string, ext::any > additionalResults
void calculate() const override
virtual void fetchResults(const PricingEngine::results *) const
virtual void setupExpired() const
ext::shared_ptr< Basket > basket
void validate() const override
bool settlePremiumAccrual
Real upfrontPremiumValue_
ext::shared_ptr< Basket > basket_
void setupArguments(PricingEngine::arguments *) const override
const ext::shared_ptr< Basket > & basket() const
bool isExpired() const override
returns whether the instrument might have value greater than zero.
Real errorEstimate() const
bool settlePremiumAccrual_
Real protectionLegNPV() const
Real premiumLegNPV() const
void setupExpired() const override
void fetchResults(const PricingEngine::results *) const override
DayCounter dayCounter() const
NthToDefault(const ext::shared_ptr< Basket > &basket, Size n, Protection::Side side, const Schedule &premiumSchedule, Rate upfrontRate, Rate premiumRate, const DayCounter &dayCounter, Real nominal, bool settlePremiumAccrual)
This product is 'digital'; the basket might be tranched but this is.
Protection::Side side() const
template class providing a null value for a given type.
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
const Date & startDate() const
std::size_t Size
size of a container