Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
List of all members
TenorBasisSwapConvention Class Reference

Container for storing Tenor Basis Swap conventions. More...

#include <ored/configuration/conventions.hpp>

+ Inheritance diagram for TenorBasisSwapConvention:
+ Collaboration diagram for TenorBasisSwapConvention:

Public Member Functions

Constructors
 TenorBasisSwapConvention ()
 Default constructor. More...
 
 TenorBasisSwapConvention (const string &id, const string &payIndex, const string &receiveIndex, const string &receiveFrequency="", const string &payFrequency="", const string &spreadOnRec="", const string &includeSpread="", const string &subPeriodsCouponType="")
 Detailed constructor. More...
 
Inspectors
QuantLib::ext::shared_ptr< IborIndexpayIndex () const
 
QuantLib::ext::shared_ptr< IborIndexreceiveIndex () const
 
const string & payIndexName () const
 
const string & receiveIndexName () const
 
const Period & receiveFrequency () const
 
const Period & payFrequency () const
 
bool spreadOnRec () const
 
bool includeSpread () const
 
SubPeriodsCoupon1::Type subPeriodsCouponType () const
 
- Public Member Functions inherited from Convention
virtual ~Convention ()
 Default destructor. More...
 
const string & id () const
 
Type type () const
 
- 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...
 

Serialisation

Period receiveFrequency_
 
Period payFrequency_
 
bool spreadOnRec_
 
bool includeSpread_
 
SubPeriodsCoupon1::Type subPeriodsCouponType_
 
string strPayIndex_
 
string strReceiveIndex_
 
string strReceiveFrequency_
 
string strPayFrequency_
 
string strSpreadOnRec_
 
string strIncludeSpread_
 
string strSubPeriodsCouponType_
 
virtual void fromXML (XMLNode *node) override
 
virtual XMLNodetoXML (XMLDocument &doc) const override
 
virtual void build () override
 

Additional Inherited Members

- Public Types inherited from Convention
enum class  Type {
  Zero , Deposit , Future , FRA ,
  OIS , Swap , AverageOIS , TenorBasisSwap ,
  TenorBasisTwoSwap , BMABasisSwap , FX , CrossCcyBasis ,
  CrossCcyFixFloat , CDS , IborIndex , OvernightIndex ,
  SwapIndex , ZeroInflationIndex , InflationSwap , SecuritySpread ,
  CMSSpreadOption , CommodityForward , CommodityFuture , FxOption ,
  BondYield
}
 Supported convention types. More...
 
- Protected Member Functions inherited from Convention
 Convention ()
 
 Convention (const string &id, Type type)
 
- Protected Attributes inherited from Convention
Type type_
 
string id_
 

Detailed Description

Container for storing Tenor Basis Swap conventions.

Definition at line 634 of file conventions.hpp.

Constructor & Destructor Documentation

◆ TenorBasisSwapConvention() [1/2]

Default constructor.

Definition at line 639 of file conventions.hpp.

639{}

◆ TenorBasisSwapConvention() [2/2]

TenorBasisSwapConvention ( const string &  id,
const string &  payIndex,
const string &  receiveIndex,
const string &  receiveFrequency = "",
const string &  payFrequency = "",
const string &  spreadOnRec = "",
const string &  includeSpread = "",
const string &  subPeriodsCouponType = "" 
)

Detailed constructor.

Definition at line 611 of file conventions.cpp.

618 build();
619}
SubPeriodsCoupon1::Type subPeriodsCouponType() const
const Period & payFrequency() const
QuantLib::ext::shared_ptr< IborIndex > receiveIndex() const
virtual void build() override
QuantLib::ext::shared_ptr< IborIndex > payIndex() const
const Period & receiveFrequency() const
+ Here is the call graph for this function:

Member Function Documentation

◆ payIndex()

QuantLib::ext::shared_ptr< IborIndex > payIndex ( ) const

Definition at line 736 of file conventions.cpp.

736{ return parseIborIndex(strPayIndex_); }
QuantLib::ext::shared_ptr< IborIndex > parseIborIndex(const string &s, const Handle< YieldTermStructure > &h)
Convert std::string to QuantLib::IborIndex.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ receiveIndex()

QuantLib::ext::shared_ptr< IborIndex > receiveIndex ( ) const

Definition at line 737 of file conventions.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ payIndexName()

const string & payIndexName ( ) const

