10.12.2019 Views

Python for Finance

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

The relationship between input values and

option values

When the volatility of an underlying stock increases, both its call and put values

increase. The logic is that when a stock becomes more volatile, we have a better

chance to observe extreme values, that is, we have a better chance to exercise our

option. The following Python program shows this relationship:

Chapter 10

import numpy as np

import p4f as pf

import matplotlib.pyplot as plt

s0=30

T0=0.5

sigma0=0.2

r0=0.05

x0=30

sigma=np.arange(0.05,0.8,0.05)

T=np.arange(0.5,2.0,0.5)

call_0=pf.bs_call(s0,x0,T0,r0,sigma0)

call_sigma=pf.bs_call(s0,x0,T0,r0,sigma)

call_T=pf.bs_call(s0,x0,T,r0,sigma0)

plt.title("Relationship between sigma and call, T and call")

plt.plot(sigma,call_sigma,'b')

plt.plot(T,call_T,'r')

plt.annotate('x=Sigma, y=call price', xy=(0.6,5), xytext=(1,6), arrowp

rops=dict(facecolor='blue',shrink=0.01),)

plt.annotate('x=T(maturity), y=call price', xy=(1,3), xytext=(0.8,1),

arrowprops=dict(facecolor='red',shrink=0.01),)

plt.ylabel("Call premium")

plt.xlabel("Sigma (volatility) or T(maturity) ")

plt.show()

[ 355 ]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!