Curve calibration and pricing


#1

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:

		BuiltMarketData builtData = StandardComponents.marketDataFactory().create(reqs, marketDataConfig, mktData,
				refData);

RatesProvider:

RatesProvider provider = (RatesProvider) calibrator.calibrate(curveGroupDef, mktData, refData));

#2

You can create an instance of RatesMarketDataLookup, then call lookup.ratesProvider(marketData) to get the RatesProvider.

HTH
Stephen


#3

Hi Stephen,

That was perfect, thanks!. As a follow on question, is there a way to speed up calibration? Currently it takes around 20 seconds for 15 curves (over 12 currencies). I’m bootstrapping via:

		BuiltMarketData builtData = StandardComponents.marketDataFactory().create(reqs, marketDataConfig, mktData,
				refData);

Is there a way to set the tolerances and or control the calibration in the above? Something like passing in the configured calibrator? Or run the calibration in parallel?

CurveCalibrator calibrator = CurveCalibrator.of(1.e-8, 1.e-8, 50);

#4

You can pass RootFinderConfig in via marketDataConfig.

Beyond that would require code change. It was intended that CurveCalibrator would be able to split the calibration into separate chunks where each chunk is independent of the other chunks. Not sure if that applies in your case, See ImmutableList.of(curveGroupDefn) around line 226 which could be altered to pass a list of chunks to the next method instead of just the whole definition.