Question on ImmutableRatesProviderBuilder indexCurves method

ImmutableRatesProviderBuilder contains methods to individually add an iborIndexCurve, overnightIndexCurve or priceIndexCurve and the #indexCurve method throws an exception if you call it with an index which is not an instance of either IborIndex, OvernightIndex or PriceIndex.

Is there a reason for this restriction? Also is there a reason why the #indexCurve methods take an Index parameter and not a FloatingRateIndex parameter which is a superclass of the valid types and a subclass of Index?

This currently forces us to abuse the three valid Index subclasses in order to add other indices to represent bonds / repos.

The reason for using Index is that FloatingRateIndex was added later.

I can’ immediately see any reason why the validation is needed. However, there is of course no simple way to use a curve associated with any other kind of index. As such, I think it would be reasonable to remove the validation.

Thanks - for bonus points, what’s the simple way? Just sticking it into a MarketData object?

Anything can be added to a MarketData object, but it isn’t really designed to be used directly from pricers. The RatesProvider is intended to be a view onto the larger set of underlying MarketData.

Depending on your goals, you could implement RatesProvider yourself, as it is an interface. Or you could take a look at LegalEntityDiscountingProvider which is intended as the one to use for bond pricing.

We haven’t hit indices for bonds/repos here, so can’t directly advise.