美式看跌期权:
- function [] =
- trinomialAmerican(T,n,K,r,sigma,S0)
- T ;% experiation date
- n ;%total number of periods
- K; %exercise price
- r ;%risk free interest rate
- sigma ;%vloatility of
- S0 ;
- deltat=T/n;
- u=exp(sigma*sqrt(deltat));
- d=exp(-sigma*sqrt(deltat));
- p=(sigma^2*deltat+exp(2*r*deltat)-exp(r*deltat)*(1+d)+d)/((u-1)*(u-d)); %risk adjusted probability
- q=(exp(r*deltat)-1-p*(u-1))/(d-1);
- m=1-p-q;
- for i=1:n
- for j=1:(2*i+1)
- s(j,i)=d^(i-j+1)*S0; % stock price
- end
- end
- for i=1:(2*n+1)
- x(i,n)=max(s(i,n)-K,0);
- y(i,n)=max(-s(i,n)+K,0);
- end
- for g=1:(n-1)
- i=n-g;
- for j=1:(2*i+1)
- x(j,i)=max(max((s(j,i)-K),0),(m*x(j+1,i+1)+p*x(j+2,i+1)+q*x(j,i+1))*exp(-r*deltat)); % call
- y(j,i)=max(max((-s(j,i)+K),0),(m*y(j+1,i+1)+p*y(j+2,i+1)+q*y(j,i+1))*exp(-r*deltat)); % European put
- end
- end
- c=(m*x(2,1)+p*x(3,1)+q*x(1,1))*exp(-r*deltat)
- p=(m*y(2,1)+p*y(3,1)+q*y(1,1))*exp(-r*deltat)
亚式期权:
- function [] =
- trinomialAsian(T,n,K,r,sigma,S0,N)
- T % expiration date;
- n % numbers of steps;
- K % exercise price;
- r % risk free rate;
- sigma % volitility of stock;
- S0 % present price of stock;
- deltat=T/n;
- N % times of monte carlo;
文件下载于:matlab做三叉树的美式和欧式期权


雷达卡




京公网安备 11010802022788号







