Rangekeeper 0.8.33__py3-none-any.whl → 0.8.34__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/duration.py +16 -3
- rangekeeper/flux.py +43 -22
- {rangekeeper-0.8.33.dist-info → rangekeeper-0.8.34.dist-info}/METADATA +1 -1
- {rangekeeper-0.8.33.dist-info → rangekeeper-0.8.34.dist-info}/RECORD +6 -6
- {rangekeeper-0.8.33.dist-info → rangekeeper-0.8.34.dist-info}/WHEEL +0 -0
- {rangekeeper-0.8.33.dist-info → rangekeeper-0.8.34.dist-info}/top_level.txt +0 -0
rangekeeper/duration.py
CHANGED
@@ -277,10 +277,23 @@ class Sequence:
|
|
277
277
|
:param bound: A terminating condition; either a pd.Timestamp end date or a (integer) number of periods
|
278
278
|
"""
|
279
279
|
if isinstance(bound, datetime.date):
|
280
|
+
freq = Type.period(frequency)
|
281
|
+
|
282
|
+
# Align to the start & ends of first & last periods
|
283
|
+
aligned_start = pd.Period(
|
284
|
+
value=include_start,
|
285
|
+
freq=freq,
|
286
|
+
).start_time.date()
|
287
|
+
|
288
|
+
aligned_end = pd.Period(
|
289
|
+
value=bound,
|
290
|
+
freq=freq,
|
291
|
+
).end_time.date()
|
292
|
+
|
280
293
|
return pd.period_range(
|
281
|
-
start=
|
282
|
-
end=
|
283
|
-
freq=
|
294
|
+
start=aligned_start,
|
295
|
+
end=aligned_end,
|
296
|
+
freq=freq,
|
284
297
|
name="periods",
|
285
298
|
)
|
286
299
|
elif isinstance(bound, int):
|
rangekeeper/flux.py
CHANGED
@@ -403,25 +403,44 @@ class Flow:
|
|
403
403
|
|
404
404
|
def to_periods(
|
405
405
|
self,
|
406
|
-
|
407
|
-
origin: Optional[Union[str, pd.Timestamp]] = "end_day",
|
406
|
+
index: pd.PeriodIndex,
|
408
407
|
) -> pd.Series:
|
409
408
|
"""
|
410
409
|
Returns a pd.Series (of index pd.PeriodIndex) with movements summed to specified frequency
|
411
410
|
"""
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
.groupby(level="period")
|
423
|
-
.sum()
|
411
|
+
resampled = self.resample(
|
412
|
+
frequency=rk.duration.Type.from_value(index.freqstr),
|
413
|
+
origin=index[0].start_time.date(),
|
414
|
+
)
|
415
|
+
|
416
|
+
return resampled.movements.to_period(freq=index.freq).reindex(
|
417
|
+
index=index,
|
418
|
+
method="pad",
|
419
|
+
limit=1,
|
420
|
+
fill_value=0,
|
424
421
|
)
|
422
|
+
# return self.resample(
|
423
|
+
# frequency=rk.duration.Type.from_value(index.freqstr)
|
424
|
+
# ).movements.reindex(
|
425
|
+
# index=index,
|
426
|
+
# # method="pad",
|
427
|
+
# # limit=1,
|
428
|
+
# fill_value=0,
|
429
|
+
# )
|
430
|
+
|
431
|
+
# return (
|
432
|
+
# # self.resample(
|
433
|
+
# # frequency=frequency,
|
434
|
+
# # origin=origin,
|
435
|
+
# # )
|
436
|
+
# self.movements.to_period(
|
437
|
+
# freq=rk.duration.Type.period(frequency),
|
438
|
+
# copy=True,
|
439
|
+
# )
|
440
|
+
# .rename_axis("period")
|
441
|
+
# .groupby(level="period")
|
442
|
+
# .sum()
|
443
|
+
# )
|
425
444
|
|
426
445
|
def earliest(self) -> datetime.date:
|
427
446
|
"""
|
@@ -550,20 +569,22 @@ class Stream:
|
|
550
569
|
self.end_date = max(dates)
|
551
570
|
"""The latest date of the Stream's constituent Flows' movements."""
|
552
571
|
|
572
|
+
self.index = rk.duration.Sequence.from_bounds(
|
573
|
+
include_start=self.start_date,
|
574
|
+
bound=self.end_date,
|
575
|
+
frequency=self.frequency,
|
576
|
+
)
|
577
|
+
|
553
578
|
self._resampled_flows = [
|
554
|
-
flow.to_periods(
|
555
|
-
frequency=self.frequency,
|
556
|
-
origin=self.start_date,
|
557
|
-
)
|
558
|
-
for flow in self.flows
|
579
|
+
flow.to_periods(index=self.index) for flow in self.flows
|
559
580
|
]
|
560
581
|
self.frame = (
|
561
582
|
pd.concat(
|
562
583
|
self._resampled_flows,
|
563
584
|
axis=1,
|
564
585
|
)
|
565
|
-
.fillna(0)
|
566
|
-
.sort_index()
|
586
|
+
# .fillna(0)
|
587
|
+
# .sort_index()
|
567
588
|
)
|
568
589
|
"""
|
569
590
|
A pd.DataFrame of the Stream's flow Flows accumulated into the Stream's frequency
|
@@ -584,7 +605,7 @@ class Stream:
|
|
584
605
|
|
585
606
|
formatted_flows = []
|
586
607
|
for flow in self.flows:
|
587
|
-
series = flow.to_periods(
|
608
|
+
series = flow.to_periods(index=self.frame.index)
|
588
609
|
formatted_flows.append(
|
589
610
|
_format_series(
|
590
611
|
series=series,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: Rangekeeper
|
3
|
-
Version: 0.8.
|
3
|
+
Version: 0.8.34
|
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
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
|
-
rangekeeper/duration.py,sha256=
|
4
|
+
rangekeeper/duration.py,sha256=ZskXtIJhb8hYV0eSoas3UPenHroiu0Qx2siWsBR6pBs,20780
|
5
5
|
rangekeeper/extrapolation.py,sha256=Zfsz2KwkImxEMMCNZaF8RpiQxlIgemS1dQkSnjliYU4,2814
|
6
|
-
rangekeeper/flux.py,sha256=
|
6
|
+
rangekeeper/flux.py,sha256=U7GhD0PCkfsOAiJDGw1E2WEQ2B9BWxZby3JVPIEv458,33067
|
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.
|
24
|
-
rangekeeper-0.8.
|
25
|
-
rangekeeper-0.8.
|
26
|
-
rangekeeper-0.8.
|
23
|
+
rangekeeper-0.8.34.dist-info/METADATA,sha256=w8ARoQcinhvVeVZXHGScmM4yC7OzshemLYWH3vw6epI,2212
|
24
|
+
rangekeeper-0.8.34.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
25
|
+
rangekeeper-0.8.34.dist-info/top_level.txt,sha256=7ov6d70lppmzKc088MAmRWnCtCRGA2cd43G28QBSv-c,12
|
26
|
+
rangekeeper-0.8.34.dist-info/RECORD,,
|
File without changes
|
File without changes
|