|
From: Francis D. <fdf...@gm...> - 2020-09-22 19:58:56
|
Hi Brian, Tom, You could possibly adapt this function, boost::shared_ptr<IborIndex> parseIborIndex(...), from ORE to achieve what you want: https://github.com/OpenSourceRisk/Engine/blob/master/OREData/ored/utilities/indexparser.cpp#L197 ? Thanks, Francis. On Tue, Sep 22, 2020 at 8:52 PM Tom Anderson <tw...@ur...> wrote: > On Wed, 23 Sep 2020, Brian Smith wrote: > > > It will really be very helpful if there is some way to achieve this > > using a variable string - > > I agree. > > In my code, i define an enum Index, and then have a function like this: > > shared_ptr<IborIndex> lookupIborIndex(Index index, > Handle<YieldTermStructure>& curveHandle = EMPTY_HANDLE) { > switch (index) { > case Index::FED_FUNDS: return make_shared<FedFunds>(curveHandle); > case Index::SOFR: return make_shared<Sofr>(curveHandle); > case Index::USD_LIBOR_3M: return make_shared<USDLibor>(Period(3, > TimeUnit::Months), curveHandle); > default: QL_FAIL("unknown index: " << Traits<Index>::name(index) << " > (" << index << ")"); > } > } > > It would be nice not to have to do that. > > tom > > > On Sat, 19 Sep 2020 at 23:01, Brian Smith <bri...@gm...> > wrote: > >> > >> Hi, > >> > >> I understand that one way to create an index in QuantLib is, > >> > >> ext::shared_ptr<IborIndex> myIndex(new Euribor1M(termStructure)); > >> > >> However in my case the information like Euribor1M is variable and > >> stored in another variable like, > >> > >> std::string getIndex = "Euribor1M"; > >> > >> I am looking for some way to pass the variable getIndex, instead > >> Euribor1M directly, to create appropriate index based on my dynamic > >> situation. > >> > >> Is there any possible way to achieve this? > > > > > > _______________________________________________ > > QuantLib-users mailing list > > Qua...@li... > > https://lists.sourceforge.net/lists/listinfo/quantlib-users > > > > -- > a blood-spattered Canadarm flinging goat carcasses into the void > > > _______________________________________________ > QuantLib-users mailing list > Qua...@li... > https://lists.sourceforge.net/lists/listinfo/quantlib-users > |