So Many Options!

financetutorialcode

So Many Options!

Introduction

Fokker-Planck equations, and stochastic differential equations in general, have many powerful applications in a wide ranging set of fields. These include modelling of Brownian motion in physical systems, electronic noise in engineering fields, and behaviour of financial assets in quantitative finance.

This paper looks at the specific application of the Fokker-Planck equation to modelling valuation of stock options using the Black-Scholes equation. From this equation, one can derive the Black-Scholes formula, giving an estimate of the value of a European option.

This formula laid the mathematical foundation for options trading, providing much needed legitimacy to the trade of stock options. In fact, the formula was so instrumental in the development of options trading that Myron Scholes and Robert Merton were awarded the Nobel Prize in Economics in 1997 for related work. Fischer Black was not awarded the prize as it is not awarded posthumously. First some relevant financial theory will be explored. The appropriate mathematics will be developed and briefly discussed before applying it to the financial mathematics explored in this paper. Finally, some simulations will be presented with accompanying Python code.

Financial Theory

Options

A stock option is a financial contract in which the holder of the option is granted the right to buy or sell some financial asset at a specified price. An option that may be exercised before or on expiration is known as an American option, while an option that may only be exercised on the date of expiry is called a European option. The incentive for owning stock options is that it changes the risk profcile of a trade in contrast to conventional buying or selling of stocks. An option can be thought of as a way to increase or decrease trading risk by increasing or decreasing the potential payout. This basic principle allows for different trading strategies by betting on the expected future behaviour of an underlying asset. For example, one can use an option as an insurance policy on the purchase of an underlying stock.

Valuation

The valuation (pricing) of an option is a non-trivial task. The value depends on both the value of the underlying financial object (asset) and a number of variables associated with the risk and potential payout of the option. In general, the following variables are used to calculate the price of an option:

  1. Market price of underlying asset.
  2. The strike price of the option.
  3. Cost of holding underlying asset.
  4. Time to expiration.
  5. Estimate of volatility of underlying asset.

This paper focuses on the application of a Fokker-Planck equation - in the form of the Black-Scholes equation - for option valuation.

Wiener Processes & Brownian Motion

The Wiener process is a real-valued continuous-time stochastic process. It forms an important aspect of theories in many fields, including mathematics, economics, biology and physics. It is often referred to as Brownian motion because of the strong ties with the physical theory of random particle motion. It is a well-known example of a Lévy process - a continuous-time random walk. A Wiener process WtW_t is characterised as in Essentials of Stochastic Processes 1Durrett, R. (1996). Essentials of Stochastic Processes. Springer..

  • W0=0W_0= 0.
  • WW has independent increments: for every t>0t>0, the future increments Wt+uWt,W_{t+u} - W_t, u0u \ge 0, are independent of the past values WsW_s, st.s\leq t.
  • WW has Gaussian increments: Wt+uWtW_{t+u} - W_t is normally distributed with mean 00 and variance uu, Wt+uWtN(0,u).W_{t+u} - W_t\sim \mathcal N(0,u).
  • WW has continuous paths: WtW_t is continuous in tt.

Geometric Brownian Motion

Geometric Brownian motion is a continuous-time stochastic process where the logarithm of the stochastic quantity follows a Wiener process. A stochastic process StS_t is said to follow a GBM if it satisfies the stochastic differential equation dSt=μStdt+σStdWt,dS_t = \mu S_t dt + \sigma S_t dW_t, where WtW_t is a Wiener process, μ\mu is the drift, and σ\sigma is the volatility. It is particularly well-known for its use in mathematical finance to model stock prices. This paper explicitly focuses on the Black-Scholes model - an example of geometric Brownian motion satisfying a stochastic differential equation.

Itô calculus

Itô calculus extends the mathematical formulation of calculus to stochastic processes. This is especially relevant for options pricing as the Black-Scholes equation is a stochastic differential equation which employs Itô calculus to solve for the Black-Scholes formula. The central concept in this formulation is a generalisation of the Riemann-Stieltjes integral. We define the integral of some process HsH_s as Yt=0tHsdXs,Y_t = \int_0^t H_sdX_s, where X is a Wiener process. The integral is defined as the limit of a sequence of random variables, which gives another stochastic process. A key result in Itô calculus is as follows.