Definition at line 651 of file conventions.hpp.

651{ return strPayIndex_; }

◆ receiveIndexName()

const string & receiveIndexName ( ) const

Definition at line 652 of file conventions.hpp.

652{ return strReceiveIndex_; }

◆ receiveFrequency()

const Period & receiveFrequency ( ) const

Definition at line 653 of file conventions.hpp.

◆ payFrequency()

const Period & payFrequency ( ) const

Definition at line 654 of file conventions.hpp.

◆ spreadOnRec()

bool spreadOnRec ( ) const

Definition at line 655 of file conventions.hpp.

◆ includeSpread()

bool includeSpread ( ) const

Definition at line 656 of file conventions.hpp.

◆ subPeriodsCouponType()

SubPeriodsCoupon1::Type subPeriodsCouponType ( ) const

Definition at line 657 of file conventions.hpp.

657{ return subPeriodsCouponType_; }
SubPeriodsCoupon1::Type subPeriodsCouponType_

◆ fromXML()

void fromXML ( XMLNode node)
overridevirtual

Implements XMLSerializable.

Definition at line 659 of file conventions.cpp.

659 {
660
661 XMLUtils::checkNode(node, "TenorBasisSwap");
663 id_ = XMLUtils::getChildValue(node, "Id", true);
664
665 // Get string values from xml
666 strPayIndex_ = XMLUtils::getChildValue(node, "PayIndex", false);
667 strReceiveIndex_ = XMLUtils::getChildValue(node, "ReceiveIndex", false);
668 strReceiveFrequency_ = XMLUtils::getChildValue(node, "ReceiveFrequency", false);
669 strPayFrequency_ = XMLUtils::getChildValue(node, "PayFrequency", false);
670 strSpreadOnRec_ = XMLUtils::getChildValue(node, "SpreadOnRec", false);
671 strIncludeSpread_ = XMLUtils::getChildValue(node, "IncludeSpread", false);
672 strSubPeriodsCouponType_ = XMLUtils::getChildValue(node, "SubPeriodsCouponType", false);
673
674 // handle deprecated fields...
675 if (strPayIndex_.empty()) {
676 XMLNode* longIndex = XMLUtils::getChildNode(node, "LongIndex");
677 if (longIndex) {
678 ALOG("TenorBasisSwapConvention: LongIndex is deprecated, fill empty PayIndex");
680 } else
681 QL_FAIL("TenorBasisSwapConvention : PayIndex field missing.");
682 }
683
684 if (strReceiveIndex_.empty()) {
685 XMLNode* shortIndex = XMLUtils::getChildNode(node, "ShortIndex");
686 if (shortIndex) {
687 ALOG("TenorBasisSwapConvention: ShortIndex is deprecated, fill empty ReceiveIndex");
689 } else
690 QL_FAIL("TenorBasisSwapConvention : ReceiveIndex field missing.");
691 }
692
693 XMLNode* longPayTenor = XMLUtils::getChildNode(node, "LongPayTenor");
694 if (longPayTenor) {
695 ALOG("TenorBasisSwapConvention: LongPayTenor is deprecated, fill empty PayFrequency");
696 if (strPayFrequency_.empty())
698 }
699
700 XMLNode* shortPayTenor = XMLUtils::getChildNode(node, "ShortPayTenor");
701 if (shortPayTenor) {
702 ALOG("TenorBasisSwapConvention: ShortPayTenor is deprecated, fill empty ReceiveFrequency");
703 if (strReceiveFrequency_.empty())
705 }
706
707 XMLNode* spreadOnShort = XMLUtils::getChildNode(node, "SpreadOnShort");
708 if (spreadOnShort) {
709 ALOG("TenorBasisSwapConvention: SpreadOnShort is deprecated, fill empty SpreadOnRec");
710 if (strSpreadOnRec_.empty())
712 }
713
714 build();
715}
static void checkNode(XMLNode *n, const string &expectedName)
Definition: xmlutils.cpp:175
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
static string getNodeValue(XMLNode *node)
Get a node's value.
Definition: xmlutils.cpp:489
#define ALOG(text)
Logging Macro (Level = Alert)
Definition: log.hpp:544
rapidxml::xml_node< char > XMLNode
Definition: xmlutils.hpp:60
+ Here is the call graph for this function:

◆ toXML()

XMLNode * toXML ( XMLDocument doc) const
overridevirtual

