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

Equity Position instrument wrapper. More...

#include <ored/portfolio/bondposition.hpp>

+ Inheritance diagram for BondPositionInstrumentWrapper:
+ Collaboration diagram for BondPositionInstrumentWrapper:

Public Member Functions

 BondPositionInstrumentWrapper (const Real quantity, const std::vector< QuantLib::ext::shared_ptr< QuantLib::Bond > > &bonds, const std::vector< Real > &weights, const std::vector< Real > &bidAskAdjstments, const std::vector< Handle< Quote > > &fxConversion={})
 
void initialise (const std::vector< QuantLib::Date > &dates) override
 Initialise with the given date grid. More...
 
void reset () override
 reset is called every time a new path is about to be priced. More...
 
QuantLib::Real NPV () const override
 Return the NPV of this instrument. More...
 
const std::map< std::string, boost::any > & additionalResults () const override
 Return the additional results of this instrument. More...
 
void updateQlInstruments () override
 call update on enclosed instrument(s) More...
 
void setNpvCurrencyConversion (const Handle< Quote > &npvCcyConversion)
 
- Public Member Functions inherited from InstrumentWrapper
 InstrumentWrapper ()
 
 InstrumentWrapper (const QuantLib::ext::shared_ptr< QuantLib::Instrument > &inst, const Real multiplier=1.0, const std::vector< QuantLib::ext::shared_ptr< QuantLib::Instrument > > &additionalInstruments=std::vector< QuantLib::ext::shared_ptr< QuantLib::Instrument > >(), const std::vector< Real > &additionalMultipliers=std::vector< Real >())
 
virtual ~InstrumentWrapper ()
 
virtual void initialise (const std::vector< QuantLib::Date > &dates)=0
 Initialise with the given date grid. More...
 
virtual void reset ()=0
 reset is called every time a new path is about to be priced. More...
 
virtual QuantLib::Real NPV () const =0
 Return the NPV of this instrument. More...
 
virtual const std::map< std::string, boost::any > & additionalResults () const =0
 Return the additional results of this instrument. More...
 
QuantLib::Real additionalInstrumentsNPV () const
 
virtual void updateQlInstruments ()
 call update on enclosed instrument(s) More...
 
virtual bool isOption ()
 is it an Option? More...
 
QuantLib::ext::shared_ptr< QuantLib::Instrument > qlInstrument (const bool calculate=false) const
 Inspectors. More...
 
Real multiplier () const
 
virtual Real multiplier2 () const
 
const std::vector< QuantLib::ext::shared_ptr< QuantLib::Instrument > > & additionalInstruments () const
 
const std::vector< Real > & additionalMultipliers () const
 
boost::timer::nanosecond_type getCumulativePricingTime () const
 Get cumulative timing spent on pricing. More...
 
std::size_t getNumberOfPricings () const
 Get number of pricings. More...
 
void resetPricingStats () const
 Reset pricing statistics. More...
 

Private Attributes

Real quantity_
 
std::vector< QuantLib::ext::shared_ptr< QuantLib::Bond > > bonds_
 
std::vector< Real > weights_
 
std::vector< Real > bidAskAdjustments_
 
std::vector< Handle< Quote > > fxConversion_
 
Handle< Quote > npvCcyConversion_
 

Additional Inherited Members

- Protected Member Functions inherited from InstrumentWrapper
Real getTimedNPV (const QuantLib::ext::shared_ptr< QuantLib::Instrument > &instr) const
 
- Protected Attributes inherited from InstrumentWrapper
QuantLib::ext::shared_ptr< QuantLib::Instrument > instrument_
 
Real multiplier_
 
std::vector< QuantLib::ext::shared_ptr< QuantLib::Instrument > > additionalInstruments_
 
std::vector< Real > additionalMultipliers_
 
std::size_t numberOfPricings_ = 0
 
boost::timer::nanosecond_type cumulativePricingTime_ = 0
 

Detailed Description

Equity Position instrument wrapper.

Definition at line 91 of file bondposition.hpp.

Constructor & Destructor Documentation

◆ BondPositionInstrumentWrapper()