Definition: For an Itô drift-diffusion process dXt=μtdt+σtdBtdX_t = \mu_tdt + \sigma_tdB_t and any twice differentiable function f(t,x)f(t,x) of two real variables tt and xx, we have df(t,Xt)=(ft+μtfx+12σt22fx2)dt+σtfxdBt.df(t,X_t) = (\frac{\partial f}{\partial t} + \mu_t\frac{\partial f}{\partial x} + \frac{1}{2}\sigma_t^2\frac{\partial^2 f}{\partial x^2})dt + \sigma_t\frac{\partial f}{\partial x}dB_t.

Fokker-Planck Equations

The Fokker-Planck equation, in the context of statistical mechanics, is a partial differential equation used to model the time evolution of some probability density of particle velocities subject to drag and stochastic forces. The equation can be generalised for application to different systems. This paper will focus on the application to financial modelling of European option pricing.

An interesting result, which ties together the mathematical formulations of various fields, is that every Fokker-Planck equation is equivalent to some path integral. Consider, for example, Feynman’s path integral formulation of quantum mechanics. This theorem tells us that we can formulate quantum mechanics in terms of Fokker-Planck equations. Alternatively, the non-equilibrium statistical mechanics formulation, for which the Fokker-Planck equation was developed, can be written in terms of path integrals. Given some Wiener process WtW_t described by dXt=μ(Xt,t)dt+σ(Xt,t)dWtdX_t = \mu(X_t,t)dt + \sigma(X_t,t)dW_t, with μ(Xt,t)\mu(X_t,t) being the drift, we can describe the Fokker-Planck equation for density p(x,t)p(x,t) of random variable XtX_t as

tp(x,t)=x[μ(x,t)p(x,t)]+2x2[D(x,t)p(x,t)].\frac{\partial}{\partial t}p(x,t) = -\frac{\partial}{\partial x}[\mu (x,t)p(x,t)] + \frac{\partial^2}{\partial x^2}[D(x,t)p(x,t)].

This generalises easily to higher dimensions.

Asset Pricing Applications

Stock assets are often modelled as following a geometric Brownian motion. The Black-Scholes dynamic is given by dStSt=μdt+σdBt.\frac{dS_t}{S_t} = \mu dt + \sigma dB_t. Applying Itô lemma to f(x)=ln(x)f(x)=\ln(x), we can solve this stochastic differential equation 2SRKX What is Itô's lemma used for in quantitative finance?. Quantitative Finance Stack Exchange.. f(x)=1xf'(x)=\frac{1}{x} f(x)=1x2f''(x)=-\frac{1}{x^2}

d(ln(Xt))=1XtdXt12Xt2d<Xt>=μdt+σdWtσ22dt=μdt+σdWtσ22dt=(μσ22)dt+σdWt d(ln(X_t)) = \frac{1}{X_t} dX_t -\frac{1}{2X_t^2} d<X_t>\\ = \mu dt + \sigma dW_t - \frac{\sigma^2}{2} dt\\ = \mu dt + \sigma dW_t - \frac{\sigma^2}{2} dt\\ = (\mu - \frac{\sigma^2}{2}) dt + \sigma dW_t

Which gives the result, ln(Xt)ln(X0)=ln(XtX0)=(μσ22)(t0)+σWtln(X_t)-ln(X_0)=ln(\frac{X_t}{X_0})=(\mu - \frac{\sigma^2}{2})(t-0) + \sigma W_t Xt=X0e(μσ22)t+σWtX_t=X_0 e^{(\mu - \frac{\sigma^2}{2})t + \sigma W_t}

ST=S0e(μσ22)T+σBT.S_T = S_0e^{(\mu-\frac{\sigma^2}{2})T+\sigma B_T}. This form of the equation can be used to simulate price movements of an asset.

The Black-Scholes Equation

The Black-Scholes equation is insightful as it enforces that one can perfectly hedge the financial option by trading the underlying financial asset - essentially eliminating risk. Moreover, there is only one correct value for the option. This value is given by the formula.

Vt+12σ2S22VS2+rSVSrV=0\frac{\partial V}{\partial t} + \frac{1}{2}\sigma^2S^2\frac{\partial^2V}{\partial S^2} + rS\frac{\partial V}{\partial S} - rV = 0

Black-Scholes Derivation

This derivation is based on Ten Different Ways to Derive Black–Scholes3Newsmth.net (2020). Ten different ways to derive Black–Scholes.. This derivation involves Fokker-Planck Equations. First, assume the option value is determined by the present value of the risk-neutral expected payoff. Also consider p(S,t;S,T)p(S^*,t^*;S,T) to be the transition probability density for the risk-neutral random walk where SS^\ast is the current asset price and tt^* is the current date. KK is the strike price and TT is the expiration date. Then, the value of the stock option is V(K,T)V(K,T) where,

V(K,T)=er(Tt)Et[max(STK,0)]=er(Tt)0max(SK,0)p(S,t;S,T)ds=er(Tt)0(SK)p(S,t;S,T)ds V(K,T) = e^{-r(T-t)}E_t[max(S_T-K,0)] \\ = e^{-r(T-t^*)}\int_0^\infty max(S-K,0)p(S^*,t^*;S,T)ds \\ = e^{-r(T-t^*)}\int_0^\infty (S-K)p(S^*,t^*;S,T)ds

Differentiating with respect to KK, the strike price, we get

VK=er(Tt)Kp(S,t;S,T)ds2VK2=er(Tt)p(S,t;S,T) \frac{\partial V}{\partial K} = e^{-r(T-t^*)}\int_K^\infty p(S^*,t^*;S,T)ds \\ \frac{\partial^2 V}{\partial K^2} = e^{-r(T-t^*)} p(S^*,t^*;S,T)

This gives the transition density in a tractable form,

p(S,t;S,T)=er(Tt)2VK2.p(S^*,t^*;S,T) = e^{r(T-t^*)} \frac{\partial^2 V}{\partial K^2}.

Since this is a density, we can apply the Fokker-Planck equation to get an equation for the time evolution of this density.

pT=122S2(σ2S2p)S(rSp)\frac{\partial p}{\partial T} = \frac{1}{2} \frac{\partial^2}{\partial S^2}(\sigma^2S^2p) - \frac{\partial}{\partial S}(rSp)

Now, instead considering the change in value with respect to the expiration date, T,T, subbing in for pT\frac{\partial p}{\partial T}, and integrating by parts we get

VT=rV+er(Tt)K(SK)pTdS=rV+er(Tt)K(SK)[122S2(σ2S2p)S(rSp)]dS=rV+12er(Tt)σ2K2p+rer(Tt)KSpdS \frac{\partial V}{\partial T} = -rV + e^{-r(T-t^*)} \int_K^\infty (S-K) \frac{\partial p}{\partial T} dS \\ = -rV + e^{-r(T-t^*)} \int_K^\infty (S-K) [\frac{1}{2} \frac{\partial^2}{\partial S^2}(\sigma^2S^2p) - \frac{\partial}{\partial S}(rSp)] dS \\ = -rV + \frac{1}{2}e^{-r(T-t^*)}\sigma^2K^2p + re^{-r(T-t^*)}\int_K^\infty SpdS

Finally, we get the form of the Black-Scholes equation,

VT=12σ2K22VK2rKVK\frac{\partial V}{\partial T} = \frac{1}{2}\sigma^2K^2 \frac{\partial^2 V}{\partial K^2} - rK\frac{\partial V}{\partial K}

The Traditional Derivation

This derivation is based on Options, Futures and Other Derivatives 4Hull, J. C. (2008). Options, Futures and Other Derivatives. Prentice Hall.. This argument is similar to that orginally made by Black and Scholes in their original paper. We start by assuming the underlying asset takes the form and behaves like a geometric Brownian motion. dSS=μdt+σdW,\frac{dS}{S} = \mu dt + \sigma dW, where W is some Wiener process. WW is the only source of randomness in this equation. We thus have E[dSS]=μdtE[\frac{dS}{S}] = \mu dt, with variance σ2dt.\sigma^2dt. Since we know the value at expiry of some European option is given by V(S,T)V(S,T), we can apply Itô’s lemma for two variables to get,

dV=(μSVS+Vt+12σ2S22VS2)dt+σSVSdW.dV = \left(\mu S \frac{\partial V}{\partial S} + \frac{\partial V}{\partial t} + \frac{1}{2}\sigma^2 S^2 \frac{\partial^2 V}{\partial S^2}\right)dt + \sigma S \frac{\partial V}{\partial S}\,dW.

Now consider a delta-neutral portfolio with value Π=V+VS\Pi = -V + \frac{\partial V}{\partial S}. Over some Δt\Delta t, the total change in value is ΔΠ=ΔV+VSΔS\Delta\Pi = -\Delta V + \frac{\partial V}{\partial S}\Delta S. Discretising and substituting in for ΔV\Delta V and ΔS\Delta S, we get

ΔΠ=(Vt12σ2S22VS2)Δt.\Delta \Pi = \left(-\frac{\partial V}{\partial t} - \frac{1}{2}\sigma^2 S^2 \frac{\partial^2 V}{\partial S^2}\right)\Delta t.

