I'm using weekdays as a proxy for days when the US stock market is open.
(I'll miss holidays.) The application is pricing CALL and PUT
options. Speed is not a problem. The number of days will typically be
between 1 and 254.
--
http://mail.python.org/mailman/listinfo/python-list
(Sorry if this shows up twice.)
Can someone think of an easy way to calculate the number of weekdays
between two calendar dates (in Python)?
Thankee.
--
http://mail.python.org/mailman/listinfo/python-list
Jive Dadson wrote:
Wow.
It's a danged tutorial. Thanks again. Take a break.
Ben Finney's method is a very good approach, and an experienced Python
programmer would consider it straightforward.
But I have to ask whether the range of dates you might be considering
could be large. For ex
Wow. It's a danged tutorial. Thanks again. Take a break.
--
http://mail.python.org/mailman/listinfo/python-list
Jive Dadson writes:
> Ben Finney wrote:
> > >>> friday_weekday = 4
> > >>> len([
> > ... date for date in (
> > ... begin_date + datetime.timedelta(days)
> > ... for days in range((end_date - begin_date).days))
> > ... if calendar.weekday(date.year,
Ben Finney wrote:
Jive Dadson writes:
Can someone think of an easy way to calculate the number of weekdays
between two calendar dates (in Python)?
That depends on what you mean by “weekdays”.
>>> import datetime
>>> begin_date = datetime.date(2009, 10, 9)
>>> end_date = datetime
Jive Dadson writes:
> Can someone think of an easy way to calculate the number of weekdays
> between two calendar dates (in Python)?
That depends on what you mean by “weekdays”.
>>> import datetime
>>> begin_date = datetime.date(2009, 10, 9)
>>> end_date = datetime.date(2009, 10, 22