I have a REST API that has an endpoint that returns a BuiltMarketData object for use in trade pricing via CalculationRunner.calculate(…) and an endpoint that returns a RatesProvider for FX spot conversion and discount factor interpolation etc. To construct both objects it seems I have to run calibration twice which is wasteful. Is there a way to combine this? For example, extract the built market data from the rates provider? I understand that they serve different purposes (rates provider is for today’s rates/curves, builtmarket data for various scenarios such a sensitivity calculations, hs var etc).
BuiltMarketData builtData = StandardComponents.marketDataFactory().create(reqs, marketDataConfig, mktData, refData);
RatesProvider provider = (RatesProvider) calibrator.calibrate(curveGroupDef, mktData, refData));