This example demonstrates the application of neural networks to the risk management of financial structured products under realistic market conditions. It focuses on a particular derivative, but can be generalized to portfolios of structured products, considering cross-asset effects like proxy hedging and statistical hedging of risks not covered by market instruments (e.g. correlation risk).

This framework – called Autohedger – is implemented in Python, but interfaces a C++ library for financial modelling and asset valuation, and TensorFlow for modelling the machine learning component.

Basically, the Autohedger consists of two core parts, the

- Feature Generator, which generates simulated market data like spot path, payoffs and deltas of the structured products, and other inputs.
- Hedger, which derives the hedge quantities from the given inputs, and is modelled by a (recurrent) neural network using TensorFlow.

The results are compared to a simple Delta hedging approach that derives the hedge quantities from the Local Volatility model deltas.

## Without Transaction Costs

Computing the optimal hedge becomes challenging when realistic market conditions like transaction costs or liquidity constraints are taken into consideration. Some derivatives, for instance a digital call or put, come with the additional risk of a discontinuous payoff. This complicates the hedging, because in real world situations hedge quantities can be only adjusted at discrete times.

Consider the following digital call with strike 70 EUR and payoff 2 EUR, having a time to maturity of about 3 months. From an issuer’s perspective, the initial position is short, i.e. the issuer sells the derivative and earns the initial value at the beginning. A spot price of 72 EUR gives a fair value of 1.12 EUR for the digital call.

The following histograms show the aggregated P&L (profit and loss) distributions, generated by

- the cash flows of the digital call (initial value 1.12 EUR minus the potential payoff of 2 EUR if in-the-money at maturity), and
- the cash flows of the hedges (trading gains and losses from adjusting the hedge positions).

Without transaction costs, the results from Delta hedging and the Network Autohedger are quite similar when the objective is to minimize the variation in P&L (left figure and table).

Minimizing the Expected Shortfall instead (i.e. maximizing the expected P&L of the lower 10% quantile), the Autohedger deteriorates on the variation, but improves with respect to the expected shortfall (right figure and table above).

## With Transaction Costs

Keeping the Expected Shortfall as the loss metric and introducing transaction costs relative to the spot price of 25 (left), 50 (middle) and 200 (right) basis points (bp), respectively, yields the following P&L histograms.

*Hedge PnL for minimizing expected shortfall in the case of 0.25% (left), 0.5% (middle) and 2% (right) transaction costs.*

When transaction costs are low (left figure), the Autohedger is able to improve the expected shortfall slightly, but at the cost of losing some mean P&L values to the lower part of the distribution. The Delta hedger has lower standard deviation, but a slightly worse expected shortfall, due to few extreme negative values.

The situation is different when transaction costs are higher (middle and right figure). Here, the Delta hedger becomes more expensive because of the transaction costs. In the case with high transaction costs (right figure), no hedging would have been even better than Delta hedging, because with no hedging the worst-case P&L is 0.88 EUR (1.12 EUR initial value minus 2 EUR payoff).

## Hedge Analytics

Machine Learning approaches support quantitative finance applications in (at least) two ways:

- Firstly, the allow to automate processes e.g. by hedging a baseline of the portfolio risk.
- Secondly, they help to analyze and optimize existing workflows and operations

The first point was addressed in the previous section, the second point is demonstrated now, by showing that the Autohedger gains further insight when hedging complicated market situations.

The plots below show the hedge quantities for a specific spot path, and again for the cases with 25 bp (left) and 50 bp (right) transaction costs. The path is challenging for a trader managing the risk of the digital call, because it is moving around the strike price of 70 EUR just before maturity. Hence the delta position moves quite rapidly between a value close to zero and a value substantially above zero, or in terms of a derivatives trader: the gamma of the digital call is large.

*Hedge quantities as determined by the Autohedger for a particular spot path with transaction costs 0.25% (left) and 0.5% (right).*

For at-the-money situations close to maturity one can summarize: the larger the transaction costs are, the less is the hedging activity of the Network Autohedger (blue line) compared to the Delta hedger (orange line). The effect is also reflected in the P&L value (see legend in the plots), which is much better for the Autohedger.

**If you are interested in
learning more about the potential of Machine Learning methods in hedging or
analyzing portfolio risks, or if you are looking for an individual solution for
your business, please contact us.**