Introduction
Batch execution is a typical process for producing detailed risk reports. This mode of execution is sensible for the bump-and-revalue, brute force method, of computing risks and scenario analysis. Using our modern AAD tool, risk management can be taken to the next level - seeing risk "live", and having your risk reports update almost instantly with every new market tick. Traditional batch execution involves breaking down the trade portfolio into jobs, serialising, and de-serialising for execution on the grid, and, eventually, carrying out the jobs in parallel. Batch execution usually takes several hours overnight, whereas live risk can give you results in a fraction of the time, enabling faster decision-making and giving you significant competitive advantage, especially in turbulent intraday trading times.
Batch processing is slow - and dangerous. When systems are slow, people cut corners, and don’t compute all scenario risks, leaving some risks unmonitored. This was demonstrated in exotic derivatives when Korean autocallable notes pushed over a trillion Won ($810 million) of South Korean equity-linked securities into the red in Q3 of 2022.
Transitioning into live risk is much desired as it can yield better returns to stakeholders, reduce operational risks as well as improve regulatory compliance. However, delivering such functionality typically needs major investment as it requires rewriting large parts of the quant library.
In this post, we present an alternative way to transition from overnight risk calculations to live risk without embarking on a multi-year IT transformation project. We show how the Automated Implicit Function Theorem (AIFT) and a modern AAD tool can be used in a real production code environment to achieve an ‘always on’ Risk Server, and we outline the steps required to transition.
Example (and we can show how this can be applied to your quant library)
We can now see how the existing batch-mode analytics can be transitioned to live risk, making your traders happy!
The Magic behind the Live Risk
The key to Live risk is performance, so a high-performing AAD tool is required. Matlogica’s AADC library achieves the adjoint factor of less than 1, meaning that all the risks can be computed faster than the PV. Therefore, it is a great fit. The performance is achieved by recording the computation once and producing a highly-optimised and vectorised ‘kernel’ to use for repeated calculations.
Proposed Software Architecture
The Math Behind it
1. Set Up
Suppose that we have an objective function where stands for the market observable data in the market variables and stands for the coefficients of the model. We calibrate the coefficients to the market data by solving the equation
(1)
Then the calibrated coefficients can be used to compute another value of interest that could be the price of the assets, XVA, etc.
We know pretty well how to solve the forward problem of computing (by using Newton solvers, Levenberg-Marquardt, etc.), let us focus on backpropagating the sensitivities with respect to the market data (representing the rates, spreads, etc.). Explicitly, we need to compute (this is (12)):
In this formula, can be obtained with a straightforward application of AAD, and is usually already computed during the forward step (if using Newton solvers or Levenberg-Marquardt). So we need to focus on computing . Again, in this simple calibration example (1), this is straightforward.
2. Calibration in steps
In practice, calibration is often done by using multiple solvers executed in a sequence. So instead of one formula (1) we get multiple calibration steps
Here the multiple calibration steps solve lower-dimensional calibration problems. The issue is that the dependence on and in is often implicit (i.e. they are hidden variables) since the abstract virtual interface that one uses to implement Newton solvers and Levenberg-Marquardt may hide these dependencies. See Figure 1 for a code example on how a virtual function GoalFunc2 (an implementation for ) can't see a dependence on and . In practice, the issue may be even more severe as GoalFunc may be hidden deep inside the library.
2.1 Naive IFT
Due to the hidden variables, a naive application of AAD to compute would often require a lot of refactoring of the existing code to track the dependencies. Writing for the hidden depedencies in , one would need to identify the hidden variables and compute the Jacobians of the functions . Note that these Jacobians can be very large.
2.2 AIFT
Suppose that we have just two calibration steps and the calibration function depends on the hidden variables . We want to backpropagate . The intuition behind the AIFT approach is as follows. When we are using AAD to compute the derivatives, executing calculates . Executing then updates and . In this process, we are free to choose . The idea is to choose in such a way that the adjoint update cancels out the value of and makes . This will propagate automatically. The correct choice for that achieves this is (see (20)):
Note from the discussion at the end of Section 1 that both quantities in the product are readily available. This allows integrating AAD by using checkpointing without going into the solvers or identifying the hidden variables. For multiple calibration steps, one would do the same thing at every level of the calibration process.
Conclusions
To summarize, the AIFT approach offers the following benefits:
- Straightforward automatic handling for solvers and minimizers with no refactoring of the codebase.
- The computation of is not required which leads to a much faster backpropagation.
By using Matlogica's AADC library, a batch system can be transformed into an ‘always on’ Risk Server without embarking on a multi-year transformation project. To achieve this, the following steps need to be implemented: Integrate Matlogica's AADC into your existing Quant library.
1. Send PV requests to the grid node at the beginning of each trading day.
2. Record market rates and obtain through the solvers.
3. Receive market updates.
4. Run solvers to fit new market data.
5. Execute pricers and the adjoint code.
6. Send live risk feed to the traders.
7.Go to 4) unless the trading day is finished!
Is it possible for you to transition to Live Risk? Talk to us!
Matlogica will be there to assist you with integration every step of the way!