BondPositionInstrumentWrapper ( const Real  quantity,
const std::vector< QuantLib::ext::shared_ptr< QuantLib::Bond > > &  bonds,
const std::vector< Real > &  weights,
const std::vector< Real > &  bidAskAdjstments,
const std::vector< Handle< Quote > > &  fxConversion = {} 
)

Definition at line 146 of file bondposition.cpp.

149 : quantity_(quantity), bonds_(bonds), weights_(weights), bidAskAdjustments_(bidAskAdjustments),
150 fxConversion_(fxConversion) {
151 QL_REQUIRE(bonds_.size() == weights_.size(), "BondPositionInstrumentWrapper: bonds size ("
152 << bonds_.size() << ") must match weights size ("
153 << weights_.size() << ")");
154 QL_REQUIRE(bonds_.size() == bidAskAdjustments_.size(),
155 "BondPositionInstrumentWrapper: bonds size (" << bonds_.size() << ") must match bidAskAdjustment size ("
156 << weights_.size() << ")");
157 QL_REQUIRE(fxConversion_.empty() || fxConversion_.size() == bonds_.size(),
158 "BondPositionInstrumentWrapper: fxConversion size ("
159 << fxConversion_.size() << ") must match bonds size (" << bonds_.size() << ")");
160}
std::vector< Handle< Quote > > fxConversion_
std::vector< QuantLib::ext::shared_ptr< QuantLib::Bond > > bonds_

Member Function Documentation

◆ initialise()

void initialise ( const std::vector< QuantLib::Date > &  dates)
overridevirtual

Initialise with the given date grid.

Implements InstrumentWrapper.

Definition at line 96 of file bondposition.hpp.

96{}

◆ reset()

void reset ( )
overridevirtual

reset is called every time a new path is about to be priced.

For path dependent Wrappers, this is when internal state should be reset

Implements InstrumentWrapper.

Definition at line 97 of file bondposition.hpp.

97{}

◆ NPV()

Real NPV ( ) const
overridevirtual

Return the NPV of this instrument.

Implements InstrumentWrapper.

Definition at line 166 of file bondposition.cpp.

166 {
167 Real result = 0.0;
168 for (Size i = 0; i < bonds_.size(); ++i) {
169 // - divide by current notional, because weights are supposed to include any amortization factors
170 // - add bid ask adjustment to relative price in bond ccy
171 Real tmp = quantity_ * (bonds_[i]->NPV() / bonds_[i]->notional() + bidAskAdjustments_[i]);
172 if (!fxConversion_[i].empty()) {
173 tmp *= fxConversion_[i]->value();
174 }
175 result += tmp * weights_[i];
176 }
177 if (!npvCcyConversion_.empty()) {
178 result *= npvCcyConversion_->value();
179 }
180 return result;
181}

◆ additionalResults()

const std::map< std::string, boost::any > & additionalResults ( ) const
overridevirtual

Return the additional results of this instrument.

Implements InstrumentWrapper.

Definition at line 183 of file bondposition.cpp.

183 {
184 static std::map<std::string, boost::any> emptyMap;
185 return emptyMap;
186}

◆ updateQlInstruments()

void updateQlInstruments ( )
overridevirtual

call update on enclosed instrument(s)

Reimplemented from InstrumentWrapper.

Definition at line 100 of file bondposition.hpp.

100{}

◆ setNpvCurrencyConversion()

void setNpvCurrencyConversion ( const Handle< Quote > &  npvCcyConversion)

Definition at line 162 of file bondposition.cpp.

162 {
163 npvCcyConversion_ = npvCcyConversion;
164}

Member Data Documentation

◆ quantity_

Real quantity_
private

Definition at line 105 of file bondposition.hpp.

◆ bonds_

std::vector<QuantLib::ext::shared_ptr<QuantLib::Bond> > bonds_
private

Definition at line 106 of file bondposition.hpp.

◆ weights_

std::vector<Real> weights_
private

Definition at line 107 of file bondposition.hpp.

◆ bidAskAdjustments_

std::vector<Real> bidAskAdjustments_
private

Definition at line 108 of file bondposition.hpp.

◆ fxConversion_

std::vector<Handle<Quote> > fxConversion_
private

Definition at line 109 of file bondposition.hpp.

◆ npvCcyConversion_

Handle<Quote> npvCcyConversion_
private

Definition at line 110 of file bondposition.hpp.