Implementing Newton-Raphson method to find strike price in Black-Scholes but the error value keeps increasing?

333 Views Asked by At

I'm essentially writing VBA code to root solve for the strike price (K) given a premium (C or P). However, when I'm writing this code in VBA, I'm finding that the relative error term keeps on increasing rather than decreasing as it gets closer to the root. I'm not able to diagnose exactly why this is happening. Here is the equation for those unfamiliar-

Black-Scholes formula

One of the reasons I think the error isn't converging is because of the fact that K is being used to find N(d1) and in the final call option price formula. If someone could provide some insight into what is going wrong and how I should tackle this issue I would be very grateful. Is there some other root-finding algorithm I should implement? I have attached my code below as well.

Sub backsolve_vanilla_call()
Dim f_x As Double
Dim dydx As Double
Dim d1 As Double
Dim d2 As Double
Dim N_d1 As Double
Dim N_d2 As Double
Dim spot As Double
Dim strike As Double
Dim vol As Double
Dim r As Double
Dim tenor As Double
Dim prem As Double
Dim ea As Double
Dim xr As Double
Dim xi As Double

spot = Worksheets("Vanilla").Cells(3, 6)
tenor = Worksheets("Vanilla").Cells(5, 6)
vol = Worksheets("Vanilla").Cells(6, 6)
r = Worksheets("Vanilla").Cells(7, 6)
prem = Worksheets("Vanilla").Cells(8, 6)
xi = Worksheets("Vanilla").Cells(3, 8)

ea = 100
Do While ea > 0.01
    d1 = (Application.WorksheetFunction.Ln(spot / xi) + (tenor * (r + (vol ^ 2 / 2)))) / (vol * (tenor ^ 0.5))
    d2 = d1 - (vol * (tenor ^ 0.5))
    N_d1 = Application.WorksheetFunction.Norm_S_Dist(d1, True)
    N_d2 = Application.WorksheetFunction.Norm_S_Dist(d2, True)
    
    f_x = spot * N_d1 - (xi * Exp(-r * tenor) * N_d2) - prem
    
    dydx = N_d1
    xr = xi - (f_x / dydx)
    
    ea = Abs((xr - xi) / xr)
    xi = xr
Loop
Worksheets("Vanilla").Cells(4, 6) = xr