Numerical Hedging of Portfolio Risk via Approximated Derivatives
Abstract
This post presents a conceptual method for constructing hedging strategies using numerical approximations of derivatives with respect to tradable risk factors. Focusing on a selected factor, we show how first- and second-order sensitivities of portfolio value can be estimated from models or data-driven sources. These are then used to build hedges that neutralize both linear and curvature risk, enabling robust, model-agnostic risk management.
Table of Contents
ToggleApproximation of derivatives from Taylor Series (Expansion)
The Taylor series expansion up to the second order can be expressed in two forms, as shown below.
Forward (incremental) expansion:
Backward (decremental) expansion:
In the above equations:
- \(f\left(x_0\right)\) is the function value at the point \(x_0\),
- \(f'\left(x_0\right)\) is the first derivative (slope) of the function at \(x_0\),
- \(f''\left(x_0\right)\) is the second derivative (curvature) at \(x_0\),
- \(h\) is a small increment or decrement in \(x\) from \(x_0\).
Now, using the equations derived above, we can obtain approximations for the first and second derivatives of the function \(f\) at the point \(x_0\).
To estimate the first derivative \(f'\left(x_0\right)\), we subtract the backward expansion from the forward expansion:
which gives the central difference approximation:
Likewise, to estimate the second derivative \(f''\left(x_0\right)\), we add the forward and backward expansions:
which leads to the standard central difference formula for the second derivative:
Using Approximation of Derivatives in Portfolio Hedging
A portfolio \(\mathit{\Pi}\) may be exposed to several tradable risk factors-denoted collectively \(x_1,x_2,\dots ,x_k\) such as interest rates, equity indices, credit spreads, or commodity prices. These are variables for which direct or indirect market positions can be taken.
To neutralize risk from changes in \(x\), a single selected factor, we rely on numerical approximations of the first and second derivatives of the portfolio value \(\mathit{\Pi}(x)\). These derivatives can be computed from closed-form valuation models or approximated using data-driven approaches-such as neural networks or simulation engines that estimate \(\mathit{\Pi}\) at various values of \(x\).
To eliminate both linear and non-linear sensitivity to the selected factor, we construct a hedged portfolio by adjusting the original one, \({\mathit{\Pi}}_0\), as follows:
Here, the coefficients \(n\) and \(m\) are calibrated so that the first and second derivatives of the adjusted portfolio with respect to \(x\) vanish at a reference point \(x_0\):
Thus, one can explicitly determine both \(n\) and \(m\). If the portfolio is only linearly exposed to the factor \(x\), then \({\mathit{\Pi}}''_0\left(x_0\right)=0\), and \(m\) vanishes. The linear term \(n\cdot x\) offsets first-order (slope) exposure by taking a position in the tradable factor \(x\). The quadratic term \(m\cdot x^2\) offsets curvature risk. While \(x^2\) is not typically a direct trading instrument, such exposure can be constructed synthetically, for example by combining positions across different levels of \(x\), using convex payoff structures, or assembling weighted portfolios of linear instruments whose aggregate response approximates a quadratic profile.
This results in a neutralized portfolio, insensitive to both small (linear) and moderate (non-linear) shifts in the selected risk factor \(x\). This type of hedging is referred to as immunization against changes in a specific risk factor. The method is robust and flexible, applicable regardless of whether the portfolio's valuation function \(\mathit{\Pi}(x)\) is derived from models or modern machine learning systems.
Presentation of Immunization
This section introduces the concept of portfolio hedging through immunization, a technique designed to neutralize the impact of changes in a risk factor. You can explore this idea interactively using the Desmos presentation below.
In the graph, the curved red line represents the value of an unhedged portfolio that depends on a risk factor \(x\), shown on the horizontal axis. By adjusting \(x\) using the black slider at the bottom, you can observe how \(\mathit{\Pi}\) — the portfolio value — responds to these changes. In contrast, the hedged portfolio \({\mathit{\Pi}}_H\), shown in blue, remains flat. Its value stays constant even as \(x\) increases or decreases slightly.
Conclusions
The showcased framework is adaptable, transparent, and applicable to a wide variety of portfolio types and risk sources. Its flexibility makes it particularly useful in high-dimensional, data-driven environments where valuation models are complex or non-analytic. By relying solely on observable or simulated portfolio responses to changes in risk factors, the method supports integration into automated hedging workflows, machine learning pipelines, and dynamic risk management systems—paving the way for more responsive and model-independent portfolio strategies.
For a rigorous statistical inference framework for evaluating hedging strategies, see my textbook: Scientific Backtesting.
To measure and compare portfolio risk directly, try my free tool: VaRCalc — Multi-Method Value at Risk Calculator.
Resources

Related methodological resources
Continue Exploring Quantitative Finance Methodology
Explore PDF textbooks, implementation-oriented bundles, and methodological frameworks in quantitative investing, trading research, and scientific backtesting.
Explore PDF Textbooks & Bundles
