MATLAB Matlab coding problem (Black-Scholes Option Pricing content)

  • Thread starter spenghali
  • Start date
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 variance


So 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.
 

Want to reply to this thread?

"Matlab coding problem (Black-Scholes Option Pricing content)" You must log in or register to reply here.

Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving
Top