Notice now that the term involving WW is no longer part of the equation. Effectively, this portfolio is now riskless. This portfolio must have a rate of return equal to that of the risk-free rate of return, otherwise there would exist oppurtunities for riskless arbitrage. So we have rΠΔt=ΔΠr\Pi\Delta t = \Delta\Pi. We can then equate for ΔΠ\Delta\Pi.

(Vt12σ2S22VS2)Δt=r(V+SVS)Δt\left(-\frac{\partial V}{\partial t} - \frac{1}{2}\sigma^2 S^2 \frac{\partial^2 V}{\partial S^2}\right)\Delta t = r\left(-V + S\frac{\partial V}{\partial S}\right)\Delta t

Simplyfying, we arrive at the result of the Black-Scholes PDE:

Vt+12σ2S22VS2+rSVSrV=0\frac{\partial V}{\partial t} + \frac{1}{2}\sigma^2 S^2 \frac{\partial^2 V}{\partial S^2} + rS\frac{\partial V}{\partial S} - rV = 0

The Black-Scholes Formula

Imposing boundary conditions on the Black-Scholes Equation allows us to obtain a formula for the price of European options. This is the famous equation Black and Scholes revealed in their seminal work. The following boundary conditions are relevant for the Black-Scholes PDE derived in previous sections. We can solve this PDE as in 4Hull, J. C. (2008). Options, Futures and Other Derivatives. Prentice Hall. by applying these conditions and using methods of Itô calculus.

  • C(0,t)C(0,t) = 0 for all t
  • C(S,t)SC(S,t) \longrightarrow S as SS \longrightarrow \infty
  • C(S,T)=max{SK,0}C(S,T) = \max \{S-K,0\}

Condition 3 above gives the value of the option at the time of expiry, T. There are other boundary conditions available when considering different limits, but these give the same resulting equation as we should expect for consistency. Let us observe that the SDE is a Cauchy-Euler equation. We can introduce some change of variables to form it as a diffusion equation. Consider,

  • τ=Tt,\tau = T-t,
  • Cerτ,Ce^{r\tau}, and
  • x=lnS/K+(r12σ2)τ,x = \ln{S/K} + (r-\frac{1}{2}\sigma^2)\tau,

which yields the diffusion equation uτ=12σ22ux2.\frac{\partial u}{\partial \tau} = \frac{1}{2}\sigma^2\frac{\partial^2u}{\partial x^2}. Condition 3 becomes an initial condition u(x,0)=u0(x)=K(expmax{x,0}1).u(x,0) = u_0(x) = K(\exp{\max\{x,0\}}-1). Applying this initial condition, we can solve the diffusion equation using convolution methods.

u(x,τ)=1σ2πτu0(y)e(xy)22σ2τdy=Kex+12σ2τN(d1)KN(d2). u(x,\tau) = \frac{1}{\sigma \sqrt{2\pi\tau}}\int_{-\infty}^\infty u_0(y)e^{-\frac{(x-y)^2}{2\sigma^2\tau}}dy \\ = Ke^{x+\frac{1}{2}\sigma^2\tau}N(d_1)-KN(d_2).

Here d1d_1 and d2d_2 are

d1=1στ[(x+12σ2τ)+12σ2τ]d2=1στ[(x+12σ2τ)12σ2τ]. d_1 = \frac{1}{\sigma\sqrt{\tau}}[(x+\frac{1}{2}\sigma^2\tau)+\frac{1}{2}\sigma^2\tau] \\ d_2 = \frac{1}{\sigma\sqrt{\tau}}[(x+\frac{1}{2}\sigma^2\tau)-\frac{1}{2}\sigma^2\tau].

This is (without proof) equivalent to the traditional formulation. For a non-dividend-paying underlying asset,

C(St,t)=N(d1)StN(d2)PV(K)d1=1σTt[ln(StK)+(r+σ22)(Tt)]d2=d1σTtPV(K)=Ker(Tt) C(S_t, t) = N(d_1)S_t - N(d_2) PV(K) \\ d_1 = \frac{1}{\sigma\sqrt{T - t}}\left[\ln\left(\frac{S_t}{K}\right) + \left(r + \frac{\sigma^2}{2}\right)(T - t)\right] \\ d_2 = d_1 - \sigma\sqrt{T - t} \\ PV(K) = Ke^{-r(T - t)}
  • N()N(\cdot) is the cumulative normal distribution (CDF of a normal).
  • TtT-t is the time to expiry.
  • StS_t is the stock price (spot price).
  • KK is the strike price of the option.
  • rr is the risk free rate.
  • σ\sigma is the volatility of the asset.

