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

Serializable ForwardRateAgreement. More...

#include <ored/portfolio/forwardrateagreement.hpp>

+ Inheritance diagram for ForwardRateAgreement:
+ Collaboration diagram for ForwardRateAgreement:

Public Member Functions

 ForwardRateAgreement ()
 
 ForwardRateAgreement (Envelope &env, string longShort, string currency, string startDate, string endDate, string index, double strike, double amount)
 
void build (const QuantLib::ext::shared_ptr< EngineFactory > &engineFactory) override
 Build QuantLib/QuantExt instrument, link pricing engine. More...
 
virtual void fromXML (XMLNode *node) override
 
virtual XMLNodetoXML (XMLDocument &doc) const override
 
const string & index () const
 
- Public Member Functions inherited from Swap
 Swap (const string swapType="Swap")
 Default constructor. More...
 
 Swap (const Envelope &env, const string swapType="Swap")
 
 Swap (const Envelope &env, const vector< LegData > &legData, const string swapType="Swap", const std::string settlement="Physical")
 Constructor with vector of LegData. More...
 
 Swap (const Envelope &env, const LegData &leg0, const LegData &leg1, const string swapType="Swap", const std::string settlement="Physical")
 Constructor with two legs. More...
 
virtual void build (const QuantLib::ext::shared_ptr< EngineFactory > &) override
 Build QuantLib/QuantExt instrument, link pricing engine. More...
 
virtual void setIsdaTaxonomyFields ()
 
QuantLib::Real notional () const override
 Return the current notional in npvCurrency. See individual sub-classes for the precise definition. More...
 
std::string notionalCurrency () const override
 
std::map< AssetClass, std::set< std::string > > underlyingIndices (const QuantLib::ext::shared_ptr< ReferenceDataManager > &referenceDataManager=nullptr) const override
 Add underlying index names. More...
 
const string & settlement () const
 Settlement Type can be set to "Cash" for NDF. Default value is "Physical". More...
 
const vector< LegData > & legData () const
 
const std::map< std::string, boost::any > & additionalData () const override
 returns all additional data returned by the trade once built More...
 
- Public Member Functions inherited from Trade
 Trade ()
 Default constructor. More...
 
 Trade (const string &tradeType, const Envelope &env=Envelope(), const TradeActions &ta=TradeActions())
 Base class constructor. More...
 
virtual ~Trade ()
 Default destructor. More...
 
virtual void build (const QuantLib::ext::shared_ptr< EngineFactory > &)=0
 
virtual std::map< std::string, RequiredFixings::FixingDatesfixings (const QuantLib::Date &settlementDate=QuantLib::Date()) const
 
const RequiredFixingsrequiredFixings () const
 
virtual std::map< AssetClass, std::set< std::string > > underlyingIndices (const QuantLib::ext::shared_ptr< ReferenceDataManager > &referenceDataManager=nullptr) const
 
void reset ()
 Reset trade, clear all base class data. This does not reset accumulated timings for this trade. More...
 
void resetPricingStats (const std::size_t numberOfPricings=0, const boost::timer::nanosecond_type cumulativePricingTime=0)
 Reset accumulated timings to given values. More...
 
string & id ()
 Set the trade id. More...
 
void setEnvelope (const Envelope &envelope)
 Set the envelope with counterparty and portfolio info. More...
 
void setAdditionalData (const std::map< std::string, boost::any > &additionalData)
 
TradeActionstradeActions ()
 Set the trade actions. More...
 
const string & id () const
 
const string & tradeType () const
 
const Envelopeenvelope () const
 
const set< string > & portfolioIds () const
 
const TradeActionstradeActions () const
 
const QuantLib::ext::shared_ptr< InstrumentWrapper > & instrument () const
 
const std::vector< QuantLib::Leg > & legs () const
 
const std::vector< string > & legCurrencies () const
 
const std::vector< bool > & legPayers () const
 
const string & npvCurrency () const
 
const Date & maturity () const
 
virtual bool isExpired (const Date &d)
 
const string & issuer () const
 
template<typename T >
additionalDatum (const std::string &tag) const
 returns any additional datum. More...
 
const std::string & sensitivityTemplate () const
 
void validate () const
 Utility to validate that everything that needs to be set in this base class is actually set. More...
 
virtual bool hasCashflows () const
 
boost::timer::nanosecond_type getCumulativePricingTime () const
 Get cumulative timing spent on pricing. More...
 
std::size_t getNumberOfPricings () const
 Get number of pricings. More...
 
- Public Member Functions inherited from XMLSerializable
virtual ~XMLSerializable ()
 
virtual void fromXML (XMLNode *node)=0
 
virtual XMLNodetoXML (XMLDocument &doc) const =0
 
void fromFile (const std::string &filename)
 
void toFile (const std::string &filename) const
 
void fromXMLString (const std::string &xml)
 Parse from XML string. More...
 
std::string toXMLString () const
 Parse from XML string. More...
 

Private Attributes

string longShort_
 
string currency_
 
string startDate_
 
string endDate_
 
string index_
 
double strike_
 
double amount_
 

