|
From: Tom A. <tw...@ur...> - 2020-09-22 19:49:42
|
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
|