# Bond price-yield curve

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

FORMULA 2  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, N:10, c:0.06, cTimes:1, Times:1,F:100);

PVexpr:rhs(p1);

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]), N:10, c:0.06, cTimes:1, Times:1,F:100),diff;

plot2d([PVexpr, duration], [r, 0, 0.4]);

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