Skip to content

Commit

Permalink
chore: update get_wealth_indexes_with_cashflow in helpers.py
Browse files Browse the repository at this point in the history
  • Loading branch information
chilango74 committed Feb 21, 2024
1 parent 2199748 commit 2d9e081
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions okama/common/helpers/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,13 @@ def get_wealth_indexes_with_cashflow(
inflation_symbol: Optional[str],
discount_rate: float,
initial_amount: float = 1000.,
cashflow: int = 0,
cashflow: float = 0,
) -> Union[pd.Series, pd.DataFrame]:
"""
Returns wealth index for a serie of returns with cash flows (withdrawals/contributions).
Values of the wealth index correspond to the beginning of the month.
"""
# first_date = ror.index[0]
if not cashflow:
wealth_index = Frame.get_wealth_indexes(ror, initial_amount)
else:
Expand All @@ -215,6 +214,7 @@ def get_wealth_indexes_with_cashflow(
s = pd.Series(dtype=float, name=portfolio_symbol)
for n, row in enumerate(ror.itertuples()):
r = row[portfolio_position + 1]
# TODO: consider using monthly inflation for cashflow indexing
value = value * (r + 1) + cashflow * (1 + discount_rate / settings._MONTHS_PER_YEAR) ** n
date = row[0]
s[date] = value
Expand Down

0 comments on commit 2d9e081

Please sign in to comment.