# Bond price-yield curve

ratprint:false; numer:TRUE;kill(all);

FORMULA 2-B  Bond price

F2: PV=nusum(c*F/cTimes/(1+r/Times)^(i*Times/cTimes), i, 1, N*cTimes)+F/(1+r/Times)^(N*Times);

p1:ev(F2, c:0.04, cTimes:1, Times:1,F:100);

plot3d(rhs(p1), [r, 0, 0.2], [N, 0, 10]);

p2:ev(F2, c:0.04, cTimes:1, Times:1,F:100, r:0.02);

p3:ev(F2, c:0.04, cTimes:1, Times:1,F:100, r:0.04);

p4:ev(F2, c:0.04, cTimes:1, Times:1,F:100, r:0.06);

plot2d([rhs(p2),rhs(p3),rhs(p4)], [N,0,10] );

FORMULA 1-C modified duration
Stop the diff evaluation by using "'"

F1C:Dm=-1./PV*'diff(PV,r);

sol:solve([F2,F1C],[Dm,PV]);

duration:ev(rhs(sol[1][1]), c:0.04, cTimes:1, Times:1,F:100),diff;

d1:float(ev(duration, r:0.02, N:5));

d5:float(ev(duration, r:0.04, N:5));

d9:float(ev(duration, r:0.06, N:5));

Legal Notice: The copyright for this application is owned by the authors.
The authors are not responsible for any errors contained within and are not liable
for any damages resulting from the use of this material.
This application is intended for non-commercial, non-profit use only.
Contact the authors for permission if you wish to use this application in for-profit activities.
Contact address: Prof. Yukari Shirota, Faculty of Economics, Gakushuin University, 1-5-1 Mejiro,
Toshima-ku, Tokyo, 171-8588 JAPAN,  yukari.shirota@ipsj.or.jp