Skip to content

Commit

Permalink
Merge pull request #1 from tarioch/bugfix/minimum_two_entries
Browse files Browse the repository at this point in the history
Fix failure when trying to call xirr with only a single entry
  • Loading branch information
tarioch authored Mar 16, 2020
2 parents 366ad70 + a792498 commit 9cb49a4
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 10 deletions.
9 changes: 0 additions & 9 deletions src/tests/test_math.py

This file was deleted.

2 changes: 1 addition & 1 deletion src/xirr/math.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/test_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 9cb49a4

Please sign in to comment.