I see an example that shows how to calculate the PnL series for IRS in the strata-example project.(HistoricalScenarioExample.java)
Is there a similar example that shows how this can be done for the CDS product as well and has the required scenario level data that will be used as inputs to calculate the pnl Series?
if there is no support out of the box, how easy it is to add this funcationality.
We don’t currently have a similar example for CDS, but it would follow exactly the same pattern as in HistoricalScenarioExample, with the exception that the market data would need to include credit curves as well as interest rate curves. You should be able to build up perturbations in the same way as in the example, and have these applied to the curves used in the CDS pricer.
A simple example of pricing a CDS for a single scenario is included in CdsPricingExample, which shows all the market data required.
If you come across any issues then please let us know!
I think you have identified a gap here where the market data types used for pricing credit products are not currently compatible with the general curve perturbations that work in the rates example. We intend to align Strata’s CDS implementation with the market data types used in our other products, which will fix this. In the meantime we will see if we can produce an example showing what would be needed at the moment for CDS. I will get back to you in the next few days.
As promised, we have added CdsScenarioExample to strata-examples showing how perturbations would work for a single name CDS. Hopefully this is also clearer than the HistoricalScenarioExample, which we will improve in a similar way.
Please let us know if you have any more questions.