Rangekeeper 0.8.24__tar.gz → 0.8.26__tar.gz

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.
Files changed (39) hide show
  1. {rangekeeper-0.8.24 → rangekeeper-0.8.26}/PKG-INFO +1 -1
  2. {rangekeeper-0.8.24 → rangekeeper-0.8.26}/Rangekeeper.egg-info/PKG-INFO +1 -1
  3. {rangekeeper-0.8.24 → rangekeeper-0.8.26}/pyproject.toml +1 -1
  4. {rangekeeper-0.8.24 → rangekeeper-0.8.26}/rangekeeper/extrapolation.py +13 -25
  5. {rangekeeper-0.8.24 → rangekeeper-0.8.26}/rangekeeper/flux.py +19 -5
  6. {rangekeeper-0.8.24 → rangekeeper-0.8.26}/rangekeeper/measure.py +1 -1
  7. {rangekeeper-0.8.24 → rangekeeper-0.8.26}/README.md +0 -0
  8. {rangekeeper-0.8.24 → rangekeeper-0.8.26}/Rangekeeper.egg-info/SOURCES.txt +0 -0
  9. {rangekeeper-0.8.24 → rangekeeper-0.8.26}/Rangekeeper.egg-info/dependency_links.txt +0 -0
  10. {rangekeeper-0.8.24 → rangekeeper-0.8.26}/Rangekeeper.egg-info/requires.txt +0 -0
  11. {rangekeeper-0.8.24 → rangekeeper-0.8.26}/Rangekeeper.egg-info/top_level.txt +0 -0
  12. {rangekeeper-0.8.24 → rangekeeper-0.8.26}/rangekeeper/__init__.py +0 -0
  13. {rangekeeper-0.8.24 → rangekeeper-0.8.26}/rangekeeper/api.py +0 -0
  14. {rangekeeper-0.8.24 → rangekeeper-0.8.26}/rangekeeper/distribution.py +0 -0
  15. {rangekeeper-0.8.24 → rangekeeper-0.8.26}/rangekeeper/duration.py +0 -0
  16. {rangekeeper-0.8.24 → rangekeeper-0.8.26}/rangekeeper/dynamics/__init__.py +0 -0
  17. {rangekeeper-0.8.24 → rangekeeper-0.8.26}/rangekeeper/dynamics/black_swan.py +0 -0
  18. {rangekeeper-0.8.24 → rangekeeper-0.8.26}/rangekeeper/dynamics/cyclicality.py +0 -0
  19. {rangekeeper-0.8.24 → rangekeeper-0.8.26}/rangekeeper/dynamics/market.py +0 -0
  20. {rangekeeper-0.8.24 → rangekeeper-0.8.26}/rangekeeper/dynamics/noise.py +0 -0
  21. {rangekeeper-0.8.24 → rangekeeper-0.8.26}/rangekeeper/dynamics/trend.py +0 -0
  22. {rangekeeper-0.8.24 → rangekeeper-0.8.26}/rangekeeper/dynamics/volatility.py +0 -0
  23. {rangekeeper-0.8.24 → rangekeeper-0.8.26}/rangekeeper/format.py +0 -0
  24. {rangekeeper-0.8.24 → rangekeeper-0.8.26}/rangekeeper/formula/__init__.py +0 -0
  25. {rangekeeper-0.8.24 → rangekeeper-0.8.26}/rangekeeper/formula/financial.py +0 -0
  26. {rangekeeper-0.8.24 → rangekeeper-0.8.26}/rangekeeper/graph.py +0 -0
  27. {rangekeeper-0.8.24 → rangekeeper-0.8.26}/rangekeeper/policy.py +0 -0
  28. {rangekeeper-0.8.24 → rangekeeper-0.8.26}/rangekeeper/projection.py +0 -0
  29. {rangekeeper-0.8.24 → rangekeeper-0.8.26}/rangekeeper/segmentation.py +0 -0
  30. {rangekeeper-0.8.24 → rangekeeper-0.8.26}/rangekeeper/space.py +0 -0
  31. {rangekeeper-0.8.24 → rangekeeper-0.8.26}/setup.cfg +0 -0
  32. {rangekeeper-0.8.24 → rangekeeper-0.8.26}/tests/test_api.py +0 -0
  33. {rangekeeper-0.8.24 → rangekeeper-0.8.26}/tests/test_dynamics.py +0 -0
  34. {rangekeeper-0.8.24 → rangekeeper-0.8.26}/tests/test_formulas.py +0 -0
  35. {rangekeeper-0.8.24 → rangekeeper-0.8.26}/tests/test_graph.py +0 -0
  36. {rangekeeper-0.8.24 → rangekeeper-0.8.26}/tests/test_measures.py +0 -0
  37. {rangekeeper-0.8.24 → rangekeeper-0.8.26}/tests/test_models.py +0 -0
  38. {rangekeeper-0.8.24 → rangekeeper-0.8.26}/tests/test_modules.py +0 -0
  39. {rangekeeper-0.8.24 → rangekeeper-0.8.26}/tests/test_projections.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Rangekeeper
3
- Version: 0.8.24
3
+ Version: 0.8.26
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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Rangekeeper
3
- Version: 0.8.24
3
+ Version: 0.8.26
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,6 +1,6 @@
1
1
  [project]
2
2
  name = "Rangekeeper"
3
- version = "0.8.24"
3
+ version = "0.8.26"
4
4
  description = "A Python library assisting financial modelling in real estate asset & development planning, decision-making, cashflow forecasting, and scenario analysis."
