Skip to content

Instantly share code, notes, and snippets.

View ajokela's full-sized avatar

A.C. Jokela ajokela

View GitHub Profile
@ajokela
ajokela / bjerksund_stensland.py
Created June 1, 2024 02:01 — forked from crapher/bjerksund_stensland.py
Bjerksund Stensland Volatility and Price calculation
from math import *
# Cumulative standard normal distribution
def cdf(x):
return (1.0 + erf(x / sqrt(2.0))) / 2.0
# Intermediate calculation used by both the Bjerksund Stensland 1993 and 2002 approximations
def phi(s, t, gamma, h, i, r, a, v):
lambda1 = (-r + gamma * a + 0.5 * gamma * (gamma - 1) * v**2) * t
dd = -(log(s / h) + (a + (gamma - 0.5) * v**2) * t) / (v * sqrt(t))