[英]How to write a matlab code for a given algorithm from a given array and function?
[英]Is my Matlab code correctly implementing this given algorithm?
我得到了一些错误的结果,而且我在代码中找不到任何错误,因此我在考虑是否有人可以确定我是否正确实现了此Binomial-Lattice算法。 这是我得到的结果以及期望得到的结果:
实际结果:我从[S0,K,sigma,r,T,nColumn]=[1.5295e+009,6e+008,0.0023,0.12,20,15]
,我得到p=32.5955
, price=-6.0e+18
和BLOV_lattice
如图1所示。
预期成绩:
p
是概率,因此它不应大于1。即使我将nColumn
增加到1000,在上述实际结果中p
仍大于1。 price
应与S0
相同,即我在第一列中的数字,即向后归纳后,即应该具有向后兼容性。 图1:BLOV_lattice
我的Matlab代码是:
function [price,BLOV_lattice]=BLOV_general(S0,K,sigma,r,T,nColumn)
% BLOV stands for Binomial Lattice Option Valuation
%% Constant parameters
del_T=T./nColumn; % where n is the number of columns in binomial lattice
u=exp(sigma.*sqrt(del_T));
d=1./u;
p=(exp(r.*del_T)-d)./(u-d);
a=exp(-r.*del_T);
%% Initializing the lattice
Stree=zeros(nColumn+1,nColumn+1);
BLOV_lattice=zeros(nColumn+1,nColumn+1);
%% Developing the lattice
%# Forward induction
for i=0:nColumn
for j=0:i
Stree(j+1,i+1)=S0.*(u.^j)*(d.^(i-j));
end
end
for i=0:nColumn
BLOV_lattice(i+1,nColumn+1)=max(Stree(i+1,nColumn+1)-K,0);
end
%# Backward induction
for i=nColumn:-1:1
for j=0:i-1
BLOV_lattice(j+1,i)=a.*(((1-p).*BLOV_lattice(j+1,i+1))+(p.*BLOV_lattice(j+2,i+1)));
end
end
price=BLOV_lattice(1,1);
%% Converting the lattice of upper traingular matrix to a tree format
N = size(BLOV_lattice,1); %# The size of the rows and columns in BLOV_lattice
BLOV_lattice = full(spdiags(spdiags(BLOV_lattice),(1-N):2:(N-1),zeros(2*N-1,N)));
参考文献:
考克斯,约翰·C,斯蒂芬·罗斯和马克·鲁宾斯坦。 1979年,“期权定价:一种简化方法”。 金融经济学杂志7:229-263。
E. Georgiadis,“二项期权定价没有封闭式解决方案”。 《算法金融学》(2011年)。
小理查德·雷德尔曼(Richard J. 1979年。“两种状态的期权定价”。 金融杂志24:1093-1110。 doi:10.2307 / 2327237
据我所知,您在引用中的任何地方都没有定义(显然如此)将p
为p=(exp(r.*del_T)-d)./(ud)
。
从代码中推断出要评估的选项不是那么简单。
我能得到的最接近的解释是p
(在您的情况下)简单地归结为p= (1- d)/ (u- d)
,其中您的参数为0.49934
。 (至少一个合理的值可以解释为概率!)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.