Additional Inherited Members

- Protected Member Functions inherited from Swap
virtual QuantLib::ext::shared_ptr< LegDatacreateLegData () const
 
- Protected Member Functions inherited from Trade
Date addPremiums (std::vector< QuantLib::ext::shared_ptr< Instrument > > &instruments, std::vector< Real > &multipliers, const Real tradeMultiplier, const PremiumData &premiumData, const Real premiumMultiplier, const Currency &tradeCurrency, const QuantLib::ext::shared_ptr< EngineFactory > &factory, const string &configuration)
 
void setLegBasedAdditionalData (const Size legNo, Size resultLegId=Null< Size >()) const
 
void setSensitivityTemplate (const EngineBuilder &builder)
 
void setSensitivityTemplate (const std::string &id)
 
- Protected Attributes inherited from Swap
vector< LegDatalegData_
 
string settlement_
 
bool isXCCY_ = false
 
- Protected Attributes inherited from Trade
string tradeType_
 
QuantLib::ext::shared_ptr< InstrumentWrapperinstrument_
 
std::vector< QuantLib::Leg > legs_
 
std::vector< string > legCurrencies_
 
std::vector< boollegPayers_
 
string npvCurrency_
 
QuantLib::Real notional_
 
string notionalCurrency_
 
Date maturity_
 
string issuer_
 
string sensitivityTemplate_
 
bool sensitivityTemplateSet_ = false
 
std::size_t savedNumberOfPricings_ = 0
 
boost::timer::nanosecond_type savedCumulativePricingTime_ = 0
 
RequiredFixings requiredFixings_
 
std::map< std::string, boost::any > additionalData_
 

Detailed Description

Serializable ForwardRateAgreement.

Definition at line 36 of file forwardrateagreement.hpp.

Constructor & Destructor Documentation

◆ ForwardRateAgreement() [1/2]

Definition at line 38 of file forwardrateagreement.hpp.

38: ore::data::Swap("ForwardRateAgreement") {}
Serializable Swap, Single and Cross Currency.
Definition: swap.hpp:36

◆ ForwardRateAgreement() [2/2]

ForwardRateAgreement ( Envelope env,
string  longShort,
string  currency,
string  startDate,
string  endDate,
string  index,
double  strike,
double  amount 
)

Member Function Documentation

◆ build()

void build ( const QuantLib::ext::shared_ptr< EngineFactory > &  engineFactory)
overridevirtual

Build QuantLib/QuantExt instrument, link pricing engine.

Reimplemented from Swap.

Definition at line 31 of file forwardrateagreement.cpp.

31 {
32
33 // ISDA taxonomy
34 additionalData_["isdaAssetClass"] = string("Interest Rate");
35 additionalData_["isdaBaseProduct"] = string("FRA");
36 additionalData_["isdaSubProduct"] = string("");
37 additionalData_["isdaTransaction"] = string("");
38
39 const QuantLib::ext::shared_ptr<Market> market = engineFactory->market();
40
41 Date startDate = parseDate(startDate_);
42 Date endDate = parseDate(endDate_);
43 Position::Type positionType = parsePositionType(longShort_);
44 auto index = market->iborIndex(index_);
45
46 QuantLib::ext::shared_ptr<FloatingRateCoupon> cpn;
47 if (auto overnightIndex = QuantLib::ext::dynamic_pointer_cast<QuantLib::OvernightIndex>(*index)) {
48 cpn = QuantLib::ext::make_shared<QuantExt::OvernightIndexedCoupon>(endDate, amount_, startDate, endDate, overnightIndex,
49 1.0, -strike_);
50 cpn->setPricer(QuantLib::ext::make_shared<QuantExt::OvernightIndexedCouponPricer>());
51 } else {
52 bool useIndexedCoupon = true;
53 cpn = QuantLib::ext::make_shared<QuantExt::IborFraCoupon>(startDate, endDate, amount_, *index, strike_);
54 cpn->setPricer(QuantLib::ext::make_shared<BlackIborCouponPricer>(
55 Handle<OptionletVolatilityStructure>(), BlackIborCouponPricer::TimingAdjustment::Black76,
56 Handle<Quote>(ext::shared_ptr<Quote>(new SimpleQuote(1.0))), useIndexedCoupon));
57 }
58 legs_.push_back({cpn});
59
60 Currency npvCcy = parseCurrency(currency_);
61 legCurrencies_.push_back(npvCcy.code());
62 legPayers_ = vector<bool>(1, positionType == Position::Type::Short);
63 isXCCY_ = false;
65 npvCurrency_ = npvCcy.code();
66 notionalCurrency_ = npvCcy.code();
67
68 QuantLib::ext::shared_ptr<QuantLib::Swap> swap(new QuantLib::Swap(legs_, legPayers_));
69 QuantLib::ext::shared_ptr<EngineBuilder> builder = engineFactory->builder("Swap");
70 QuantLib::ext::shared_ptr<SwapEngineBuilderBase> swapBuilder = QuantLib::ext::dynamic_pointer_cast<SwapEngineBuilderBase>(builder);
71 QL_REQUIRE(swapBuilder, "No Builder found for Swap " << id());
72 swap->setPricingEngine(swapBuilder->engine(npvCcy, std::string(), std::string()));
73 setSensitivityTemplate(*swapBuilder);
74 instrument_.reset(new VanillaInstrument(swap));
75 maturity_ = endDate;
76}
bool isXCCY_
Definition: swap.hpp:84
string npvCurrency_
Definition: trade.hpp:201
std::vector< bool > legPayers_
Definition: trade.hpp:200
std::vector< string > legCurrencies_
Definition: trade.hpp:199
std::vector< QuantLib::Leg > legs_
Definition: trade.hpp:198
QuantLib::Real notional_
Definition: trade.hpp:202
void setSensitivityTemplate(const EngineBuilder &builder)
Definition: trade.cpp:295
QuantLib::ext::shared_ptr< InstrumentWrapper > instrument_
Definition: trade.hpp:197
string notionalCurrency_
Definition: trade.hpp:203
std::map< std::string, boost::any > additionalData_
Definition: trade.hpp:224
Date parseDate(const string &s)
Convert std::string to QuantLib::Date.
Definition: parsers.cpp:51
Currency parseCurrency(const string &s)
Convert text to QuantLib::Currency.
Definition: parsers.cpp:290
Position::Type parsePositionType(const std::string &s)
Convert text to QuantLib::Position::Type.
Definition: parsers.cpp:404
+ Here is the call graph for this function:

