python - NameError: name 'addTimeInterval' not defined -


i'm trying run code on hull-white 1 factor model , @ point in time:

today           = datetime.date(2014,10,24)  spot_rate       =   0.02 fardate         = today + addtimeinterval(10.0, 'y') 

i error message:

nameerror                                 traceback (most recent call last) <ipython-input-61-e46904f6da74> in <module>()      59       60 spot_rate       =   0.02 ---> 61 fardate         = today + addtimeinterval(10.0, 'y')      62 year_fraction   = yearfractionfactory.create_istance(day_count_basis.basis_lin_act_365)      63 df              = 1.0 / ((1.0 + spot_rate / 365.0) **(year_fraction(today, fardate) * 365.0))  nameerror: name 'addtimeinterval' not defined 

i dont'know how fix :( answer or hint appreciate. thank all, really..

stef

edit: think found problem. i'm using , modifying code our professor provided (we attended workshop in used code , told use if need it). think imported module called calendar.pyc has kind of functions. of course don't have in python library..thank all! think i'm going create new functions addtimeinterval , yearfraction using module datetime.

remember share full-working example. in code, had @ least import datetime function.

your code tells there nameerror:

nameerror: name 'addtimeinterval' not defined 

the object addtimeinterval seems not function of datetime package unknown.

maybe timedelta looking for:

from datetime import date, timedelta newtime = date(2014,10,24) + timedelta(days=365.25*10) 

however, hard because question not concrete. consider rephrasing question.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -