Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions QID-1143-SFEgamma/Metainfo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ See also: SFEvanna, SFEvolga, SFEdelta, SFEvega, SFEtheta, SFEspeed, SFEcharmcal

Author: Wolfgang K. Haerdle

Author[Python]: David Schulte

Submitted: Mon, November 24 2014 by Awdesch Melzer

Example: 'For given [lower, upper] bound of Asset price S like [50,150] and [lower, upper] bound of time to maturity tau like [0.01, 1] a plot of the Gamma of a call option is produced.'
78 changes: 0 additions & 78 deletions QID-1143-SFEgamma/README.md

This file was deleted.

Binary file added QID-1143-SFEgamma/SFEgamma.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions QID-1143-SFEgamma/SFEgamma.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import numpy as np
from scipy.stats import norm
from matplotlib import pyplot as plt
from matplotlib import cm

# parameter settings
save_figure = True
S_min = 50 # lower bound of Asset Price
S_max = 150 # upper bound of Asset Price
tau_min = 0.05 # lower bound of Time to Maturity
tau_max = 1 # upper bound of Time to Maturity
K = 100 # exercise price
r = 0.1 # riskfree interest rate
sig = 0.25 # volatility
d = 0.2 # dividend rate
steps = 60 # steps

tau = np.linspace(tau_min, tau_max, steps)
S = np.linspace(S_max, S_min, steps)


def get_gamma(tau, S, K, r, d, sig):
y = (np.log(S/K) + (r - d - sig**2/2) * tau)/(sig * np.sqrt(tau))

return np.exp(-d*tau)*norm.pdf(y+sig*np.sqrt(tau))/(S * sig * np.sqrt(tau))


X, Y = np.meshgrid(tau, S)
fig, ax = plt.subplots(subplot_kw={"projection": "3d"})
ax.plot_surface(X, Y, get_gamma(X, Y, K, r, d, sig), cmap=cm.viridis)
ax.set_title('Dependence of Gamma on Stock Price and Time to Maturity')
ax.set_xlabel('Time to Maturity')
ax.set_ylabel('Stock Price')
ax.set_zlabel('Gamma')
plt.show()

if save_figure:
fig.savefig('SFEgamma.png', transparent=True)
17 changes: 17 additions & 0 deletions QID-1389-SFEBSCopt2/SFEBSCopt2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import numpy as np
from scipy.stats import norm

# input variables
K = 100
S = 98
r = 1/20
b = 1/20
tau = 20/52
sig = 1/5

# main computation
y = (np.log(S/K) + (b - (sig**2)/2) * tau)/(sig * np.sqrt(tau))
c = np.exp(-(r - b) * tau) * S * norm.cdf(y + sig * np.sqrt(tau)) - np.exp(-r * tau) * K * norm.cdf(y)

# output
print("The call price is {}".format(c))
2 changes: 2 additions & 0 deletions QID-1414-SFEtheta/Metainfo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ See also: SFEvanna, SFEvolga, SFEdelta, SFEgamma, SFEvega, SFEspeed, SFEcharmcal

Author: Ekaterina Ignatieva, Ying Chen, Christian M. Hafner

Author[Python]: David Schulte

Submitted: Sun, December 04 2011 by Dedy Dwi Prastyo

Example: 'For given [lower, upper] bound of Asset price S like [50,150] and [lower, upper] bound of time to maturity tau like [0.05, 1] a plot of the Theta of a call option is produced.'
90 changes: 0 additions & 90 deletions QID-1414-SFEtheta/README.md

This file was deleted.

Binary file added QID-1414-SFEtheta/SFEtheta.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions QID-1414-SFEtheta/SFEtheta.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import numpy as np
from scipy.stats import norm
from matplotlib import pyplot as plt
from matplotlib import cm

# parameter settings
save_figure = True
S_min = 50 # lower bound of Asset Price
S_max = 150 # upper bound of Asset Price
tau_min = 0.05 # lower bound of Time to Maturity
tau_max = 1 # upper bound of Time to Maturity
K = 100 # exercise price
r = 0.1 # riskfree interest rate
sig = 0.25 # volatility
d = 0.2 # dividend rate
steps = 60 # steps

tau = np.linspace(tau_min, tau_max, steps)
S = np.linspace(S_max, S_min, steps)


def get_theta(tau, S, K, r, d, sig):
y = (np.log(S/K) + (r - d - sig**2/2) * tau)/(sig * np.sqrt(tau))

return -np.exp(-d*tau)*sig*S/(2*np.sqrt(tau))*norm.pdf(y+sig*np.sqrt(tau)) - r*K*np.exp(-r*tau)*norm.cdf(y)


X, Y = np.meshgrid(tau, S)
fig, ax = plt.subplots(subplot_kw={"projection": "3d"})
ax.plot_surface(X, Y, get_theta(X, Y, K, r, d, sig), cmap=cm.viridis)
ax.set_title('Dependence of Theta on Stock Price and Time to Maturity')
ax.set_xlabel('Time to Maturity')
ax.set_ylabel('Stock Price')
ax.set_zlabel('Theta')
plt.show()

if save_figure:
fig.savefig('SFEtheta.png', transparent=True)
2 changes: 2 additions & 0 deletions QID-1428-SFEvega/Metainfo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ See also: SFEvanna, SFEvolga, SFEdelta, SFEgamma, SFEtheta, SFEspeed, SFEcharmca

Author: Ying Chen, Christian M. Hafner

Author[Python]: David Schulte

Submitted: Tue, July 01 2014 by Petra Burdejova

Example: 'For given [lower, upper] bound of Asset price S like [50,150] and [lower, upper] bound of time to maturity tau like [0.01, 1] a plot of the Vega of a call option is produced.'
87 changes: 0 additions & 87 deletions QID-1428-SFEvega/README.md

This file was deleted.

Binary file added QID-1428-SFEvega/SFEvega.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading