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

Wrapper class for holding Bond Spread and recovery rate quotes. More...

#include <ored/marketdata/security.hpp>

+ Collaboration diagram for Security:

Public Member Functions

 Security (const Date &asof, SecuritySpec spec, const Loader &loader, const CurveConfigurations &curveConfigs)
 Constructor. More...
 
Handle< Quote > spread () const
 Inspector. More...
 
Handle< Quote > price () const
 
Handle< Quote > recoveryRate () const
 
Handle< Quote > cpr () const
 

Private Attributes

Handle< Quote > spread_
 
Handle< Quote > price_
 
Handle< Quote > recoveryRate_
 
Handle< Quote > cpr_
 

Detailed Description

Wrapper class for holding Bond Spread and recovery rate quotes.

Definition at line 39 of file security.hpp.

Constructor & Destructor Documentation

◆ Security()

Security ( const Date &  asof,
SecuritySpec  spec,
const Loader loader,
const CurveConfigurations curveConfigs 
)

Constructor.

Definition at line 31 of file security.cpp.

31 {
32
33 try {
34 const QuantLib::ext::shared_ptr<SecurityConfig>& config = curveConfigs.securityConfig(spec.securityID());
35
36 string spreadQuote = config->spreadQuote();
37 if (spreadQuote != "" && loader.has(spreadQuote, asof)) {
38 QuantLib::ext::shared_ptr<SecuritySpreadQuote> q =
39 QuantLib::ext::dynamic_pointer_cast<SecuritySpreadQuote>(loader.get(spreadQuote, asof));
40 QL_REQUIRE(q, "Failed to cast " << spreadQuote << " to SecuritySpreadQuote");
41 spread_ = q->quote();
42 }
43
44 // get recovery quote
45 string recoveryQuote = config->recoveryRatesQuote();
46 if (recoveryQuote != "" && loader.has(recoveryQuote, asof)) {
47 QuantLib::ext::shared_ptr<RecoveryRateQuote> q =
48 QuantLib::ext::dynamic_pointer_cast<RecoveryRateQuote>(loader.get(recoveryQuote, asof));
49 QL_REQUIRE(q, "Failed to cast " << recoveryQuote << " to RecoveryRateQuote");
50 recoveryRate_ = q->quote();
51 }
52
53 // get cpr quote
54 string cprQuote = config->cprQuote();
55 if (cprQuote != "" && loader.has(cprQuote,asof)) {
56 QuantLib::ext::shared_ptr<CPRQuote> q = QuantLib::ext::dynamic_pointer_cast<CPRQuote>(loader.get(cprQuote, asof));
57 QL_REQUIRE(q, "Failed to cast " << cprQuote << " to CPRQuote");
58 cpr_ = q->quote();
59 }
60
61 // get price quote
62 string priceQuote = config->priceQuote();
63 if (priceQuote != "" && loader.has(priceQuote,asof)) {
64 QuantLib::ext::shared_ptr<BondPriceQuote> q =
65 QuantLib::ext::dynamic_pointer_cast<BondPriceQuote>(loader.get(priceQuote, asof));
66 QL_REQUIRE(q, "Failed to cast " << priceQuote << " to BondPriceQuote");
67 price_ = q->quote();
68 }
69
70 } catch (std::exception& e) {
71 QL_FAIL("Security building failed for curve " << spec.curveConfigID() << " on date " << io::iso_date(asof)
72 << ": " << e.what());
73 } catch (...) {
74 QL_FAIL("Security building failed: unknown error");
75 }
76
77 return;
78}
Handle< Quote > spread_
Definition: security.hpp:51
Handle< Quote > price_
Definition: security.hpp:52
Handle< Quote > cpr_
Definition: security.hpp:54
Handle< Quote > recoveryRate_
Definition: security.hpp:53
vector< string > curveConfigs
+ Here is the call graph for this function:

Member Function Documentation

◆ spread()

Handle< Quote > spread ( ) const

Inspector.

Definition at line 45 of file security.hpp.

45{ return spread_; }

◆ price()

Handle< Quote > price ( ) const

Definition at line 46 of file security.hpp.

46{ return price_; }

◆ recoveryRate()

Handle< Quote > recoveryRate ( ) const

Definition at line 47 of file security.hpp.

47{ return recoveryRate_; }

◆ cpr()

Handle< Quote > cpr ( ) const

Definition at line 48 of file security.hpp.

48{ return cpr_; }

Member Data Documentation

◆ spread_

Handle<Quote> spread_
private

Definition at line 51 of file security.hpp.

◆ price_

Handle<Quote> price_
private

Definition at line 52 of file security.hpp.

◆ recoveryRate_

Handle<Quote> recoveryRate_
private

Definition at line 53 of file security.hpp.

◆ cpr_

Handle<Quote> cpr_
private

Definition at line 54 of file security.hpp.