diff --git a/src/tests/test_math.py b/src/tests/test_math.py deleted file mode 100644 index 96197fb..0000000 --- a/src/tests/test_math.py +++ /dev/null @@ -1,9 +0,0 @@ -import pytest -from datetime import datetime -from xirr.math import xirr - - -@pytest.mark.parametrize("valuesPerDateString,expected", [({'2019-12-31': -80005.8, '2020-03-12': 65209.6}, -0.6453638827)]) -def test_xirr(valuesPerDateString, expected): - valuesPerDate = {datetime.fromisoformat(k).date: v for k, v in valuesPerDateString.items()} - assert xirr(valuesPerDate) == expected diff --git a/src/xirr/math.py b/src/xirr/math.py index 58754d6..a190dce 100644 --- a/src/xirr/math.py +++ b/src/xirr/math.py @@ -37,7 +37,7 @@ def xirr(valuesPerDate): >>> xirr(valuesPerDate) -0.6454 ''' - if not valuesPerDate: + if not valuesPerDate or len(valuesPerDate) < 2: return None result = None diff --git a/tests/test_math.py b/tests/test_math.py index c03b71e..9a17155 100644 --- a/tests/test_math.py +++ b/tests/test_math.py @@ -10,6 +10,7 @@ ({'2020-03-12': 65209.6, '2019-12-31': -80005.8}, -0.6454), ({'2019-12-31': -100082.76, '2020-03-05': 82671.24}, -0.6581), ({}, None), + ({'2019-12-31': -100082.76}, None), ({'2019-12-31': -0.00001, '2020-03-05': 0.00001}, 0.0), ({'2019-12-31': -100, '2020-03-05': 100}, 0.0), ({'2019-12-31': -100, '2020-03-05': 1000}, 412461.6383),