I have this code (bare in mind that S= Stock price, X=Strike price, T=Years to maturity, r= Risk-free rate, v=Volatility):
Sub button5_click As Button
'// The Black and Scholes (1973) Stock option formula
S = edittext1.Text
X = edittext2.Text
T = edittext4.Text
r = edittext3.Text
v = edittext5.Text
d1 = (Logarithm(10,(S / X)) + (r + v ^ 2 / 2) * T) / (v * Sqrt(T))
d2 = d1 - v * Sqrt(T)
BlackScholes = S * CND(d1) - X * Exp(-r * T) * CND(d2)
'// The cumulative normal distribution function
Const a1 = 0.31938153: Const a2 = -0.356563782: Const a3 = 1.781477937:
Const a4 = -1.821255978: Const a5 = 1.330274429
L = Abs(X)
K = 1 / (1 + 0.2316419 * L)
CND = 1 - 1 / Sqrt(2 * 3.14159) * Exp(-L ^ 2 / 2) * (a1 * K + a2 * K ^ 2 + a3 * K ^ 3 + a4 * K ^ 4 + a5 * K ^ 5)
If X < 0 Then
CND = 1 - CND
End If
End Sub
Is the keyword 'power' a natural logarithm. Is there anything else I'm doing wrong?
Sub button5_click As Button
'// The Black and Scholes (1973) Stock option formula
S = edittext1.Text
X = edittext2.Text
T = edittext4.Text
r = edittext3.Text
v = edittext5.Text
d1 = (Logarithm(10,(S / X)) + (r + v ^ 2 / 2) * T) / (v * Sqrt(T))
d2 = d1 - v * Sqrt(T)
BlackScholes = S * CND(d1) - X * Exp(-r * T) * CND(d2)
'// The cumulative normal distribution function
Const a1 = 0.31938153: Const a2 = -0.356563782: Const a3 = 1.781477937:
Const a4 = -1.821255978: Const a5 = 1.330274429
L = Abs(X)
K = 1 / (1 + 0.2316419 * L)
CND = 1 - 1 / Sqrt(2 * 3.14159) * Exp(-L ^ 2 / 2) * (a1 * K + a2 * K ^ 2 + a3 * K ^ 3 + a4 * K ^ 4 + a5 * K ^ 5)
If X < 0 Then
CND = 1 - CND
End If
End Sub
Is the keyword 'power' a natural logarithm. Is there anything else I'm doing wrong?