def test_heisei_emperor_abdication_holiday(self): for calendar in [jpd.TSEHolidayCalendar(), jpd.JapaneseHolidayCalendar()]: holidays = calendar.holidays() self.assertTrue(datetime.datetime(2018, 12, 23) in holidays) self.assertFalse(datetime.datetime(2019, 12, 23) in holidays) self.assertFalse(datetime.datetime(2019, 2, 23) in holidays) self.assertTrue(datetime.datetime(2020, 2, 23) in holidays)
def test_holiday_bug(self): # GH 42 for calendar in [jpd.TSEHolidayCalendar(), jpd.JapaneseHolidayCalendar()]: holidays = calendar.holidays() self.assertFalse(datetime.datetime(1993, 9, 5) in holidays) self.assertTrue(datetime.datetime(1993, 9, 15) in holidays) self.assertFalse(datetime.datetime(2020, 8, 12) in holidays) self.assertTrue(datetime.datetime(2020, 8, 11) in holidays)
def test_tseholiday_holidays(self): calendar = jpd.TSEHolidayCalendar() holidays = calendar.holidays() for y in range(1970, 2031): for m, d in [(1, 1), (1, 2), (1, 3), (12, 31)]: dt = datetime.date(y, m, d) self.assertTrue(dt in holidays) # test initial / final date explicitly self.assertTrue(datetime.date(1970, 1, 1) in holidays) self.assertTrue(datetime.date(2030, 12, 31) in holidays) for e in self.expected: self.assertTrue(dt in holidays)
def test_holiday_bug(self): # GH 42 for calendar in [jpd.TSEHolidayCalendar(), jpd.JapaneseHolidayCalendar()]: holidays = calendar.holidays() self.assertFalse(datetime.datetime(1993, 9, 5) in holidays) self.assertTrue(datetime.datetime(1993, 9, 15) in holidays) self.assertFalse(datetime.datetime(2020, 8, 12) in holidays) # http://www8.cao.go.jp/chosei/shukujitsu/gaiyou.html#tokurei self.assertFalse(datetime.datetime(2020, 8, 11) in holidays)
def test_tokurei(self): # http://www8.cao.go.jp/chosei/shukujitsu/gaiyou.html#tokurei for calendar in [jpd.TSEHolidayCalendar(), jpd.JapaneseHolidayCalendar()]: holidays = calendar.holidays() # 海の日 self.assertTrue(datetime.datetime(2020, 7, 23) in holidays) self.assertFalse(datetime.datetime(2020, 7, 20) in holidays) self.assertTrue(datetime.datetime(2021, 7, 19) in holidays) # 山の日 self.assertTrue(datetime.datetime(2020, 8, 10) in holidays) self.assertFalse(datetime.datetime(2020, 8, 11) in holidays) self.assertTrue(datetime.datetime(2021, 8, 11) in holidays) # スポーツの日 self.assertTrue(datetime.datetime(2020, 7, 24) in holidays) self.assertFalse(datetime.datetime(2020, 10, 12) in holidays) self.assertTrue(datetime.datetime(2021, 10, 11) in holidays)
def test_new_era(self): for calendar in [ jpd.TSEHolidayCalendar(), jpd.JapaneseHolidayCalendar() ]: holidays = calendar.holidays() self.assertFalse(datetime.datetime(2019, 4, 26) in holidays) self.assertFalse(datetime.datetime(2019, 4, 27) in holidays) self.assertFalse(datetime.datetime(2019, 4, 28) in holidays) self.assertTrue(datetime.datetime(2019, 4, 29) in holidays) self.assertTrue(datetime.datetime(2019, 4, 30) in holidays) self.assertTrue(datetime.datetime(2019, 5, 1) in holidays) self.assertTrue(datetime.datetime(2019, 5, 2) in holidays) self.assertTrue(datetime.datetime(2019, 5, 3) in holidays) self.assertTrue(datetime.datetime(2019, 5, 4) in holidays) self.assertTrue(datetime.datetime(2019, 5, 5) in holidays) self.assertTrue(datetime.datetime(2019, 5, 6) in holidays) self.assertFalse(datetime.datetime(2019, 5, 7) in holidays) self.assertFalse(datetime.datetime(2019, 12, 23) in holidays)
def tse_date_range(start_date, end_date): """japandasライブラリを使って、東証(TSE)の営業日情報を取得 """ tse_business_day = pd.offsets.CustomBusinessDay( calendar=japandas.TSEHolidayCalendar()) return pd.date_range(start_date, end_date, freq=tse_business_day)
def tse_date_range(start_date, end_date): tse_business_day = pd.offsets.CustomBusinessDay( calendar=japandas.TSEHolidayCalendar()) return pd.date_range(start_date, end_date, freq=tse_business_day)