Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
RiskParticipationAgreement Class Reference

#include <qle/instruments/riskparticipationagreement.hpp>

+ Inheritance diagram for RiskParticipationAgreement:
+ Collaboration diagram for RiskParticipationAgreement:

Classes

class  arguments
 
class  engine
 
class  results
 

Public Member Functions

 RiskParticipationAgreement (const std::vector< Leg > &underlying, const std::vector< bool > &underlyingPayer, const std::vector< std::string > &underlyingCcys, const std::vector< Leg > &protectionFee, const bool protectionFeePayer, const std::vector< std::string > &protectionFeeCcys, const Real participationRate, const Date &protectionStart, const Date &protectionEnd, const bool settlesAccrual, const Real fixedRecoveryRate=Null< Real >(), const QuantLib::ext::shared_ptr< QuantLib::Exercise > &exercise=nullptr, const bool exerciseIsLong=false, const std::vector< QuantLib::ext::shared_ptr< CashFlow > > &premium=std::vector< QuantLib::ext::shared_ptr< CashFlow > >(), const bool nakedOption=false)
 
bool isExpired () const override
 Instrument interface. More...
 
const std::vector< Leg > & underlying () const
 Inspectors. More...
 
const std::vector< bool > & underlyingPayer () const
 
const std::vector< std::string > & underlyingCcys () const
 
const std::vector< Leg > & protectionFee () const
 
bool protectionFeePayer () const
 
const std::vector< std::string > & protectionFeeCcys () const
 
Real participationRate () const
 
const Date & protectionStart () const
 
const Date & protectionEnd () const
 
bool settlesAccrual () const
 
Real fixedRecoveryRate () const
 
const QuantLib::ext::shared_ptr< Exercise > & exercise () const
 
const bool nakedOption () const
 
const Date & maturity () const
 
const Date & underlyingMaturity () const
 

Private Member Functions

void setupArguments (QuantLib::PricingEngine::arguments *) const override
 
void setupExpired () const override
 
void fetchResults (const QuantLib::PricingEngine::results *) const override
 

Private Attributes

const std::vector< Leg > underlying_
 
const std::vector< boolunderlyingPayer_
 
const std::vector< std::string > underlyingCcys_
 
const std::vector< Leg > protectionFee_
 
const bool protectionFeePayer_
 
const std::vector< std::string > protectionFeeCcys_
 
const Real participationRate_
 
const Date protectionStart_
 
const Date protectionEnd_
 
const bool settlesAccrual_
 
const Real fixedRecoveryRate_
 
const QuantLib::ext::shared_ptr< Exercise > exercise_
 
const bool exerciseIsLong_
 
const std::vector< QuantLib::ext::shared_ptr< CashFlow > > premium_
 
const bool nakedOption_
 
Date maturity_
 
Date underlyingMaturity_
 
Date optionRepresentationReferenceDate_
 
std::vector< std::tuple< Date, Date, Date > > optionRepresentationPeriods_
 
std::vector< QuantLib::ext::shared_ptr< Instrument > > optionRepresentation_
 
std::vector< Real > optionMultiplier_
 

Detailed Description

Definition at line 35 of file riskparticipationagreement.hpp.

Constructor & Destructor Documentation

◆ RiskParticipationAgreement()

RiskParticipationAgreement ( const std::vector< Leg > &  underlying,
const std::vector< bool > &  underlyingPayer,
const std::vector< std::string > &  underlyingCcys,
const std::vector< Leg > &  protectionFee,
const bool  protectionFeePayer,
const std::vector< std::string > &  protectionFeeCcys,
const Real  participationRate,
const Date &  protectionStart,
const Date &  protectionEnd,
const bool  settlesAccrual,
const Real  fixedRecoveryRate = Null<Real>(),
const QuantLib::ext::shared_ptr< QuantLib::Exercise > &  exercise = nullptr,
const bool  exerciseIsLong = false,
const std::vector< QuantLib::ext::shared_ptr< CashFlow > > &  premium = std::vector<QuantLib::ext::shared_ptr<CashFlow>>(),
const bool  nakedOption = false 
)

