示例#1
0
    def testNullCalendar(self):
        cal = Calendar("Null")

        testDate = Date(2015, 1, 1)
        self.assertTrue(cal.isBizDay(testDate))
        self.assertTrue(not cal.isHoliday(testDate))
        self.assertTrue(cal.isWeekEnd(Weekdays.Saturday))
        self.assertTrue(cal.isWeekEnd(Weekdays.Sunday))
        self.assertTrue(not cal.isWeekEnd(Weekdays.Friday))
示例#2
0
    def testChinaIB(self):

        # China Inter Bank working weekend list in the year 2014
        expected_working_week_end = [
            Date(2014, 1, 26),
            Date(2014, 2, 8),
            Date(2014, 5, 4),
            Date(2014, 9, 28),
            Date(2014, 10, 11),
            # China Inter Bank working weekend list in the year 2015
            Date(2015, 1, 4),
            Date(2015, 2, 15),
            Date(2015, 2, 28),
            Date(2015, 9, 6),
            Date(2015, 10, 10),
            # China Inter Bank working weekend list in the year 2016
            Date(2016, 2, 6),
            Date(2016, 2, 14),
            Date(2016, 6, 12),
            Date(2016, 9, 18),
            Date(2016, 10, 8),
            Date(2016, 10, 9),
            # China Inter Bank working weekend list in the year 2017
            Date(2017, 1, 22),
            Date(2017, 2, 4),
            Date(2017, 4, 1),
            Date(2017, 5, 27),
            Date(2017, 9, 30),
            # China Inter Bank working weekend list in the year 2018
            Date(2018, 2, 11),
            Date(2018, 2, 24),
            Date(2018, 4, 8),
            Date(2018, 4, 28),
            Date(2018, 9, 29),
            Date(2018, 9, 30)
        ]

        cal = Calendar('China.IB')

        for day in expected_working_week_end:
            self.assertEqual(
                cal.isHoliday(day), False,
                "{0} is not expected to be a holiday in {1}".format(day, cal))
            self.assertEqual(
                cal.isBizDay(day), True,
                "{0} is expected to be a working day in {1} ".format(day, cal))
示例#3
0
    def testChinaSSE(self):
        # China Shanghai Securities Exchange holiday list in the year 2014
        expectedHol = [
            Date(2014, 1, 1),
            Date(2014, 1, 31),
            Date(2014, 2, 3),
            Date(2014, 2, 4),
            Date(2014, 2, 5),
            Date(2014, 2, 6),
            Date(2014, 4, 7),
            Date(2014, 5, 1),
            Date(2014, 5, 2),
            Date(2014, 6, 2),
            Date(2014, 9, 8),
            Date(2014, 10, 1),
            Date(2014, 10, 2),
            Date(2014, 10, 3),
            Date(2014, 10, 6),
            Date(2014, 10, 7),
            # China Shanghai Securities Exchange holiday list in the year 2015
            Date(2015, 1, 1),
            Date(2015, 1, 2),
            Date(2015, 2, 18),
            Date(2015, 2, 19),
            Date(2015, 2, 20),
            Date(2015, 2, 23),
            Date(2015, 2, 24),
            Date(2015, 4, 6),
            Date(2015, 5, 1),
            Date(2015, 6, 22),
            Date(2015, 9, 3),
            Date(2015, 9, 4),
            Date(2015, 10, 1),
            Date(2015, 10, 2),
            Date(2015, 10, 5),
            Date(2015, 10, 6),
            Date(2015, 10, 7),
            # China Shanghai Securities Exchange holiday list in the year 2016
            Date(2016, 1, 1),
            Date(2016, 2, 8),
            Date(2016, 2, 9),
            Date(2016, 2, 10),
            Date(2016, 2, 11),
            Date(2016, 2, 12),
            Date(2016, 4, 4),
            Date(2016, 5, 2),
            Date(2016, 6, 9),
            Date(2016, 6, 10),
            Date(2016, 9, 15),
            Date(2016, 9, 16),
            Date(2016, 10, 3),
            Date(2016, 10, 4),
            Date(2016, 10, 5),
            Date(2016, 10, 6),
            Date(2016, 10, 7),
            # China Shanghai Securities Exchange holiday list in the year 2017
            Date(2017, 1, 1),
            Date(2017, 1, 2),
            Date(2017, 1, 27),
            Date(2017, 1, 28),
            Date(2017, 1, 29),
            Date(2017, 1, 30),
            Date(2017, 1, 31),
            Date(2017, 2, 1),
            Date(2017, 2, 2),
            Date(2017, 4, 2),
            Date(2017, 4, 3),
            Date(2017, 4, 4),
            Date(2017, 5, 1),
            Date(2017, 5, 28),
            Date(2017, 5, 29),
            Date(2017, 5, 30),
            Date(2017, 10, 1),
            Date(2017, 10, 2),
            Date(2017, 10, 3),
            Date(2017, 10, 4),
            Date(2017, 10, 5),
            Date(2017, 10, 6),
            Date(2017, 10, 7),
            Date(2017, 10, 8)
        ]

        cal = Calendar('China.SSE')

        for day in expectedHol:
            self.assertEqual(
                cal.isHoliday(day), True,
                "{0} is expected to be a holiday in {1}".format(day, cal))
            self.assertEqual(
                cal.isBizDay(day), False,
                "{0} is expected not to be a working day in {1} ".format(
                    day, cal))