|
|||||||||
| General Finance Discuss general personal finance issues and home accounting not covered on the other finance boards. |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
I want to solve the bond pricing equation of Cox, IngersoU. and Ross model.I wrote some code in matlab,but result look strange.It is very small.I want some one can help me to check the code or give me some information.thanks a million!!!
Code: dr = 0.005; Nr = 8; dt = 0.1; Nt = 100; a=0.2339*0.0189; b=0.2339; delta=sqrt(0.0073); u(:,1) = ones(Nr+1,1); % Initial condition for j=1:Nr+1 alpha=(1/2)*delta^2*dr*(j-1); mu=(a-b*dr*(j-1)); rho=dt/(dr)^2; x(j)=1+2*rho*alpha+dr*mu*rho+dt*dr*(j-1); end for p=1:Nr alpha=(1/2)*delta^2*dr*(p-1); mu=(a-b*dr*(p-1)); rho=dt/(dr)^2; y(p)=-rho*alpha-dr*mu*rho; end for q=1:Nr alpha=(1/2)*delta^2*dr*(q); mu=(a-b*dr*(q)); rho=dt/(dr)^2; z(q)=-rho*alpha; end A=diag(x)+diag(y,1)+diag(z,-1); for i=1:Nt u(:,i+1)=inv(A)*u(:,i); end |
|
|
|





