Skip to content

Commit

Permalink
Allow filtering by user defined holidays
Browse files Browse the repository at this point in the history
  • Loading branch information
saeedamen committed May 11, 2018
1 parent d925fa6 commit 74b07b0
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions findatapy/timeseries/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def create_calendar_bus_days(self, start_date, end_date, cal = 'FX'):

return [x for x in index if x not in hols]

def get_holidays(self, start_date, end_date, cal = 'FX'):
def get_holidays(self, start_date, end_date, cal = 'FX', holidays_list = []):
"""Gets the holidays for a given calendar
Parameters
Expand All @@ -104,7 +104,6 @@ def get_holidays(self, start_date, end_date, cal = 'FX'):
"""

# TODO use Pandas CustomBusinessDays to get more calendars
holidays_list = []

if cal == 'FX':
# filter for Christmas & New Year's Day
Expand All @@ -130,7 +129,7 @@ def get_holidays(self, start_date, end_date, cal = 'FX'):

return pandas.to_datetime(holidays_list)

def filter_time_series_by_holidays(self, data_frame, cal = 'FX'):
def filter_time_series_by_holidays(self, data_frame, cal = 'FX', holidays_list = []):
"""Removes holidays from a given time series
Parameters
Expand All @@ -150,7 +149,7 @@ def filter_time_series_by_holidays(self, data_frame, cal = 'FX'):
return data_frame.ix[data_frame.index.dayofweek <= 4]

# select only those holidays in the sample
holidays_start = self.get_holidays(data_frame.index[0], data_frame.index[-1], cal)
holidays_start = self.get_holidays(data_frame.index[0], data_frame.index[-1], cal, holidays_list = holidays_list)

if(holidays_start.size == 0):
return data_frame
Expand Down

0 comments on commit 74b07b0

Please sign in to comment.