[Edu-sig] re: financial calculation
Arthur
ajsiegel at optonline.net
Sat Feb 12 22:08:45 CET 2005
>Though maybe my calculations need to be checked, in Python.
which I attempt, as follows:
____________________________________________________________
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)
#price at purchase
ivalue=64.5
#current price
cvalue=81
#let's keep this up for ten years - sure....
print future_value(iday,cday,ivalue,cvalue,10)
_________________________________________________
which returns
4561078546.84
well over $4 bliion
4,561,078,546.84
This is still not seeming intuitively correct. Which might be a problem of my intuition, or my calculation.
Really not sure.
A very serious - (or just serious,compared to my silliness) - quantitative financial analysis tool available to the
Python programmer/student of quantitative finance is the Python bindings to the C++ Quantlib library.
http://www.quantlib.org/
Unfortuantely while it provides automatically generated API documentation, I haven't found anything that could be
called a user manual.
Art
------------------------------------------------------------------------
More information about the Edu-sig
mailing list