Delta Hedging Simulation

Calculate the distribution of the hedging error of selling a European option and delta hedging it: how much the hedged seller can gain or lose across simulated Geometric Brownian Motion paths of the stock from its price on the start date.

Each path is hedged as in get_delta_hedging_backtest: the option is sold at its Black-Scholes value at the implied volatility, the hedge holds its delta, rebalanced every rebalancing_days trading days at a proportional cost, while the stock moves with the volatility:

\[S(t + \Delta t) = S(t) e^{\left(r - q - \frac{\sigma^{2}}{2}\right) \Delta t + \sigma \sqrt{\Delta t} Z},\;\; Z \sim N(0,\; 1),\;\; \Delta t = \frac{1}{252}\] \[\text{Profit and Loss} = e^{- rT}\left[\text{Cash}_{T} + \Delta_{T} S_{T} - \operatorname{Payoff}(S_{T})\right],\;\; \text{per path}\] \[\text{Approximate Standard Deviation} = \frac{\sqrt{\frac{\pi}{4}} \cdot \text{Vega} \cdot \sigma}{\sqrt{N}}\]

Hedging at discrete times leaves an error whose mean is near zero and whose standard deviation falls with the square root of the number of rebalances N, as Boyle and Emanuel (1980) and Derman and Kamal (1999) derive for an at-the-money option; the last column gives their approximation. An implied volatility above the volatility gives the seller a profit on average, transaction costs a loss that grows as the hedge is rebalanced more often (Leland, 1985).

FinancePy’s simulate_hedge_paths reports the profit and loss at expiration rather than discounted and closes the hedge in cash at expiration.

Also known as: hedging error distribution, discrete hedging simulation, delta hedging Monte Carlo.

Example · AAPL, MSFT · 2024 to 2025

Install the Finance Toolkit with pip install financetoolkit -U, then call get_delta_hedging_simulation:

from financetoolkit import Toolkit

toolkit = Toolkit(
    ["AAPL", "MSFT"], api_key="FINANCIAL_MODELING_PREP_KEY", start_date="2024-01-01", end_date="2025-12-31"
)

toolkit.options.get_delta_hedging_simulation(
    start_date="2025-12-31",
    rebalancing_days=5,
    transaction_cost=0.0005,
    show_columns=["Option Value", "Mean Profit and Loss", "Standard Deviation", "Approximate Standard Deviation"],
)

Or, with the Finance Toolkit MCP set up, ask an AI assistant such as Claude or ChatGPT:

How much can a seller of an option on Apple and Microsoft gain or lose when delta hedging it every five trading days from the end of 2025, with a cost of 0.05% per trade?

Which returns:

Parameters

get_delta_hedging_simulation accepts the following parameters.

ParameterTypeDescriptionExample
daysintThe trading days to expiration, at least 1. Defaults to 63, about three months.360
start_datestr | NoneThe date of the stock price, volatility, risk free rate and dividend yield, or the last trading day before it. Defaults to None, the last date of the historical data."2021-01-01"
moneynessfloatThe strike as a fraction of the stock price. Defaults to 1.0, at the money.
volatilityfloat | NoneThe volatility the stock moves with, for every ticker, 0 or above (at 0 every path grows at the risk free rate less the dividend yield). Defaults to None, the volatility of the year of daily returns up to the start date.0.008
implied_volatilityfloat | NoneThe volatility the option is sold and hedged at, 0 or above (at 0 the option is sold at its discounted intrinsic value and the delta is 0 or 1). Defaults to None, the volatility the stock moves with.None, the volatility the stock moves with
put_optionboolWhether the option is a put. Defaults to False.True
transaction_costfloatThe cost of a trade as a fraction of its value (0.001 is 10 basis points), 0 or above. Defaults to 0.0.0.0
rebalancing_daysintThe trading days between rebalances. Defaults to 1, daily.1, daily
simulationsintThe number of simulated paths, at least 1. Defaults to 10,000.1000
seedint | NoneThe seed of the random numbers, None for a different draw on every call. Defaults to 0.42
roundingint | NoneThe number of decimals to round the results to. Defaults to None, which uses the Toolkit’s rounding.2
show_columnsstr | list[str] | NoneThe columns to keep, a name or a list of names, matched on every column level, or the rows when no column has those names (such as the line items of a financial statement). Names that do not exist are logged, and when none exist the result is returned in full. Defaults to None, which keeps every column.None, which keeps every column

References

  • Paper Boyle, P. P. and Emanuel, D. (1980). “Discretely Adjusted Option Hedges.” Journal of Financial Economics, 8(3), 259-282.
  • Paper Derman, E. and Kamal, M. (1999). “When You Cannot Hedge Continuously: The Corrections of Black-Scholes.” Risk, 12(1), 82-85.
  • Paper Leland, H. E. (1985). “Option Pricing and Replication with Transactions Costs.” The Journal of Finance, 40(5), 1283-1301.
  • Library Referenced against FinancePy’s simulate_hedge_paths
Share