Implements XMLSerializable.

Definition at line 717 of file conventions.cpp.

717 {
718
719 XMLNode* node = doc.allocNode("TenorBasisSwap");
720 XMLUtils::addChild(doc, node, "Id", id_);
721 XMLUtils::addChild(doc, node, "PayIndex", strPayIndex_);
722 XMLUtils::addChild(doc, node, "ReceiveIndex", strReceiveIndex_);
723 if (!strReceiveFrequency_.empty())
724 XMLUtils::addChild(doc, node, "ReceiveFrequency", strReceiveFrequency_);
725 if (!strPayFrequency_.empty())
726 XMLUtils::addChild(doc, node, "PayFrequency", strPayFrequency_);
727 if (!strSpreadOnRec_.empty())
728 XMLUtils::addChild(doc, node, "SpreadOnRec", strSpreadOnRec_);
729 if (!strIncludeSpread_.empty())
730 XMLUtils::addChild(doc, node, "IncludeSpread", strIncludeSpread_);
731 if (!strSubPeriodsCouponType_.empty())
732 XMLUtils::addChild(doc, node, "SubPeriodsCouponType", strSubPeriodsCouponType_);
733 return node;
734}
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
Definition: xmlutils.cpp:181
+ Here is the call graph for this function:

◆ build()

void build ( )
overridevirtual

Implements Convention.

Definition at line 621 of file conventions.cpp.

621 {
624
625 QuantLib::ext::shared_ptr<OvernightIndex> payON = QuantLib::ext::dynamic_pointer_cast<OvernightIndex>(payIndex());
626 QuantLib::ext::shared_ptr<OvernightIndex> recON = QuantLib::ext::dynamic_pointer_cast<OvernightIndex>(receiveIndex());
627
628 if (strReceiveFrequency_.empty()) {
629 if (recON) {
630 receiveFrequency_ = 1 * Years;
631 WLOG("receiveFrequency_ empty and overnight, set to 1 Year");
632 } else {
633 receiveFrequency_ = receiveIndex()->tenor();
634 WLOG("receiveFrequency_ empty set to index tenor.");
635 }
636 } else
638
639 if (strPayFrequency_.empty()) {
640 if (payON) {
641 payFrequency_ = 1 * Years;
642 WLOG("payFrequency_ empty and overnight, set to 1 Year");
643 } else {
644 payFrequency_ = payIndex()->tenor();
645 WLOG("payFrequency_ empty set to index tenor.");
646 }
647 } else
649
652 if (includeSpread_ && (payON || recON))
653 QL_FAIL("IncludeSpread must be false for overnight index legs.");
654
656 : parseSubPeriodsCouponType(strSubPeriodsCouponType_);
657}
Period parsePeriod(const string &s)
Convert text to QuantLib::Period.
Definition: parsers.cpp:171
bool parseBool(const string &s)
Convert text to bool.
Definition: parsers.cpp:144
#define WLOG(text)
Logging Macro (Level = Warning)
Definition: log.hpp:550
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ receiveFrequency_

Period receiveFrequency_
private

Definition at line 668 of file conventions.hpp.

◆ payFrequency_

Period payFrequency_
private

Definition at line 669 of file conventions.hpp.

◆ spreadOnRec_

bool spreadOnRec_
private

Definition at line 670 of file conventions.hpp.

◆ includeSpread_

bool includeSpread_
private

Definition at line 671 of file conventions.hpp.

◆ subPeriodsCouponType_

SubPeriodsCoupon1::Type subPeriodsCouponType_
private

Definition at line 672 of file conventions.hpp.

◆ strPayIndex_

string strPayIndex_
private

Definition at line 675 of file conventions.hpp.

◆ strReceiveIndex_

string strReceiveIndex_
private

Definition at line 676 of file conventions.hpp.

◆ strReceiveFrequency_

string strReceiveFrequency_
private

Definition at line 677 of file conventions.hpp.

◆ strPayFrequency_

string strPayFrequency_
private

Definition at line 678 of file conventions.hpp.

◆ strSpreadOnRec_

string strSpreadOnRec_
private

Definition at line 679 of file conventions.hpp.

◆ strIncludeSpread_

string strIncludeSpread_
private

Definition at line 680 of file conventions.hpp.

◆ strSubPeriodsCouponType_

string strSubPeriodsCouponType_
private

Definition at line 681 of file conventions.hpp.