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

Deposit Instrument. More...

#include <qle/instruments/deposit.hpp>

+ Inheritance diagram for Deposit:
+ Collaboration diagram for Deposit:

Classes

class  arguments
 
class  engine
 
class  results
 

Public Member Functions

 Deposit (const Real nominal, const Rate rate, const Period &tenor, const Natural fixingDays, const Calendar &calendar, const BusinessDayConvention convention, const bool endOfMonth, const DayCounter &dayCounter, const Date &tradeDate, const bool isLong=true, const Period forwardStart=0 *Days)
 
Additional interface
Date fixingDate () const
 
Date startDate () const
 
Date maturityDate () const
 
Real fairRate () const
 
const Leg & leg () const
 

Instrument interface

Date fixingDate_
 
Date startDate_
 
Date maturityDate_
 
QuantLib::ext::shared_ptr< IborIndex > index_
 
Leg leg_
 
Real fairRate_
 
bool isExpired () const override
 
void setupArguments (PricingEngine::arguments *) const override
 
void fetchResults (const PricingEngine::results *) const override
 
void setupExpired () const override
 

Detailed Description

Deposit Instrument.

This class holds the term sheet data for a Deposit Instrument.

\ingroup instruments

Definition at line 43 of file deposit.hpp.

Constructor & Destructor Documentation

◆ Deposit()

Deposit ( const Real  nominal,
const Rate  rate,
const Period &  tenor,
const Natural  fixingDays,
const Calendar &  calendar,
const BusinessDayConvention  convention,
const bool  endOfMonth,
const DayCounter &  dayCounter,
const Date &  tradeDate,
const bool  isLong = true,
const Period  forwardStart = 0 * Days 
)

Definition at line 30 of file deposit.cpp.

32 {
33
34 leg_.resize(3);
35 index_ = QuantLib::ext::make_shared<IborIndex>("deposit-helper-index", tenor, fixingDays, Currency(), calendar, convention,
36 endOfMonth, dayCounter);
37 // move to next good day
38 Date referenceDate = calendar.adjust(tradeDate);
39 startDate_ = index_->valueDate(referenceDate);
40 fixingDate_ = index_->fixingDate(startDate_);
41 maturityDate_ = index_->maturityDate(startDate_);
42 Real w = isLong ? 1.0 : -1.0;
43 leg_[0] = QuantLib::ext::make_shared<Redemption>(-w * nominal, startDate_);
44 leg_[1] =
45 QuantLib::ext::make_shared<FixedRateCoupon>(maturityDate_, w * nominal, rate, dayCounter, startDate_, maturityDate_);
46 leg_[2] = QuantLib::ext::make_shared<Redemption>(w * nominal, maturityDate_);
47}
QuantLib::ext::shared_ptr< IborIndex > index_
Definition: deposit.hpp:79

Member Function Documentation

◆ isExpired()

bool isExpired ( ) const
override

Definition at line 49 of file deposit.cpp.

49{ return detail::simple_event(maturityDate_).hasOccurred(); }

◆ setupArguments()

void setupArguments ( PricingEngine::arguments *  args) const
override

Definition at line 56 of file deposit.cpp.

56 {
57
58 Deposit::arguments* arguments = dynamic_cast<Deposit::arguments*>(args);
59 QL_REQUIRE(arguments, "wrong argument type in deposit");
60 arguments->leg = leg_;
61 arguments->index = index_;
62 arguments->maturityDate = maturityDate_;
63}

◆ fetchResults()

void fetchResults ( const PricingEngine::results *  r) const
override

Definition at line 65 of file deposit.cpp.

65 {
66
67 Instrument::fetchResults(r);
68 const Deposit::results* results = dynamic_cast<const Deposit::results*>(r);
69 QL_REQUIRE(results, "wrong result type");
70 fairRate_ = results->fairRate;
71}

◆ fixingDate()

Date fixingDate ( ) const

Definition at line 62 of file deposit.hpp.

62{ return fixingDate_; }

◆ startDate()

Date startDate ( ) const

Definition at line 63 of file deposit.hpp.

63{ return startDate_; }

◆ maturityDate()

Date maturityDate ( ) const

Definition at line 64 of file deposit.hpp.

64{ return maturityDate_; }

◆ fairRate()

Real fairRate ( ) const

Definition at line 65 of file deposit.hpp.

65 {
66 calculate();
67 QL_REQUIRE(fairRate_ != Null<Real>(), "Deposit::fairRate(): not provided");
68 return fairRate_;
69 }
+ Here is the caller graph for this function:

◆ leg()

const Leg & leg ( ) const

Definition at line 70 of file deposit.hpp.

70{ return leg_; }

◆ setupExpired()

void setupExpired ( ) const
overrideprivate

Definition at line 51 of file deposit.cpp.

51 {
52 Instrument::setupExpired();
53 fairRate_ = Null<Real>();
54}

Member Data Documentation

◆ fixingDate_

Date fixingDate_
private

Definition at line 78 of file deposit.hpp.

◆ startDate_

Date startDate_
private

Definition at line 78 of file deposit.hpp.

◆ maturityDate_

Date maturityDate_
private

Definition at line 78 of file deposit.hpp.

◆ index_

QuantLib::ext::shared_ptr<IborIndex> index_
private

Definition at line 79 of file deposit.hpp.

◆ leg_

Leg leg_
private

Definition at line 80 of file deposit.hpp.

◆ fairRate_

Real fairRate_
mutableprivate

Definition at line 82 of file deposit.hpp.