Definition at line 26 of file riskparticipationagreement.cpp.

36 exerciseIsLong_(exerciseIsLong), premium_(premium), nakedOption_(nakedOption) {
37
38 QL_REQUIRE(underlying_.size() == underlyingPayer_.size(),
39 "underlying size (" << underlying_.size() << ") must match underlying payer size ("
40 << underlyingPayer_.size() << ")");
41 QL_REQUIRE(underlying_.size() == underlyingCcys_.size(),
42 "underlying size (" << underlying_.size() << ") must match underlying ccys size ("
43 << underlyingCcys_.size() << ")");
44 QL_REQUIRE(!underlying_.empty(), "underlying is empty");
45 QL_REQUIRE(protectionFee_.size() == protectionFeeCcys_.size(),
46 "protection fee size (" << protectionFee_.size() << ") must match protecttion fee ccys size ("
47 << protectionFeeCcys_.size() << ")");
48 QL_REQUIRE(participationRate_ > 0.0 || close_enough(participationRate_, 0.0),
49 "participation rate must be non-negative (" << participationRate_ << ")");
51 "protection end (" << protectionEnd_ << ") must be greater than protection start " << protectionStart_);
52
53 // the maturity is the maximum of the protection end date and the last fee cashflow payment date
55 for (auto const& p : protectionFee) {
56 if (!p.empty())
57 maturity_ = std::max(maturity_, CashFlows::maturityDate(p));
58 }
59
60 // the underlying maturity is the maturity over the underlying legs
61 underlyingMaturity_ = Date::minDate();
62 for (auto const& l : underlying)
63 underlyingMaturity_ = std::max(underlyingMaturity_, CashFlows::maturityDate(l));
64
65 for (auto const& l : underlying) {
66 for (auto const& c : l) {
67 registerWith(c);
68 if (auto lazy = QuantLib::ext::dynamic_pointer_cast<LazyObject>(c))
69 lazy->alwaysForwardNotifications();
70 }
71 }
72
73 for (auto const& l : protectionFee) {
74 for (auto const& c : l) {
75 registerWith(c);
76 if (auto lazy = QuantLib::ext::dynamic_pointer_cast<LazyObject>(c))
77 lazy->alwaysForwardNotifications();
78 }
79 }
80}
const std::vector< std::string > protectionFeeCcys_
const std::vector< Leg > & underlying() const
Inspectors.
const QuantLib::ext::shared_ptr< Exercise > exercise_
const std::vector< std::string > underlyingCcys_
const std::vector< QuantLib::ext::shared_ptr< CashFlow > > premium_
const std::vector< std::string > & protectionFeeCcys() const
const QuantLib::ext::shared_ptr< Exercise > & exercise() const
const std::vector< std::string > & underlyingCcys() const
const std::vector< bool > & underlyingPayer() const
const std::vector< Leg > & protectionFee() const
Filter close_enough(const RandomVariable &x, const RandomVariable &y)
+ Here is the call graph for this function:

Member Function Documentation

◆ isExpired()

bool isExpired ( ) const
override

Instrument interface.

Definition at line 82 of file riskparticipationagreement.cpp.

82{ return detail::simple_event(maturity()).hasOccurred(); }
+ Here is the call graph for this function:

◆ underlying()

const std::vector< Leg > & underlying ( ) const

Inspectors.

Definition at line 52 of file riskparticipationagreement.hpp.

52{ return underlying_; }
+ Here is the caller graph for this function:

◆ underlyingPayer()

const std::vector< bool > & underlyingPayer ( ) const

Definition at line 53 of file riskparticipationagreement.hpp.

53{ return underlyingPayer_; }

◆ underlyingCcys()

const std::vector< std::string > & underlyingCcys ( ) const

Definition at line 54 of file riskparticipationagreement.hpp.

54{ return underlyingCcys_; }

◆ protectionFee()

