24#include <ql/time/calendars/jointcalendar.hpp>
25#include <ql/time/calendars/nullcalendar.hpp>
27#include <boost/make_shared.hpp>
32QuantLib::ext::shared_ptr<QuantExt::FormulaBasedIndex>
34 const std::string& configuration,
35 std::map<std::string, QuantLib::ext::shared_ptr<QuantLib::InterestRateIndex>>& indexMaps,
36 const Calendar& fixingCalendar) {
39 std::vector<QuantLib::ext::shared_ptr<QuantLib::InterestRateIndex>> indices;
40 std::vector<std::string> variables;
41 QuantExt::CompiledFormula compiledFormula =
parseFormula(formula, variables);
42 Calendar fixCal = NullCalendar();
43 for (
auto const& v : variables) {
44 QuantLib::ext::shared_ptr<InterestRateIndex> index;
45 QuantLib::ext::shared_ptr<IborIndex> dummyIborIndex;
47 index = *market->iborIndex(v, configuration);
50 index = *market->swapIndex(v, configuration);
52 QL_REQUIRE(index !=
nullptr,
"makeFormulaBasedIndex("
53 << formula <<
"): variable \"" << v
54 <<
"\" could not resolved as an ibor or swap index in the given market");
55 indices.push_back(index);
56 fixCal = JointCalendar(fixCal, index->fixingCalendar());
60 QuantLib::ext::shared_ptr<QuantExt::FormulaBasedIndex> fbi = QuantLib::ext::make_shared<QuantExt::FormulaBasedIndex>(
61 "FormulaBasedIndex", indices, compiledFormula, fixingCalendar == Calendar() ? fixCal : fixingCalendar);
bool tryParseIborIndex(const string &s, QuantLib::ext::shared_ptr< IborIndex > &index)
Try to convert std::string to QuantLib::IborIndex.
Map text representations to QuantLib/QuantExt types.
QuantExt::CompiledFormula parseFormula(const std::string &text, std::vector< std::string > &variables)
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)
Serializable Credit Default Swap.