OpenSourceRisk / Engine

Open Source Risk Engine

Home Page:http://www.opensourcerisk.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Market removes non-dominant FX pair and fails to build FX curve segment

gbfredrik opened this issue · comments

Hi,
With the new release, inverted FX spots are filtered out of the market data if a dominant pair is also available. This makes sense, but it causes crashes under certain conditions. We have seen this earlier as well (for similar "inverted" curves) but it is more prominent now that some spot quotes are removed.

E.g. in this case:

2024-05-28 FX/RATE/USD/BWP 13.559322033898306
2024-05-28 FX/RATE/BWP/USD 0.07375

the latter is removed -> Replacing MarketDatum FX/RATE/BWP/USD with FX/RATE/USD/BWP due to FX Dominance or skipped Skipped MarketDatum FX/RATE/BWP/USD - dominant FX already present.

If a cross-currency segment in a yield curve requests the inverted pair, an exception is thrown. See this example segment:

<CrossCurrency>
  <Type>FX Forward</Type>
  <Quotes>
    <Quote>FX_FWD/RATE/BWP/USD/...</Quote>
  </Quotes>
  <Conventions>USD-BWP-FX</Conventions>
  <DiscountCurve></DiscountCurve>
  <SpotRate>FX/RATE/BWP/USD</SpotRate>
  <ProjectionCurveDomestic>USD_SOFR</ProjectionCurveDomestic>
  <ProjectionCurveForeign>BWP_FX_SOFR</ProjectionCurveForeign>
</CrossCurrency>

and the error:
"FXTriangulation: no conversion from 'USD' to 'BWP' possible, since 'BWP' is not available as one of the currencies in any of the quotes (USDSEK)"
and warning:
Requested quote FX/RATE/BWP/USD for date May 28th, 2024 not in csv file. This is not necessarily an error.

This happens because a "slimmed down" market data loader is created for the valuations, which is unable to resolve inverted spot quotes. Adding <Parameter name="entireMarket">true</Parameter> to ore.xml will let the code move further, but the curve won't quite be correct, and the failure would still occur when trying to do a sensitivity calculation. Removing the USD/BWP quote solves the issue, but when removing BWP/USD the issue persists. Any thoughts on this problem? :)

I can create a workaround in the code for the time being, likely by allowing an inversion somewhere.

Thanks a lot!
Fredrik

Right, we didn't think of the curve building when cleaning this up. I would tend to invert the quote in the curve builder if necessary. Will that work?

We will try to fix this and include in a point release next week.

Thanks for the replies! Unfortunately I didn't have the time yet to create a fix. It did seem like the xccy curve segment would have to register a dependency also against the inverted pair, such that it'll always hit the "dominant" order pair when creating the internal slim market.

Just thinking loud: Would it be sufficient to extend

https://github.com/OpenSourceRisk/Engine/blob/master/OREData/ored/marketdata/yieldcurve.cpp#L2853

so that looks for the inverted spotId in the loader?

Hi @gbfredrik, as discussed I'll look into that. Could you provide an input folder that reproduces the problem?

Hi,
Here's a self-contained example with a dummy configuration. It should currently cause an error as-is, and you can test for the other edge cases by removing either of the BWP/USD and USD/BWP quotes from the market data file.

I am able to get it to work by adding these lines:
image

The logs will then produce these messages showing how it attempts to add both pairs:
image

Input.zip

perfect, thank you, I'll just add a version of your patch

Hi,
Confirming this as fixed with v12.1, thanks for the re-release!