[SciPy-user] scikits.timeseries

Pierre GM pgmdevlist@gmail....
Wed Dec 10 11:08:34 CST 2008


On Dec 10, 2008, at 9:23 AM, Dave Hirschfeld wrote:

> Pierre GM <pgmdevlist <at> gmail.com> writes:
>> On Nov 27, 2008, at 11:23 AM, Robert Ferrell wrote:
>>> 2. I've noticed that 'business frequency' includes holidays, and  
>>> that
>>> can create holes in what are actually complete data sets.  For
>>> instance, Sep 01, 2008 was a holiday in the US (Labor Day).
>> Yes, the moniker "business days" is a bit decepetive, as it refers
>> only to days that are not Saturday or Sunday. It'd be too tricky for
>> us to implement holidays, as it'd vary from one place to another (no
>> such things as Thanksgiving in Europe, for example...).
> Hi Pierre & Matt,
> I'm finding the timeseries package very useful but I've also run  
> into the same
> holidays issue as Robert. I was wondering if a solution of allowing  
> the user
> to specify the holidays (cf Excel networkdays function) would be  
> feasible?

Yes and no.
No : there's no plan for any user-defined frequency yet, if either.  
The whole machinery is in C, and it would be *very* tricky for us to  
implement such a feature. Besides, this 'OpenBusinessDate' frequency   
is far too local to
be developed on a large scale.
Yes : This said, there should be a way to take holidays into account,  
at a small scale. I'm thinking out loud here:

Say we come with a list of holidays for a given period of time.
We could use that to mask specific dates on a series with Business/ 
WeekDay frequency. That way, conversion and statistics would still  
work seamlessly, we'd just be working with masked data.
However, we'd still have some problems. A basic one would be to find  
the value in the series that falls 3 business days after some date: we  
could start adding 3 to the initial date (in WeekDay frequency), but  
then we would have to check whether there were some missing data  
during these 3 days (a vacation), and adjust the result accordingly.  
Doable, but not straightforward.

> In the following example the user is able to change the function in  
> the
> descriptor which would allow him/her to specify the holidays in their
> particular part of the world. I don't claim that this is the best  
> way to do it,
> but I was wondering if such a scheme could be made to work in the  
> wider context
> of the timeseries package?

We'd be more than happy to incorporate a good subclass of DateArray  
that takes holidays into account, whether through your scheme or the  
one I just suggested, and adresses some of the issues I listed above  
(find the business day that falls 3 days from now). I don't have time  
to do it myself, I don't think Matt has either, so we'll rely on users  
to come up with a solution.

> from scikits.timeseries import Date, DateArray, date_array
> class _isbusinessday(object):
>    def __init__(self, func):
>        assert callable(func)
>        self.func = func
>    def __get__(self, obj, objtype):
>        return self.func(obj)
>    def __set__(self, obj, func):
>        assert callable(func)
>        self.func = func
> #
> class BusinessDateArray(DateArray):
>    isbusinessday = _isbusinessday(lambda x: x.weekday < 5)
>    def __init__(self,*args,**kwargs):
>        super(BusinessDateArray, self).__init__(*args,**kwargs)
> #
> dates = date_array(start_date=Date('D','01-Jan-2008'),length=100)
> dates = BusinessDateArray(dates=dates)
> print dates.isbusinessday
> _______________________________________________
> SciPy-user mailing list
> SciPy-user@scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user

More information about the SciPy-user mailing list