From 97731b4c12f337c2463908e522b78522aabfcdce Mon Sep 17 00:00:00 2001 From: Gourav Kumar Date: Sun, 13 Mar 2022 14:28:42 +0530 Subject: [PATCH] Param name and type changes --- tests/test_fincal.py | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/tests/test_fincal.py b/tests/test_fincal.py index 8740b8e..93c1278 100644 --- a/tests/test_fincal.py +++ b/tests/test_fincal.py @@ -200,7 +200,7 @@ class TestFincalBasic: assert time_series.iloc[:3] is not None assert time_series.iloc[5:7] is not None assert isinstance(time_series.iloc[0], tuple) - assert isinstance(time_series.iloc[10:20], list) + assert isinstance(time_series.iloc[10:20], TimeSeries) assert len(time_series.iloc[10:20]) == 10 def test_key_slicing(self): @@ -236,57 +236,65 @@ class TestReturns: def test_returns_calc(self): ts = TimeSeries(self.data, frequency="M") returns = ts.calculate_returns( - "2021-01-01", annual_compounded_returns=False, interval_type="years", interval_value=1 + "2021-01-01", annual_compounded_returns=False, return_period_unit="years", return_period_value=1 ) assert returns[1] == 2.4 returns = ts.calculate_returns( - "2020-04-01", annual_compounded_returns=False, interval_type="months", interval_value=3 + "2020-04-01", annual_compounded_returns=False, return_period_unit="months", return_period_value=3 ) assert round(returns[1], 4) == 0.6 returns = ts.calculate_returns( - "2020-04-01", annual_compounded_returns=True, interval_type="months", interval_value=3 + "2020-04-01", annual_compounded_returns=True, return_period_unit="months", return_period_value=3 ) assert round(returns[1], 4) == 5.5536 returns = ts.calculate_returns( - "2020-04-01", annual_compounded_returns=False, interval_type="days", interval_value=90 + "2020-04-01", annual_compounded_returns=False, return_period_unit="days", return_period_value=90 ) assert round(returns[1], 4) == 0.6 returns = ts.calculate_returns( - "2020-04-01", annual_compounded_returns=True, interval_type="days", interval_value=90 + "2020-04-01", annual_compounded_returns=True, return_period_unit="days", return_period_value=90 ) assert round(returns[1], 4) == 5.727 returns = ts.calculate_returns( - "2020-04-10", annual_compounded_returns=True, interval_type="days", interval_value=90 + "2020-04-10", annual_compounded_returns=True, return_period_unit="days", return_period_value=90 ) assert round(returns[1], 4) == 5.727 with pytest.raises(DateNotFoundError): - ts.calculate_returns("2020-04-10", interval_type="days", interval_value=90, as_on_match="exact") + ts.calculate_returns("2020-04-10", return_period_unit="days", return_period_value=90, as_on_match="exact") with pytest.raises(DateNotFoundError): - ts.calculate_returns("2020-04-10", interval_type="days", interval_value=90, prior_match="exact") + ts.calculate_returns("2020-04-10", return_period_unit="days", return_period_value=90, prior_match="exact") def test_date_formats(self): ts = TimeSeries(self.data, frequency="M") FincalOptions.date_format = "%d-%m-%Y" with pytest.raises(ValueError): - ts.calculate_returns("2020-04-10", annual_compounded_returns=True, interval_type="days", interval_value=90) + ts.calculate_returns( + "2020-04-10", annual_compounded_returns=True, return_period_unit="days", return_period_value=90 + ) - returns1 = ts.calculate_returns("2020-04-10", interval_type="days", interval_value=90, date_format="%Y-%m-%d") - returns2 = ts.calculate_returns("10-04-2020", interval_type="days", interval_value=90) + returns1 = ts.calculate_returns( + "2020-04-10", return_period_unit="days", return_period_value=90, date_format="%Y-%m-%d" + ) + returns2 = ts.calculate_returns("10-04-2020", return_period_unit="days", return_period_value=90) assert round(returns1[1], 4) == round(returns2[1], 4) == 5.727 FincalOptions.date_format = "%m-%d-%Y" with pytest.raises(ValueError): - ts.calculate_returns("2020-04-10", annual_compounded_returns=True, interval_type="days", interval_value=90) + ts.calculate_returns( + "2020-04-10", annual_compounded_returns=True, return_period_unit="days", return_period_value=90 + ) - returns1 = ts.calculate_returns("2020-04-10", interval_type="days", interval_value=90, date_format="%Y-%m-%d") - returns2 = ts.calculate_returns("04-10-2020", interval_type="days", interval_value=90) + returns1 = ts.calculate_returns( + "2020-04-10", return_period_unit="days", return_period_value=90, date_format="%Y-%m-%d" + ) + returns2 = ts.calculate_returns("04-10-2020", return_period_unit="days", return_period_value=90) assert round(returns1[1], 4) == round(returns2[1], 4) == 5.727 def test_limits(self): ts = TimeSeries(self.data, frequency="M") FincalOptions.date_format = "%Y-%m-%d" with pytest.raises(DateNotFoundError): - ts.calculate_returns("2020-04-25", interval_type="days", interval_value=90, closest_max_days=10) + ts.calculate_returns("2020-04-25", return_period_unit="days", return_period_value=90, closest_max_days=10) class TestVolatility: