Option Pricing Module


In [1]:
import OptionPricing as op

In [2]:
#help(op)

In [3]:
c = op.BSCall(mat=1, strike=100, spot=100, sig=0.2, rate=0.05, yld=0.)
p = op.BSPut(mat=1, strike=100, spot=100, sig=0.2, rate=0.05, yld=0.)
dc = op.BSDCall(mat=1, strike=100, spot=100, sig=0.2, rate=0.05, yld=0.)
dp = op.BSDPut(mat=1, strike=100, spot=100, sig=0.2, rate=0.05, yld=0.)
o = p
spot = range(60,140)

Present Value


In [4]:
plot(spot, list((o.PV(spot=s),o.PV(spot=s, sig=0.05)) for s in spot))


Out[4]:
[<matplotlib.lines.Line2D at 0x7f921e20dcc0>,
 <matplotlib.lines.Line2D at 0x7f921e214080>]

Delta and Cash Delta


In [5]:
plot(spot, list((o.Delta(spot=s),o.Delta(spot=s, sig=0.1)) for s in spot))


Out[5]:
[<matplotlib.lines.Line2D at 0x7f921e078518>,
 <matplotlib.lines.Line2D at 0x7f921e078898>]

In [6]:
plot(spot, list((100.*o.Delta(spot=s),o.DeltaCash(spot=s)) for s in spot))


Out[6]:
[<matplotlib.lines.Line2D at 0x7f921e05ba58>,
 <matplotlib.lines.Line2D at 0x7f921e05bdd8>]

Gamma and Cash Gamma


In [7]:
plot(spot, list((o.Gamma(spot=s),o.Gamma(spot=s, sig=0.1)) for s in spot))


Out[7]:
[<matplotlib.lines.Line2D at 0x7f921dfbc6a0>,
 <matplotlib.lines.Line2D at 0x7f921dfbca20>]

In [8]:
plot(spot, list((10000*o.Gamma(spot=s),o.GammaCash(spot=s)) for s in spot))


Out[8]:
[<matplotlib.lines.Line2D at 0x7f921dfa4860>,
 <matplotlib.lines.Line2D at 0x7f921dfa4be0>]

Theta (and Gamma)


In [9]:
plot(spot, list((o.Theta(spot=s),o.Gamma(spot=s)) for s in spot))


Out[9]:
[<matplotlib.lines.Line2D at 0x7f921df034e0>,
 <matplotlib.lines.Line2D at 0x7f921df03860>]

Vega, Volga, Vanna


In [10]:
plot(spot, list((o.Vega(spot=s),o.Gamma(spot=s, sig=0.1)) for s in spot))


Out[10]:
[<matplotlib.lines.Line2D at 0x7f921dee7978>,
 <matplotlib.lines.Line2D at 0x7f921dee7cf8>]

In [11]:
plot(spot, list((o.Vanna(spot=s),o.Vanna(spot=s, sig=0.1)) for s in spot))


Out[11]:
[<matplotlib.lines.Line2D at 0x7f921de4f6d8>,
 <matplotlib.lines.Line2D at 0x7f921de4fa58>]

In [12]:
plot(spot, list((o.Volga(spot=s),o.Volga(spot=s, sig=0.1)) for s in spot))


Out[12]:
[<matplotlib.lines.Line2D at 0x7f921ddb09b0>,
 <matplotlib.lines.Line2D at 0x7f921ddb0d30>]

Rho and RhoYld


In [13]:
plot(spot, list((o.Rho(spot=s),o.RhoYld(spot=s)) for s in spot))


Out[13]:
[<matplotlib.lines.Line2D at 0x7f921dd93ef0>,
 <matplotlib.lines.Line2D at 0x7f921dd982b0>]