1000 rem aaii program no. 9 -- cd put 1010 rem by robert osterlund of aaii. (c) copyright 1986 by 1020 rem the american association of individual investors, 1030 rem 612 n. michigan ave., chicago, il 60611, (312)280-0170. 1040 rem from the may 1986 issue of computerized investing. 1100 rem enter rates as percents, for example, 7.5% enter as: 7.5 1110 rem enter dates as follows: month (comma) year 1120 rem for example, june 1986 is entered as: 6,1986 1130 rem for continuous compounding, enter >365 periods per year 2000 rem initialization routine 2010 def fn fr(x) = x - int(x) 2020 def fn f(x) = (1+x/cp)^int(cp*t2) * (1+(x/cp)*fn fr(cp*t2)) - tv/rv 2030 def fn rn(x) = int(x*100+.5)/100 3000 rem data input routine 3010 print chr$(26): rem clear the screen 3020 print "cd principal value ($)";: input pv 3030 print "original cd interest rate (%)";: input r1 3040 print "no. compounding periods per year";: input cp 3050 print "cd term (years, months)";: input yt%,mt% 3060 print 3070 print "early withdrawal penalty (months)";: input wp 3080 print "does the cd rate revert to the passbook" 3090 print "savings rate upon early withdrawal";: input a$ 3100 a$ = left$(a$,1): if a$ <> "y" and a$ <> "n" then 3080 3110 if a$ = "n" then rp = r1: goto 3130 3120 print "what is the passbook rate (%)";: input rp 3130 print 3140 print "month & year of cd purchase";: input mm%(1), yy%(1) 3150 print "current month & year";: input mm%(2),yy%(2) 3160 t1 = yy%(2) - yy%(1) + (mm%(2)-mm%(1))/12 3170 t2 = mt%/12 + yt% - t1 3180 print 3190 print "for a cd with"; int(t2); "years,"; fn rn(12*fn fr(t2)); "months" 3200 print "remaining to maturity, compounding"; cp 3210 print "times annually, what is the" 3220 print "current interest rate";: input rc 4000 rem computation routine 4010 r1 = r1/100: rp = rp/100: rc = rc/100 4020 tv = pv * (1+r1/cp)^int(cp*(t1+t2)) * (1+(r1/cp)*fn fr(cp*(t1+t2))) 4030 rv = pv * (1+rp/cp)^int(cp*t1) * (1+(rp/cp)*fn fr(cp*t1)) - pv*rp*wp/12 4040 r2 = r1: k = 0 4050 f = fn f(r2) 4060 fd = ((1+(r2/cp)*fn fr(cp*t2)) * int(cp*t2) * (1+r2/cp)^(int(cp*t2)-1))/cp 4070 fd = fd + ((1+r2/cp)^int(cp*t2) * fn fr(cp*t2))/cp 4080 if abs(fd) < .1 then rd = .001 * sgn(f) * sgn(fd): goto 4100 4090 rd = f/fd 4100 r2 = r2 - rd 4110 if abs(rd) < .00005 then if fd <> 0 then 5000 4120 k = k+1 4130 if k >= 500 then print "nonconvergence": stop 4140 goto 4050 5000 rem output routine 5010 print 5020 print "terminal value of holding ($):"; fn rn(tv) 5030 print "terminal value of putting ($):"; fn rn(fn f(rc)*rv+tv) 5040 print "tv(putting) - tv(holding) ($):"; fn rn(fn f(rc)*rv) 5050 print "breakeven rate (%):"; fn rn(r2*100) 5060 end