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.
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.
I hit this again when setting up an FX forward curve for XCcy Swap pricing, any chance we can get this updated and possibly a test added to the codebase for setting up an FX forward curve?