The Black-Scholes formula, C(St,t)C(S_t,t), gives the price for a European style call option. There are two terms in this equation. The first term, N(d1)StN(d_1)S_t, is given with the stock price at present value. KK is the strike price, which is not a present value. We therefore discount the strike price by subtracting off the time-value of money. That is, we remove the interest one would get with a risk-free investment - think government bond. We then get PV(K)=Ker(Tt).PV(K) = Ke^{-r(T - t)}. The key here is that we assume the periodic daily returns are normally distributed 5Veisdal, J. (2020). The Black-Scholes formula, explained. Cantor's Paradise (Medium).. Integrating over this normal distribution on the interval [a,b][a,b] gives the probability of observing a return in that interval. N(d1N(d_1 is the expected value of the stock, multiplied by the probability that the stock price will reach or exceed the strike price. N(d2)N(d_2) is the probability that the stock price will be equal to or greater than the strike price when the stock option reaches the date of expiry.

Dangers & Pitfalls

The Black-Scholes model provided much needed mathematical rigour and legitimacy to options trading, however emphasis is placed on the fact that this is a model. The aphormism “all models are wrong, but some are useful” is especially relevant here since we are dealing with financial assets. Most of the issues with the model arise directly from the assumptions that are made about the market itself. The following limitations of the Black-Scholes model 5Veisdal, J. (2020). The Black-Scholes formula, explained. Cantor's Paradise (Medium). should be carefully considered before applying the techniques discussed in this paper.

  • Tail risk - Underestimation of extreme movements in stock prices. The assumption of normally distributed stock prices is criticised as extreme price movements have been shown to occur far more often than predicted by a normal distribution.
  • Liquidity risk - The assumption of instant and cost-less trading.
  • Volatility risk - The assumption of stationarity. Critics argue that large fluctuations in price cannot be ignored.
  • Gap risk - Assumption of continuous time and trading.
  • Independence - The assumption that price movements at subsequent time steps are independent of previous time steps is flawed. Studies of assets has shown short-term and long-term dependence.

Code

    from scipy.stats import norm

    def d1(sigma, time_to_expire, S, K, r):
        return (math.log(S/K) + (r + sigma**2 / 2) * (time_to_expire)) 
            / (sigma * math.sqrt(time_to_expire))

    def d2(sigma, time_to_expire, S, K, r):
        return d1(sigma, time_to_expire, S, K, r) - sigma * math.sqrt(time_to_expire)

    def PV(K, r, time_to_expire):
        return K * math.exp(-r*(time_to_expire))

    def black_scholes(sigma, time_to_expire, S, K, r):
        return norm.cdf(d1(sigma, time_to_expire, S, K, r)) * S 
        - norm.cdf(d2(sigma, time_to_expire, S, K, r)) * PV(K, r, time_to_expire)
    # Plot option value as a function of multiple variables
    from mpl_toolkits import mplot3d
    fig = plt.figure()
    ax = plt.axes(projection='3d')

    S = np.linspace(0.01,2,50)
    T = np.linspace(0,2,101)

    X, Y = np.meshgrid(S, T)
    Z = np.zeros((len(S),len(T)))

    for i in range(len(S)):
        for j in range(len(T)):
            Z[i,j] = black_scholes(volatility, T[j], S[i], 1, 0.02)

    scamap = plt.cm.ScalarMappable(cmap='inferno')
    fcolors = scamap.to_rgba(X)

    ax.view_init(45, -80)
    ax.plot_surface(X,Y,np.transpose(Z), facecolors=fcolors)
    ax.set_xlabel("S")
    ax.set_ylabel("T")
    ax.set_zlabel("Option Value")
    ax.set_title("Option value as a function of\ntime to expiry (T) and asset price (S)")

    fig.savefig("3DOptionPrices.png", dpi=400)

Further reading: “Black Scholes: A Simple Explanation” (YouTube).

References

  1. Durrett, R. (1996). Essentials of Stochastic Processes. Springer.
  2. SRKX What is Itô's lemma used for in quantitative finance?. Quantitative Finance Stack Exchange.
  3. Newsmth.net (2020). Ten different ways to derive Black–Scholes.
  4. Hull, J. C. (2008). Options, Futures and Other Derivatives. Prentice Hall.
  5. Veisdal, J. (2020). The Black-Scholes formula, explained. Cantor's Paradise (Medium).
St John

Written by St John

Author of the Asking Why Blog - a personal blog and website with everything I find interesting.

Comments are being migrated. Check back soon.