I am going through QSTK and in tutorials they use datetime.timedelta
I am curios what is the purpose of such command in stock related environment. I found some articles on what timedelta
is but clearly I am not grasping it since I am clueless what this means:
timeofday= datetime.timedelta(hours=16)
timestamps = du.getNYSEdays(startday,endday,timeofday)
What is a purpose of timedelta as an argument for QSTK or in general.
A timedelta is just an amount of time. In this case, "16 hours".
They're useful because they can be used to manipulate dates and times. Say you've got a datetime object that represents "May 21, 2002 at 6am". If you add your timedelta to that datetime, you'll get "May 21, 2002 at 10pm".
You can also use them to compare datetime objects. If
todays_lunch
is defined as "11/26/2012 at 12pm" andtoday's dinner
is "11/26/2012 at 6pm", then you can do:Without more of the code (or maybe just a better understanding of the NYSE than I have), it's hard to tell what this particular case is doing. But it's something to do with manipulating datetime objects in 16-hour intervals.