Trinomialtree
- To: mathgroup at smc.vnet.net
- Subject: [mg30920] Trinomialtree
- From: Yannis.Paraskevopoulos at ubsw.com
- Date: Thu, 27 Sep 2001 02:16:37 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Hi all, I have been having problem executing the following code. Could you please tell me what am I doing wrong? Best regards and thanks in advance ============Mathematica Code=============================================== TrinomialTree[AmEurFlag_Symbol,CallPutFlag_Symbol,S_,X_,T_,r_,b_,v_,n_]: = Module[{OptionValue,dt,pu,pd,pm,u,d,Df,z}, dt=T/n; u=Exp[v*Sqrt[2*dt]]; d=Exp[-v*Sqrt[2*dt]]; pu=((Exp[b*dt/2]-Exp[-v*Sqrt[dt/2]])/(Exp[v*Sqrt[dt/2]]- Exp[-v*Sqrt[dt/2]]))^2; pd=((Exp[v*dt/2]-Exp[b*Sqrt[dt/2]])/(Exp[v*Sqrt[dt/2]]- Exp[-v*Sqrt[dt/2]]))^2; pm=1-pu-pd; Which[CallPutFlag=c,z==1,CallPutFlag=p,z==-1]; OptionValue= Table[Max[0,z*(S*u^Max[i-n,0]*d^Max[n*2-n-i,0]-X)],{i,0,2*n}]; Which[AmEurFlag=e,OptionValue=Table[(pu*OtoptionValue[[i+2]] +pm*OptionValue[[i+1]]+pd*OptionValue[[i]])*Df,{j,n-1, 0,-1},{i,0,j*2}],AmEurFlag=a, OptionValue= Table[Max[(z*(S*u^Max[i-j,0]*d^Max[j*2-j-i,0]-X)),(pu* OptionValue[[i+1]]+pd*OptionValue[[i]])*Df],{j,n-1, 0,-1},{i,0,j*2}]]; OptionValue ] ================================================================================= Visit our website at http://www.ubswarburg.com This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. This message is provided for informational purposes and should not be construed as a solicitation or offer to buy or sell any securities or related financial instruments.