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

#include <ored/portfolio/formulabasedlegbuilder.hpp>

+ Inheritance diagram for FormulaBasedLegBuilder:
+ Collaboration diagram for FormulaBasedLegBuilder:

Public Member Functions

 FormulaBasedLegBuilder ()
 
QuantLib::Leg buildLeg (const ore::data::LegData &data, const QuantLib::ext::shared_ptr< ore::data::EngineFactory > &engineFactory, ore::data::RequiredFixings &requiredFixings, const std::string &configuration, const QuantLib::Date &openEndDateReplacement=Null< Date >(), const bool useXbsCurves=false) const override
 
- Public Member Functions inherited from LegBuilder
 LegBuilder (const string &legType)
 
virtual ~LegBuilder ()
 
virtual Leg buildLeg (const LegData &data, const QuantLib::ext::shared_ptr< EngineFactory > &, RequiredFixings &requiredFixings, const string &configuration, const QuantLib::Date &openEndDateReplacement=Null< Date >(), const bool useXbsCurves=false) const =0
 
const string & legType () const
 

Detailed Description

Definition at line 36 of file formulabasedlegbuilder.hpp.

Constructor & Destructor Documentation

◆ FormulaBasedLegBuilder()

FormulaBasedLegBuilder ( )
explicit

Definition at line 38 of file formulabasedlegbuilder.hpp.

38: LegBuilder("FormulaBased") {}
LegBuilder(const string &legType)

Member Function Documentation

◆ buildLeg()

Leg buildLeg ( const ore::data::LegData data,
const QuantLib::ext::shared_ptr< ore::data::EngineFactory > &  engineFactory,
ore::data::RequiredFixings requiredFixings,
const std::string &  configuration,
const QuantLib::Date &  openEndDateReplacement = Null<Date>(),
const bool  useXbsCurves = false 
) const
override

Definition at line 26 of file formulabasedlegbuilder.cpp.

28 {
29 auto formulaData = QuantLib::ext::dynamic_pointer_cast<FormulaBasedLegData>(data.concreteLegData());
30 QL_REQUIRE(formulaData, "Wrong LegType, expected Formula");
31 string formula = formulaData->formulaBasedIndex();
32 Calendar cal;
33 if (formulaData->fixingCalendar() != "")
34 cal = parseCalendar(formulaData->fixingCalendar());
35 std::map<std::string, QuantLib::ext::shared_ptr<QuantLib::InterestRateIndex>> indexMaps;
36 auto formulaIndex =
37 makeFormulaBasedIndex(formula, engineFactory->market(), configuration, indexMaps, cal);
38 Leg result = makeFormulaBasedLeg(data, formulaIndex, engineFactory, indexMaps, openEndDateReplacement);
39 // add required fixing dates
40 for (auto const& m : indexMaps) {
41 for (auto const& c : result) {
42 auto f = QuantLib::ext::dynamic_pointer_cast<FloatingRateCoupon>(c);
43 QL_REQUIRE(f != nullptr, "expected FloatingRateCoupon in FormulaBasedLegBuilder");
44 requiredFixings.addFixingDate(f->fixingDate(), m.first, f->date(), false);
45 }
46 }
47 return result;
48}
void addFixingDate(const QuantLib::Date &fixingDate, const std::string &indexName, const QuantLib::Date &payDate=Date::maxDate(), const bool alwaysAddIfPaysOnSettlement=false, const bool mandatoryFixing=true)
Calendar parseCalendar(const string &s)
Convert text to QuantLib::Calendar.
Definition: parsers.cpp:157
@ data
Definition: log.hpp:77
QuantLib::ext::shared_ptr< QuantExt::FormulaBasedIndex > makeFormulaBasedIndex(const std::string &formula, const QuantLib::ext::shared_ptr< ore::data::Market > market, const std::string &configuration, std::map< std::string, QuantLib::ext::shared_ptr< QuantLib::InterestRateIndex > > &indexMaps, const Calendar &fixingCalendar)
Leg makeFormulaBasedLeg(const LegData &data, const QuantLib::ext::shared_ptr< QuantExt::FormulaBasedIndex > &formulaBasedIndex, const QuantLib::ext::shared_ptr< EngineFactory > &engineFactory, const std::map< std::string, QuantLib::ext::shared_ptr< QuantLib::InterestRateIndex > > &indexMaps, const QuantLib::Date &openEndDateReplacement)
+ Here is the call graph for this function: