[Edu-sig] re: financial calculation
Arthur
ajsiegel at optonline.net
Sun Feb 13 18:50:06 CET 2005
For anybody who might join me in my crass interest in $4.5 billion.
In the form below - i.e. just adding some sanity checking - I seem to be
able to conclude my code is sane (by some loose definition of sanity).
Sample output:
value at 2004-12-27: 64.50
assumed value at 2005-02-11: 65.50
projected future value at 2014-12-15: 218.64
value at 2004-12-27: 64.50
assumed value at 2005-02-11: 71.00
projected future value at 2014-12-15: 131297.27
value at 2004-12-27: 64.50
actual at 2005-02-11: 81.00
projected future value at 2014-12-15: 4561078546.84
------------------------------------------------------------------
from __future__ import division
import datetime
import math
def future_value(iday,cday,ivalue,cvalue,years):
days_invested=(cday-iday).days
year_periods=365/days_invested
annualized_rate = math.log(cvalue/ivalue)*year_periods
#future_value at the end of given years
return ivalue*math.pow(math.e,annualized_rate*years)
#date we purchased stock
iday=datetime.date(2004,12,27)
#date of valuation
cday=datetime.date(2005,2,11)
#10 years from date we purchased stock
fdate = iday+datetime.timedelta(weeks=10*52)
#price at purchase
ivalue=64.5
for i in range(0,34):
cvalue = ivalue + i/2
fvalue = round(future_value(iday,cday,ivalue,cvalue,10),2)
print "value at %s: %.2f" %(iday,ivalue)
if not i == 33:
print "assumed value at %s: %.2f" %(cday,cvalue)
else:
print "actual value at %s: %.2f" %(cday,cvalue)
print "projected future value at %s: %.2f" %(fdate,fvalue)
print "+-------------------------------+"
print "\n"
More information about the Edu-sig
mailing list