Rangekeeper 0.8.25__py3-none-any.whl → 0.8.27__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
rangekeeper/__init__.py CHANGED
@@ -1,10 +1,10 @@
1
1
  from . import api as api
2
+ from . import measure as measure
2
3
  from . import distribution as distribution
3
4
  from . import duration as duration
4
5
  from . import extrapolation as extrapolation
5
6
  from . import flux as flux
6
7
  from . import graph as graph
7
- from . import measure as measure
8
8
  from . import policy as policy
9
9
  from . import projection as projection
10
10
  from . import segmentation as segmentation
rangekeeper/flux.py CHANGED
@@ -1,9 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import datetime
4
- import itertools
5
4
  import json
6
- import locale
7
5
  import os
8
6
  from typing import Dict, Union, Optional, Tuple, List
9
7
 
@@ -324,21 +322,42 @@ class Flow:
324
322
  movements=frame["Discounted Flow"], units=self.units, name=name
325
323
  )
326
324
 
327
- def xirr(self) -> float:
328
- return pyxirr.xirr(
325
+ def xirr(
326
+ self,
327
+ registry: pint.UnitRegistry = None,
328
+ ) -> pint.Quantity:
329
+ """
330
+ Returns the XIRR (Extended Internal Rate of Return) of the Flow's movements.
331
+ Formats the result as a percentage in the specified registry's units.
332
+ """
333
+ # Lazy import to avoid circular dependency
334
+ if registry is None:
335
+ from rangekeeper.measure import Index
336
+
337
+ registry = Index.registry
338
+
339
+ result = pyxirr.xirr(
329
340
  dates=list(self.movements.index.array),
330
341
  amounts=self.movements.to_list(),
331
342
  )
343
+ return result * 100 * registry.percent
332
344
 
333
345
  def xnpv(
334
346
  self,
335
- rate: float,
336
- ) -> float:
337
- return pyxirr.xnpv(
347
+ rate: Union[float, pint.Quantity],
348
+ ) -> pint.Quantity:
349
+ """
350
+ Returns the XNPV (Extended Net Present Value) of the Flow's movements at a specified rate.
351
+ Formats the result as a quantity in the Flow's units.
352
+ """
353
+ if isinstance(rate, pint.Quantity):
354
+ rate = rate.to(rk.measure.Index.registry.dimensionless).magnitude
355
+ result = pyxirr.xnpv(
338
356
  rate=rate,
339
357
  dates=list(self.movements.index.array),
340
358
  amounts=self.movements.to_list(),
341
359
  )
360
+ return result * self.units
342
361
 
343
362
  def diff(
344
363
  self,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Rangekeeper
3
- Version: 0.8.25
3
+ Version: 0.8.27
4
4
  Summary: A Python library assisting financial modelling in real estate asset & development planning, decision-making, cashflow forecasting, and scenario analysis.
5
5
  Author-email: Daniel Fink <danfink@mit.edu>
6
6
  License-Expression: MPL-2.0
@@ -1,9 +1,9 @@
1
- rangekeeper/__init__.py,sha256=3ed6dqjrwb0_Z1le9oItyOFHFrAtP0XJIVhZG07iqZ0,1731
1
+ rangekeeper/__init__.py,sha256=8q0KF90SLgIfptpFGuI66FOCqe3K9UgIzTHFL1pwP4Y,1731
2
2
  rangekeeper/api.py,sha256=3nuG7C2IQjpumcn79MvYDTa7ADWPAos7VfVM-3pL4n4,4798
3
3
  rangekeeper/distribution.py,sha256=2C3jhi1rLJUs0seBztdQb196hNhc00sKJEGMkFiDpYs,8961
4
4
  rangekeeper/duration.py,sha256=9GU6dcZTL_OAOgEHLGkCVxjG16_Po1IMEU29K5g4iRM,20433
5
5
  rangekeeper/extrapolation.py,sha256=Zfsz2KwkImxEMMCNZaF8RpiQxlIgemS1dQkSnjliYU4,2814
6
- rangekeeper/flux.py,sha256=X1m4bkGQqRG5DswYWh46nwcbgIfKqj2sk6xLhaFYzYE,31227
6
+ rangekeeper/flux.py,sha256=25-jSnBrO9QGDXpuNahaVFUiJrHAWaiTda1uplUXFck,32043
7
7
  rangekeeper/format.py,sha256=DOfF4-LCXqWyCtE1OomwE80sJLe6LjL4gqEOAP454LQ,10796
8
8
  rangekeeper/graph.py,sha256=6oWRv-qzGsM5Z19UyJ1v3hwtWaQp_F4qQKxizvkQ_gg,28043
9
9
  rangekeeper/measure.py,sha256=eCdoTAocq1loNZBnOp3nPiPV7yIi0QTwpVHvjba1hkY,4125
@@ -20,7 +20,7 @@ rangekeeper/dynamics/trend.py,sha256=-WqrRvmmTj2mE24Pz-Dl5lXEpLXnDUMngafU__em_ac
20
20
  rangekeeper/dynamics/volatility.py,sha256=MGDLzrI1uP_C6HL-pigJwWikHg1KNbfB_0m0Akh-L2A,5162
21
21
  rangekeeper/formula/__init__.py,sha256=4OXzdJAYDBxQeOMzLR5MZvIjxxIfFOTE9aNu9zFryAE,36
22
22
  rangekeeper/formula/financial.py,sha256=oNFdhygbtdEUFjpxYFuuDnpC_P8nOO538b21FzaMtTU,14045
23
- rangekeeper-0.8.25.dist-info/METADATA,sha256=_bLPq7sZOAVAi0aKKviTEp-lpee04lB30okteq9VsOs,2212
24
- rangekeeper-0.8.25.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
25
- rangekeeper-0.8.25.dist-info/top_level.txt,sha256=7ov6d70lppmzKc088MAmRWnCtCRGA2cd43G28QBSv-c,12
26
- rangekeeper-0.8.25.dist-info/RECORD,,
23
+ rangekeeper-0.8.27.dist-info/METADATA,sha256=2RSAoHJkWMaR5bEw9Y03S_pZHx149hKs6bvcXFkoK8s,2212
24
+ rangekeeper-0.8.27.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
25
+ rangekeeper-0.8.27.dist-info/top_level.txt,sha256=7ov6d70lppmzKc088MAmRWnCtCRGA2cd43G28QBSv-c,12
26
+ rangekeeper-0.8.27.dist-info/RECORD,,