const std::vector< Leg > & protectionFee ( ) const

Definition at line 55 of file riskparticipationagreement.hpp.

55{ return protectionFee_; }
+ Here is the caller graph for this function:

◆ protectionFeePayer()

bool protectionFeePayer ( ) const

Definition at line 56 of file riskparticipationagreement.hpp.

56{ return protectionFeePayer_; }

◆ protectionFeeCcys()

const std::vector< std::string > & protectionFeeCcys ( ) const

Definition at line 57 of file riskparticipationagreement.hpp.

57{ return protectionFeeCcys_; }

◆ participationRate()

Real participationRate ( ) const

Definition at line 58 of file riskparticipationagreement.hpp.

58{ return participationRate_; }

◆ protectionStart()

const Date & protectionStart ( ) const

Definition at line 59 of file riskparticipationagreement.hpp.

59{ return protectionStart_; }

◆ protectionEnd()

const Date & protectionEnd ( ) const

Definition at line 60 of file riskparticipationagreement.hpp.

60{ return protectionEnd_; }

◆ settlesAccrual()

bool settlesAccrual ( ) const

Definition at line 61 of file riskparticipationagreement.hpp.

61{ return settlesAccrual_; }

◆ fixedRecoveryRate()

Real fixedRecoveryRate ( ) const

Definition at line 62 of file riskparticipationagreement.hpp.

62{ return fixedRecoveryRate_; }

◆ exercise()

const QuantLib::ext::shared_ptr< Exercise > & exercise ( ) const

Definition at line 63 of file riskparticipationagreement.hpp.

63{ return exercise_; }

◆ nakedOption()

const bool nakedOption ( ) const

Definition at line 64 of file riskparticipationagreement.hpp.

64{ return nakedOption_; }

◆ maturity()

const Date & maturity ( ) const

Definition at line 66 of file riskparticipationagreement.hpp.

66{ return maturity_; }
+ Here is the caller graph for this function:

◆ underlyingMaturity()

const Date & underlyingMaturity ( ) const

Definition at line 67 of file riskparticipationagreement.hpp.

67{ return underlyingMaturity_; }

◆ setupArguments()

void setupArguments ( QuantLib::PricingEngine::arguments args) const
overrideprivate

Definition at line 92 of file riskparticipationagreement.cpp.

92 {
93 RiskParticipationAgreement::arguments* arguments = dynamic_cast<RiskParticipationAgreement::arguments*>(args);
94 QL_REQUIRE(arguments, "RiskParticipationAgreement::setupArguments(): wrong argument type");
95 arguments->underlying = underlying_;
96 arguments->underlyingPayer = underlyingPayer_;
97 arguments->underlyingCcys = underlyingCcys_;
98 arguments->protectionFee = protectionFee_;
99 arguments->protectionFeePayer = protectionFeePayer_;
100 arguments->protectionFeeCcys = protectionFeeCcys_;
101 arguments->participationRate = participationRate_;
102 arguments->protectionStart = protectionStart_;
103 arguments->protectionEnd = protectionEnd_;
104 arguments->underlyingMaturity = underlyingMaturity_;
105 arguments->settlesAccrual = settlesAccrual_;
106 arguments->fixedRecoveryRate = fixedRecoveryRate_;
107 arguments->exercise = exercise_;
108 arguments->exerciseIsLong = exerciseIsLong_;
109 arguments->premium = premium_;
110 arguments->nakedOption = nakedOption_;
111 // provide previously computed option representation, if this is available
112 arguments->optionRepresentation = optionRepresentation_;
113 arguments->optionMultiplier = optionMultiplier_;
114 arguments->optionRepresentationPeriods = optionRepresentationPeriods_;
115 arguments->optionRepresentationReferenceDate = optionRepresentationReferenceDate_;
116}
std::vector< QuantLib::ext::shared_ptr< Instrument > > optionRepresentation_
std::vector< std::tuple< Date, Date, Date > > optionRepresentationPeriods_

◆ setupExpired()

void setupExpired ( ) const
overrideprivate

