- #1
spenghali
- 14
- 0
So I have made this code to price a european call, hedge, and record the hedging error at each time step. I then take the mean and variance of the hedging error which is suppose to go to zero as dt goes to zero. Here's what I have, my question will follow:
clear;
%Parameters
M = 200;
dt = 0.5;
T = repmat(365/4:-dt:0,M,1);
N = size(T,2);
K(1:M,1:N) = 50;
r(1:M,1:N) = 0.01;
sigma(1:M,1:N) = 0.25;
toss = randn(M,N-1);
S = cumsum([K(:,1), toss],2); %Stock Paths
V = blsprice(S, K, r, T, sigma); %BSM Price
delta = blsdelta(S, K, r, T, sigma); %BSM delta
X = V-(delta.*S); %Portfolio value
mean = mean(mean(X)) %Sample mean
var = var(var(X)) %Sample varianceSo my problem is that when I decrease dt to make the time steps smaller, some of the underlyings (stock prices, S) become negative and then the 'blsprice' function cannot compute the price of the option because it is expecting a non-negative entry. Any suggestions on how to solve this? The model works fine for dt = 0.5, I just cannot make it smaller. Thanks for any input.
clear;
%Parameters
M = 200;
dt = 0.5;
T = repmat(365/4:-dt:0,M,1);
N = size(T,2);
K(1:M,1:N) = 50;
r(1:M,1:N) = 0.01;
sigma(1:M,1:N) = 0.25;
toss = randn(M,N-1);
S = cumsum([K(:,1), toss],2); %Stock Paths
V = blsprice(S, K, r, T, sigma); %BSM Price
delta = blsdelta(S, K, r, T, sigma); %BSM delta
X = V-(delta.*S); %Portfolio value
mean = mean(mean(X)) %Sample mean
var = var(var(X)) %Sample varianceSo my problem is that when I decrease dt to make the time steps smaller, some of the underlyings (stock prices, S) become negative and then the 'blsprice' function cannot compute the price of the option because it is expecting a non-negative entry. Any suggestions on how to solve this? The model works fine for dt = 0.5, I just cannot make it smaller. Thanks for any input.