You are on page 1of 3

Barrier option pricing

I am treating the following problem of double barrier option:

I want to price an option which has the following features: A trigger level 𝐻1 below which, if the
underlying asset price is below for 5 days, it expires worthless, a trigger level 𝐻2 above which, the option
gets knocked-in, a strike price 𝐾, lifetime 𝑇.

Model for the underlying asset price:

𝑆𝑡 follows the equation 𝑑𝑆𝑡 = 𝜇𝑆𝑡 𝑑𝑡 + 𝜎𝑆𝑡 𝑑𝐵𝑡 with 𝜇, 𝜎 constant.

I use Euler scheme to simulate 𝑆𝑡 on the interval [0,T].

That is: 𝑆𝑡𝑖+1 = 𝑆𝑡𝑖 + 𝜇ℎ ∗ 𝑆𝑡𝑖 + 𝜎√ℎ𝜖𝑆𝑡𝑖 , where 𝜖 ∼ 𝑁(0,1) and 𝑖 = 0,1, … , 𝑁 − 1, 𝑁 𝑏𝑒𝑖𝑛𝑔 the no. of
knots.

VBA CODE for this:


Function gbm_path(S As Double, mu As Double, sigma As Double, T As Double, N
As Long) As Variant
'I will assume the geometric brownian motion as model, with constant
drift and diffusion coefficients'
'I am applying Euler scheme'
'N is the number of knots'
Dim path As Variant, i As Long
ReDim path(1 To N, 1 To 1)
path(1, 1) = S
For i = 2 To N
path(i, 1) = path(i - 1, 1) + mu * T / N * path(i - 1, 1) + sigma *
Sqr(T / N) * WorksheetFunction.NormInv(Rnd, 0, 1) * path(i - 1, 1)
Next i
gbm_path = path
End Function

The next sub-procedure tests for 21 samples, on a lifetime of 2 years, a path for 𝑆𝑡 , 𝑡 ∈ [0,2].
Sub test_gbm_path()
Sheets(1).Activate
Dim rng As Range, N As Long, path As Variant
path = gbm_path(100, 0.1, 0.4, 2, 21)
Set rng = Range("A2").Resize(21, 1)
' MsgBox (path(2) & " " & path(3))
rng.Value = path
End Sub

The next would be designing the payoff according to the CEO request.
First we need to test that there are no 5 consecutive days for which the prices lies below 𝐻1 .

Then we need to see that there are 10 consecutive days for which the price lies above 𝐻2 , provided the
first condition is followed.
Function payoff_double_barrier(path As Variant, H1 As Double, H2 As Double, K
As Double) As Double
'If 5 days in a row the price is below H1, the payoff of the double
barrier is 0'
'If 10 days in a row the price is above H2, the payoff knocks-in'
'H1 is the lower trigger, H2 is the upper trigger,K is the strike price'
Dim ok1 As Integer, ok2 As Integer, i As Long
ok1 = 1: ok2 = 0
For i = 5 To UBound(path)
If path(i - 4, 1) < H1 And path(i - 3, 1) < H1 And path(i - 2, 1) <
H1 And path(i - 1, 1) < H1 And path(i, 1) < H1 Then
payoff_double_barrier = 0
ok1 = 0 'The option is knocked out'
Exit For
End If
Next i
For i = 10 To UBound(path)
If path(i - 9, 1) > H2 And path(i - 8, 1) > H2 And path(i - 7, 1) >
H2 And path(i - 6, 1) > H2 And path(i - 5, 1) > H2 And _
path(i - 4, 1) > H2 _
And path(i - 3, 1) > H2 And path(i - 2, 1) > H2 And path(i - 1, 1) >
H2 And path(i, 1) > H2 And ok1 = 1 Then
ok2 = 1 'The option is knocked in
payoff_double_barrier = WorksheetFunction.Max(path(UBound(path), 1) -
K, 0)
Exit For
End If
Next i
If ok2 = 0 Then
payoff_double_barrier = 0
End If
End Function
I test the payoff for the path generated before (See A2:A22 values).
Sub test_payoff_barrier()
Dim path As Variant, rng As Range
ReDim path(1 To 21, 1 To 1)
Sheets(1).Activate
path = Range("A2:A22").Value
MsgBox payoff_double_barrier(path, 50, 60, 30)
End Sub

Finally, I compute the price after the simple Monte Carlo design:

I take all the sample paths, their payoffs, and then compute the discounted average.
Function price_double_barrier(S As Double, mu As Double, sigma As Double, T
As Double, N As Long, H1 As Double, H2 As Double, K As Double, r As Double,
size As Long)
res = 0
For i = 1 To size
path = gbm_path(S, mu, sigma, T, N)
res = res + payoff_double_barrier(path, H1, H2, K)
Next i
price_double_barrier = Exp(-r * T) * res / size
End Function
Then I test the price of a double barrier call option of current asset price S=100, trigger level down =
𝐻1 = 50, 𝐻2 = 60, strike price 𝐾 = 100.
Sub test_price()
Dim S As Double, mu As Double, sigma As Double, T As Double, N As Long,
H1 As Double, H2 As Double, K As Double, r As Double, size As Long
S = 100: mu = 0.1: sigma = 0.4: T = 1: N = 10: H1 = 50: H2 = 60: K = 100:
r = 0.05: size = 1000
MsgBox price_double_barrier(S, mu, sigma, T, N, H1, H2, K, r, size)
End Sub

You might also like