Exemplo n.º 1
0
    def test(self):

        expected = util.matrix_to_dataframe(
            [['2019-11-27', 13.88, 0.0005159071471232402],
             ['2019-11-28', 13.63, 0.000507181628455422]])

        input_example = util.matrix_to_dataframe([['2019-11-27', 13.88],
                                                  ['2019-11-28', 13.63]])
        result = logic.calculate_cdi_rate_for_time_series(input_example)

        pd.testing.assert_frame_equal(expected, result)
Exemplo n.º 2
0
    def setUp(self):
        if os.path.exists(processed_cdi_prices):
            os.remove(processed_cdi_prices)

        expected = [
            ['2019-11-27', 5, 0.0001936305065440],
            ['2019-11-28', 4, 0.0001556498627913],
            ['2019-11-29', 3, 0.0001173037138344],
            ['2019-12-02', 2, 0.0000785849419846],
            ['2019-12-03', 1, 0.0000394862194537]
        ]

        self.expected = util.matrix_to_dataframe(expected)
Exemplo n.º 3
0
    def test_for_valid_file(self):

        expected = util.matrix_to_dataframe([
            ['2019-11-27', 5],
            ['2019-11-28', 4],
            ['2019-11-29', 3],
            ['2019-12-02', 2],
            ['2019-12-03', 1]
        ])

        result = data.load_raw_cdi_prices(raw_cdi_prices)

        pd.testing.assert_frame_equal(expected, result)
Exemplo n.º 4
0
    def test_for_last_days(self):

        expected = util.matrix_to_dataframe([
            ['2020-12-09', 9, 90],
        ])

        start = util.str_to_datetime('2020-12-09')
        end = util.str_to_datetime('2020-12-10')

        result = logic.filter_by_date_interval(self.input_example, start, end)
        result = result.reset_index(drop=True)

        pd.testing.assert_frame_equal(expected, result)
Exemplo n.º 5
0
 def setUp(self):
     input_example = [
         ['2020-12-01', 13.88, 0.00051591],
         ['2020-12-02', 13.88, 0.00051591],
         ['2020-12-03', 13.88, 0.00051591],
         ['2020-12-04', 13.88, 0.00051591],
         ['2020-12-05', 13.88, 0.00051591],
         ['2020-12-06', 13.88, 0.00051591],
         ['2020-12-07', 13.88, 0.00051591],
         ['2020-12-08', 13.88, 0.00051591],
         ['2020-12-09', 13.88, 0.00051591],
     ]
     self.input_example = util.matrix_to_dataframe(input_example)
Exemplo n.º 6
0
    def setUp(self):
        input_example = [
            ['2020-12-01', 1, 10],
            ['2020-12-02', 2, 20],
            ['2020-12-03', 3, 30],
            ['2020-12-04', 4, 40],
            ['2020-12-05', 5, 50],
            ['2020-12-06', 6, 60],
            ['2020-12-07', 7, 70],
            ['2020-12-08', 8, 80],
            ['2020-12-09', 9, 90],
        ]

        self.input_example = util.matrix_to_dataframe(input_example)
Exemplo n.º 7
0
    def test_save_and_load_file(self):

        expected = util.matrix_to_dataframe([
            ['2019-11-27', 5, 0.0001936305065440],
            ['2019-11-28', 4, 0.0001556498627913],
            ['2019-11-29', 3, 0.0001173037138344],
            ['2019-12-02', 2, 0.0000785849419846],
            ['2019-12-03', 1, 0.0000394862194537]
        ])

        data.save_processed_cdi_prices_file(expected, processed_cdi_prices)

        result = data.load_processed_cdi_prices_file(processed_cdi_prices)

        pd.testing.assert_frame_equal(expected, result)
Exemplo n.º 8
0
    def test_for_valid_interval(self):

        expected = util.matrix_to_dataframe([
            ['2020-12-04', 4, 40],
            ['2020-12-05', 5, 50],
            ['2020-12-06', 6, 60],
        ])

        start = util.str_to_datetime('2020-12-04')
        end = util.str_to_datetime('2020-12-07')

        result = logic.filter_by_date_interval(self.input_example, start, end)
        result = result.reset_index(drop=True)

        pd.testing.assert_frame_equal(expected, result)
Exemplo n.º 9
0
    def test_if_accumulated_values_are_correct(self):

        expected = util.matrix_to_dataframe([
            ['2020-12-01', 1.0005339668500000],
            ['2020-12-02', 1.0010682188206000],
            ['2020-12-03', 1.0016027560640400],
            ['2020-12-04', 1.0021375787326500],
            ['2020-12-05', 1.0026726869788300],
            ['2020-12-06', 1.0032080809550800],
            ['2020-12-07', 1.0037437608139600],
            ['2020-12-08', 1.0042797267081300],
            ['2020-12-09', 1.0048159787903200],
        ], ['date', 'accumulated'])

        cdb = 103.5

        result = logic.calculate_accumulated_cdi_rate(self.input_example, cdb)

        pd.testing.assert_frame_equal(expected, result)