An Interactive Dynamic Delta Hedging Example in R

Share Price Screen

Delta hedging is a technique used by trades to reduce the directional risk of a position. This delta hedging strategy results in the reduction of the variability of the profit and loss (pnl) of the position. A position that is delta hedged is said to be delta neutral.

In this blog we will look at delta hedging European options under the Black and Scholes framework. A European option is an option that can only be exercised at the end of its life (i.e at its maturity). The hedging we will perform will be daily, and thus making it a dynamic delta hedging strategy.

As a visual illustration of dynamic delta hedging, I have developed an interactive web application. Feel free to play around with it. Any feedback on how I can improve the web app is welcome.

The rest of this blog post goes through the theory of delta hedging for European options as well as the assumptions used in building the web application.

For ease of illustration, we will focus on how one delta hedges a European call. The results for a European put follow by the put call parity.

The price of a non-dividend paying European call option  under the Black and Scholes framework is given as:

 C_t(S_t,t)=N(d_1)S_t-N(d_2)Ke^{-r(T-t)} where

  • S_t is the stock price at time t
  • K is the strike
  • r is the risk free interest rate
  • \sigma is the annualized volatility of the stock
  • T is the maturity of the option
  • d_1=\frac{1}{\sigma\sqrt{T-t}}\large[\ln(\frac{S_t}{K})+(r+\sigma^2/2)(T-t)\large]
  • d_2=d_1-\sigma\sqrt{T-t} and
  • N(x) is the cumulative normal distribution evaluated at x.

Note that the stochastic process underlying  the Black Scholes framework is the Geometric Brownian Motion (GBM). For a background on GBM please go to the Introduction to Diffusion and Jump diffusion blog post.

The profit and loss, from time  t to s (with s>t ), that a trader  who is long  the call option will experience  is


This pnl can be very variable (especially if the underlying stock S_t process has a high volatility). Thus we want to reduce this variability of the pnl. We can archive this by delta hedging this position.

In order to delta hedge the position, we need to understand what the delta of the option is. The delta is the sensitivity of the option to small changes in the underlying stock price. That is, the delta is the partial derivative of the option price with respect to  the underlying. The delta  of  a non-dividend paying European call option under the Black Scholes framework is given as:

\delta_t=\frac{\partial C_t(S_t,t)}{\partial S_t}=N(d_1).

This represents the number of units of the underlying that we should hold  at time t in order to be delta neutral at time t. The pnl equation now becomes:


For this delta hedge to be maintained, we need to keep buying/selling units of the underlying regularly. In the web application, we do the hedging daily. In practice one may need to do this even more frequently.

Although delta hedging has the advantage of reducing the variability of the pnl, it has the disadvantage of attracting transaction costs (which we ignore in  the web app) due to the frequent buying and selling of the underlying.

In the web application we also look at  the case where we price assuming GBM and try to hedge a stock path that was generated using a Jump Diffusion process. This results in an unhedged pnl that is more variable than the case where we price and hedge using  GBM.

The delta hedged pnl is also more variable that the case where we price and hedge using GBM.

These scenarios can be observed by playing around in with the web application.

This section has the R code used for this blog post.

3 Replies to “An Interactive Dynamic Delta Hedging Example in R”

  1. Pingback: Quantocracy's Daily Wrap for 08/28/2017 | Quantocracy

  2. Looks very cool so far. You have a link for code used, but it is not populating in Chrome; are you planning to share that?
    Thanks very much for the good work.

Leave a Reply

Your email address will not be published. Required fields are marked *