필터 지우기
필터 지우기

Black-Scholes formula

조회 수: 4 (최근 30일)
Francesco Rossi
Francesco Rossi 2019년 9월 30일
댓글: the cyclist 2019년 9월 30일
I tried to build this function, but when I try it, this gives me different result, compared to the online solvers.
Does anyone spots the error?
function [C] = BlackScholesCall(S,K,t,r,sd)
% Calculates the price of a call option
% INPUT S 1x1 ... Current stock price (underlying)
% K 1x1 ... Strike price
% t 1x1 ... Time to maturity
% r 1x1 ... Risk-free interest rate
% sd 1x1 ... standard deviation (volatility of the underlying)
% OUTPUT C 1x1 ... The price of a call option
% USAGE BlackScholesCall(S,K,t,r,sd)
C = S*normcdf((log(S/K)+(r+(1/2)*sd^2)^t)/(sd*sqrt(t)))-K*exp(-r*t)*normcdf((log(S/K)+(r+(1/2)*sd^2)^t)/(sd*sqrt(t))-sd*sqrt(t));
end

채택된 답변

the cyclist
the cyclist 2019년 9월 30일
Both places where you have
(r+(1/2)*sd^2)^t
it should be
(r+(1/2)*sd^2)*t
FYI, I think this would be been easier to debug if you had defined the variables d1 and d2, as in the wikipedia page. That's how I broke it out and found the error.
  댓글 수: 2
Francesco Rossi
Francesco Rossi 2019년 9월 30일
Many thanks!
the cyclist
the cyclist 2019년 9월 30일
The best form of thanks is to upvote and/or accept helpful answers. This rewards the contributor, and also points future users to useful answers.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Price and Analyze Financial Instruments에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by