Definition at line 84 of file riskparticipationagreement.cpp.

84 {
85 Instrument::setupExpired();
87 optionMultiplier_.clear();
90}

◆ fetchResults()

void fetchResults ( const QuantLib::PricingEngine::results *  ) const
overrideprivate

Definition at line 118 of file riskparticipationagreement.cpp.

118 {
119 Instrument::fetchResults(r);
120 const RiskParticipationAgreement::results* results = dynamic_cast<const RiskParticipationAgreement::results*>(r);
121 QL_REQUIRE(results, "RiskParticipationAgreement::fetchResults(): wrong result type");
122 // might be empty / null if engine does not provide these
123 optionRepresentation_ = results->optionRepresentation;
124 optionMultiplier_ = results->optionMultiplier;
125 optionRepresentationPeriods_ = results->optionRepresentationPeriods;
126 optionRepresentationReferenceDate_ = results->optionRepresentationReferenceDate;
127}

Member Data Documentation

◆ underlying_

const std::vector<Leg> underlying_
private

Definition at line 74 of file riskparticipationagreement.hpp.

◆ underlyingPayer_

const std::vector<bool> underlyingPayer_
private

Definition at line 75 of file riskparticipationagreement.hpp.

◆ underlyingCcys_

const std::vector<std::string> underlyingCcys_
private

Definition at line 76 of file riskparticipationagreement.hpp.

◆ protectionFee_

const std::vector<Leg> protectionFee_
private

Definition at line 77 of file riskparticipationagreement.hpp.

◆ protectionFeePayer_

const bool protectionFeePayer_
private

Definition at line 78 of file riskparticipationagreement.hpp.

◆ protectionFeeCcys_

const std::vector<std::string> protectionFeeCcys_
private

Definition at line 79 of file riskparticipationagreement.hpp.

◆ participationRate_

const Real participationRate_
private

Definition at line 80 of file riskparticipationagreement.hpp.

◆ protectionStart_

const Date protectionStart_
private

Definition at line 81 of file riskparticipationagreement.hpp.

◆ protectionEnd_

const Date protectionEnd_
private

Definition at line 81 of file riskparticipationagreement.hpp.

◆ settlesAccrual_

const bool settlesAccrual_
private

Definition at line 82 of file riskparticipationagreement.hpp.

◆ fixedRecoveryRate_

const Real fixedRecoveryRate_
private

Definition at line 83 of file riskparticipationagreement.hpp.

◆ exercise_

const QuantLib::ext::shared_ptr<Exercise> exercise_
private

Definition at line 84 of file riskparticipationagreement.hpp.

◆ exerciseIsLong_

const bool exerciseIsLong_
private

Definition at line 85 of file riskparticipationagreement.hpp.

◆ premium_

const std::vector<QuantLib::ext::shared_ptr<CashFlow> > premium_
private

Definition at line 86 of file riskparticipationagreement.hpp.

◆ nakedOption_

const bool nakedOption_
private

Definition at line 87 of file riskparticipationagreement.hpp.

◆ maturity_

Date maturity_
private

Definition at line 90 of file riskparticipationagreement.hpp.

◆ underlyingMaturity_

Date underlyingMaturity_
private

Definition at line 90 of file riskparticipationagreement.hpp.

◆ optionRepresentationReferenceDate_

Date optionRepresentationReferenceDate_
mutableprivate

Definition at line 93 of file riskparticipationagreement.hpp.

◆ optionRepresentationPeriods_

std::vector<std::tuple<Date, Date, Date> > optionRepresentationPeriods_
mutableprivate

Definition at line 94 of file riskparticipationagreement.hpp.

◆ optionRepresentation_

std::vector<QuantLib::ext::shared_ptr<Instrument> > optionRepresentation_
mutableprivate

Definition at line 95 of file riskparticipationagreement.hpp.

◆ optionMultiplier_

std::vector<Real> optionMultiplier_
mutableprivate

Definition at line 96 of file riskparticipationagreement.hpp.