5
5
  authors = [
6
6
  { name = "Daniel Fink", email = "danfink@mit.edu" }
@@ -8,10 +8,12 @@ from abc import abstractmethod
8
8
 
9
9
 
10
10
  class Type(enum.Enum):
11
- STRAIGHT_LINE = 'StraightLine' # A constant-change (linearly growing (or decaying)) projection form, originating from an initial value.
12
- COMPOUNDING = 'Compounding' # An exponentially growing (compounding) or decaying projection at a specified rate per period.
13
- RECURRING = 'Recurring' # A projection form that repeats a specified sequence of values.
14
- DYNAMIC = 'Dynamic' # A projection form generated by a stochastic process.
11
+ STRAIGHT_LINE = "StraightLine" # A constant-change (linearly growing (or decaying)) projection form, originating from an initial value.
12
+ COMPOUNDING = "Compounding" # An exponentially growing (compounding) or decaying projection at a specified rate per period.
13
+ RECURRING = (
14
+ "Recurring" # A projection form that repeats a specified sequence of values.
15
+ )
16
+ DYNAMIC = "Dynamic" # A projection form generated by a stochastic process.
15
17
 
16
18
 
17
19
  class Form:
@@ -21,9 +23,7 @@ class Form:
21
23
  """
22
24
 
23
25
  @abstractmethod
24
- def terms(
25
- self,
26
- sequence: pd.RangeIndex) -> [float]:
26
+ def terms(self, sequence: pd.RangeIndex) -> [float]:
27
27
  """
28
28
  Returns the set of terms that define the projection's form at each value in the sequence.
29
29
  """
@@ -37,15 +37,11 @@ class StraightLine(Form):
37
37
  To calculate the factor, the projection is modelled as a linear function of (slope * period) + 1
38
38
  """
39
39
 
40
- def __init__(
41
- self,
42
- slope: float):
40
+ def __init__(self, slope: float):
43
41
  self.type = Type.STRAIGHT_LINE
44
42
  self.slope = slope
45
43
 
46
- def terms(
47
- self,
48
- sequence: pd.RangeIndex) -> [float]:
44
+ def terms(self, sequence: pd.RangeIndex) -> [float]:
49
45
  """
50
46
  Returns the additive terms to the projection at each value in the sequence.
51
47
  """
@@ -65,15 +61,11 @@ class Compounding(Form):
65
61
  To calculate the factor, the projection is modelled as an exponential function of (1 + rate) ** period
66
62
  """
67
63
 
68
- def __init__(
69
- self,
70
- rate: float):
64
+ def __init__(self, rate: float):
71
65
  self.type = Type.COMPOUNDING
72
66
  self.rate = rate
73
67
 
74
- def terms(
75
- self,
76
- sequence: pd.RangeIndex) -> [float]:
68
+ def terms(self, sequence: pd.RangeIndex) -> [float]:
77
69
  """
78
70
  Returns the multiplicative factors of the projection's form at each value in the sequence.
79
71
  """
@@ -83,15 +75,11 @@ class Compounding(Form):
83
75
  class Dynamic(Form):
84
76
  series: pd.Series
85
77
 
86
- def __init__(
87
- self,
88
- series: pd.Series):
78
+ def __init__(self, series: pd.Series):
89
79
  self.type = Type.DYNAMIC
90
80
  self.series = series
91
81
 
92
- def terms(
93
- self,
94
- sequence: pd.RangeIndex) -> [float]:
82
+ def terms(self, sequence: pd.RangeIndex) -> [float]:
95
83
  """
96
84
  Returns the multiplicative factors of the projection's form at each value in the sequence.
97
85
  """
@@ -324,21 +324,35 @@ class Flow:
324
324
  movements=frame["Discounted Flow"], units=self.units, name=name
325
325
  )
326
326
 
327
- def xirr(self) -> float:
328
- return pyxirr.xirr(
327
+ def xirr(
328
+ self, registry: pint.UnitRegistry = rk.measure.Index.registry
329
+ ) -> pint.Quantity:
330
+ """
331
+ Returns the XIRR (Extended Internal Rate of Return) of the Flow's movements.
332
+ Formats the result as a percentage in the specified registry's units.
333
+ """
334
+ result = pyxirr.xirr(
329
335
  dates=list(self.movements.index.array),
330
336
  amounts=self.movements.to_list(),
331
337
  )
338
+ return result * 100 * registry.percent
332
339
 
333
340
  def xnpv(
334
341
  self,
335
- rate: float,
336
- ) -> float:
337
- return pyxirr.xnpv(
342
+ rate: Union[float, pint.Quantity],
343
+ ) -> pint.Quantity:
344
+ """
345
+ Returns the XNPV (Extended Net Present Value) of the Flow's movements at a specified rate.
346
+ Formats the result as a quantity in the Flow's units.
347
+ """
348
+ if isinstance(rate, pint.Quantity):
349
+ rate = rate.to(rk.measure.Index.registry.dimensionless).magnitude
350
+ result = pyxirr.xnpv(
338
351
  rate=rate,
339
352
  dates=list(self.movements.index.array),
340
353
  amounts=self.movements.to_list(),
341
354
  )
355
+ return result * self.units
342
356
 
343
357
  def diff(
344
358
  self,
@@ -102,7 +102,7 @@ def register_currency(
102
102
  return Measure(
103
103
  name=currency.name,
104
104
  definition="Currency of {0}".format(currency.countries),
105
- units=registry[currency.code].units,
105
+ units=registry.parse_units(currency.code),
106
106
  )
107
107
 
108
108
 
File without changes
File without changes