I've been looking at the open-source library Strata (maintained by OpenGamma), which is written in Java.
Now, upon inspection of the FX Forward Pricer and Payment Pricer I noticed two things:
- All its low-level calculations & results (present value, PV01, etc.) are done using classes like CurrencyAmount or MultiCurrencyAmount. What is the computational cost of this in comparison to using double numbers first and enhancing the results with Currency Meta Data after the calculations are completed? E.g. every time a new CurrencyAmount is created one passes the internal Currency property, which itself contains a 3-letter symbol represented as string. So it seems strings are repeatedly copied.
- The present value function call receives the trade itself and a market data provider. The trade's currency is then used to obtain the appropriate discount factor curve from the market data provider, from which the final discount factor is then queried. Again, I am wondering what the cost of this constant "curve look-up" is on a larger scale. Why not embed a direct reference in the trade (or pricer, depending on the implementation) to the appropriate discount curve? So repeated function calls (be it present value or pv01) don't have to constantly look up the curve in the market data map. Maybe similarly to having a
shared_ptr
to the curve in C++.
QuantLib in comparison embeds the necessary market-data object pointers in the pricing engines when the engine is setup, and it only operates on double numbers, which appears more efficient on first glance. Obviously, one cannot easily parallelise the QuantLib approach, whereas this is possible using Strata.