Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "cells": [
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {
- "collapsed": true
- },
- "outputs": [],
- "source": []
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "# Black-Scholes option pricing theory\n",
- "\n",
- "## Hedging and the partial differential equation\n",
- "\n",
- "The original derivation of the Black-Scholes partial differential equation was via stochastic calculus, Ito's lemma and a simple hedging argument (Black & Scholes, 1973).\n",
- "\n",
- "Assume that the underlying follows a lognormal random walk\n",
- "$$\n",
- "\tdS = \\mu S dt + \\sigma S dX.\n",
- "$$\n",
- "Use $\\Pi$ to denote the value of a portfolio of one long option position and a short position in some quantity $\\Delta$ of the underlying:\n",
- "$$ \n",
- "\t\\Pi = V(S,t) - \\Delta S.\n",
- "$$\n",
- "\n",
- "The first term on the right is the option and the second term is the short asset position.\n",
- "\n",
- "Ask .... $t$ to $t+dt$.\n",
- "$$\n",
- "\td\\Pi = dV -\n",
- "$$\n",
- "\n",
- "From Ito's lemma we have\n",
- "$$\n",
- "\td\\Pi = \\frac{\\partial V}{\\partial t}dt + \\frac{\\partial V}{\\partial S}dS +\n",
- "\t\\frac{1}{2} \\sigma^2 S^2 \\frac{\\partial^2 V}{\\partial S^2}dt -\n",
- "$$\n",
- "\n",
- ".....\n",
- "\n",
- "$$\n",
- "\td\\Pi = \\Big( \\frac{\\partial V}{\\partial t} + ...\\Big)dt.\n",
- "$$\n",
- "\n",
- "$$\n",
- "\tV(S,T)=\\max(S-K,0)\n",
- "$$"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 1,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "8.916035060662303\n"
- ]
- }
- ],
- "source": [
- "from math import *\n",
- "# Cumulative normal distribution\n",
- "\n",
- "def CND(X):\n",
- "\n",
- " (a1,a2,a3,a4,a5) = (0.31938153, -0.356563782, 1.781477937, \n",
- "\n",
- " -1.821255978, 1.330274429)\n",
- " L = abs(X)\n",
- "\n",
- " K = 1.0 / (1.0 + 0.2316419 * L)\n",
- "\n",
- " w = 1.0 - 1.0 / sqrt(2*pi)*exp(-L*L/2.) * (a1*K + a2*K*K + a3*pow(K,3) +\n",
- "\n",
- " a4*pow(K,4) + a5*pow(K,5))\n",
- " if X<0:\n",
- "\n",
- " w = 1.0-w\n",
- "\n",
- " return w\n",
- "# Black Sholes Function\n",
- "\n",
- "def BlackSholes(CallPutFlag,S,X,T,r,v):\n",
- "\n",
- " d1 = (log(S/X)+(r+v*v/2.)*T)/(v*sqrt(T))\n",
- "\n",
- " d2 = d1-v*sqrt(T)\n",
- " if CallPutFlag=='c':\n",
- "\n",
- " return S*CND(d1)-X*exp(-r*T)*CND(d2)\n",
- "\n",
- " else:\n",
- "\n",
- " return X*exp(-r*T)*CND(-d2)-S*CND(-d1)\n",
- " \n",
- "call = BlackSholes('c',100,100,1,0.02,0.2)\n",
- "\n",
- "print (call)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {
- "collapsed": true
- },
- "outputs": [],
- "source": []
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- },
- "language_info": {
- "codemirror_mode": {
- "name": "ipython",
- "version": 3
- },
- "file_extension": ".py",
- "mimetype": "text/x-python",
- "name": "python",
- "nbconvert_exporter": "python",
- "pygments_lexer": "ipython3",
- "version": "3.6.1"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 2
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement