def createDateIntervalDictionaries(): """ :return: dict """ date_to_track_from = '2015-12-29' today_date = '2016-01-19' symbol_collection_span_code = 'crash_plus_12_periods_leading_up' days_between_dates = DateDelta.getDaysBetweenDateStrings(date_to_track_from, today_date) interval_count = 12 dateIntervalDictionary = DateIntervalFactory.getDateIntervalDictionary(date_to_track_from, days_between_dates, interval_count, 'days', dictionary_code = 'leading_up_to_crash') since_crash_interval_code = 'since_crash' betweenCrashDatesInterval = DateInterval(date_to_track_from, today_date, since_crash_interval_code) sinceCrashDictionary = DateIntervalDictionary(since_crash_interval_code) sinceCrashDictionary.addDateInterval(betweenCrashDatesInterval) three_month_span_code = 'three_month' threeMonthDateInterval = DateIntervalFactory.getDateIntervals(date_to_track_from, 12, 1, 'weeks').pop() threeMonthDictionary = DateIntervalDictionary(three_month_span_code) threeMonthDictionary.addDateInterval(threeMonthDateInterval) one_year_span_code = 'one_year' oneYearDateInterval = DateIntervalFactory.getDateIntervals(date_to_track_from, 52, 1, 'weeks').pop() oneYearDictionary = DateIntervalDictionary(one_year_span_code) oneYearDictionary.addDateInterval(oneYearDateInterval) dateIntervalDictionaries = {symbol_collection_span_code : dateIntervalDictionary, since_crash_interval_code : sinceCrashDictionary, three_month_span_code : threeMonthDictionary, one_year_span_code : oneYearDictionary} return dateIntervalDictionaries
def __init__(self, start_date, end_date, code = None): self.start_date = start_date self.end_date = end_date self.code = code self.days_in_interval = DateDelta.getDaysBetweenDateStrings(self.start_date, self.end_date)