◆ fromXML()

void fromXML ( XMLNode node)
overridevirtual

Reimplemented from Swap.

Definition at line 78 of file forwardrateagreement.cpp.

78 {
79 Trade::fromXML(node);
80 XMLNode* fNode = XMLUtils::getChildNode(node, "ForwardRateAgreementData");
81 startDate_ = XMLUtils::getChildValue(fNode, "StartDate", true);
82 endDate_ = XMLUtils::getChildValue(fNode, "EndDate", true);
83 currency_ = XMLUtils::getChildValue(fNode, "Currency", true);
84 index_ = XMLUtils::getChildValue(fNode, "Index", true);
85 longShort_ = XMLUtils::getChildValue(fNode, "LongShort", true);
86 strike_ = XMLUtils::getChildValueAsDouble(fNode, "Strike", true);
87 amount_ = XMLUtils::getChildValueAsDouble(fNode, "Notional", true);
88}
virtual void fromXML(XMLNode *node) override
Definition: trade.cpp:34
static Real getChildValueAsDouble(XMLNode *node, const string &name, bool mandatory=false, double defaultValue=0.0)
Definition: xmlutils.cpp:286
static string getChildValue(XMLNode *node, const string &name, bool mandatory=false, const string &defaultValue=string())
Definition: xmlutils.cpp:277
static XMLNode * getChildNode(XMLNode *n, const string &name="")
Definition: xmlutils.cpp:387
rapidxml::xml_node< char > XMLNode
Definition: xmlutils.hpp:60
+ Here is the call graph for this function:

◆ toXML()

XMLNode * toXML ( XMLDocument doc) const
overridevirtual

Reimplemented from Swap.

Definition at line 90 of file forwardrateagreement.cpp.

90 {
91 XMLNode* node = Trade::toXML(doc);
92 XMLNode* fNode = doc.allocNode("ForwardRateAgreementData");
93 XMLUtils::appendNode(node, fNode);
94 XMLUtils::addChild(doc, fNode, "StartDate", startDate_);
95 XMLUtils::addChild(doc, fNode, "EndDate", endDate_);
96 XMLUtils::addChild(doc, fNode, "Currency", currency_);
97 XMLUtils::addChild(doc, fNode, "Index", index_);
98 XMLUtils::addChild(doc, fNode, "LongShort", longShort_);
99 XMLUtils::addChild(doc, fNode, "Strike", strike_);
100 XMLUtils::addChild(doc, fNode, "Notional", amount_);
101 return node;
102}
virtual XMLNode * toXML(XMLDocument &doc) const override
Definition: trade.cpp:46
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
Definition: xmlutils.cpp:181
static void appendNode(XMLNode *parent, XMLNode *child)
Definition: xmlutils.cpp:406
+ Here is the call graph for this function:

◆ index()

const string & index ( ) const

Definition at line 48 of file forwardrateagreement.hpp.

48{ return index_; }
+ Here is the caller graph for this function:

Member Data Documentation

◆ longShort_

string longShort_
private

Definition at line 51 of file forwardrateagreement.hpp.

◆ currency_

string currency_
private

Definition at line 52 of file forwardrateagreement.hpp.

◆ startDate_

string startDate_
private

Definition at line 53 of file forwardrateagreement.hpp.

◆ endDate_

string endDate_
private

Definition at line 54 of file forwardrateagreement.hpp.

◆ index_

string index_
private

Definition at line 55 of file forwardrateagreement.hpp.

◆ strike_

double strike_
private

Definition at line 56 of file forwardrateagreement.hpp.

◆ amount_

double amount_
private

Definition at line 57 of file forwardrateagreement.hpp.