Skip to content

Commit d619dbb

Browse files
committed
chore: make VanguardDynamicSpending.calculate_withdrawal_size a private method
1 parent e2449f5 commit d619dbb

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

okama/portfolios/cashflow_strategies.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -666,9 +666,9 @@ def indexation(self, indexation: Optional[float]):
666666
self._clear_cf_cache()
667667
self._indexation = indexation
668668

669-
def calculate_withdrawal_size(self, last_withdrawal: float, balance: float, number_of_periods: int) -> float:
669+
def _calculate_withdrawal_size(self, last_withdrawal: float, balance: float, number_of_periods: int) -> float:
670670
"""
671-
Calculate regular withdrawal size (Extra Withdrawals are not taken into account).
671+
Calculate regular withdrawal size (Extra Withdrawals are not taken into account). Used in helpers.
672672
673673
Parameters
674674
----------
@@ -829,9 +829,9 @@ def crash_threshold_reduction(self, value):
829829
self._crash_threshold_reduction = value
830830

831831

832-
def calculate_withdrawal_size(self, drawdown: float, withdrawal_without_drawdowns: float) -> float:
832+
def _calculate_withdrawal_size(self, drawdown: float, withdrawal_without_drawdowns: float) -> float:
833833
"""
834-
Calculate regular withdrawal size (Extra Withdrawals are not taken into account).
834+
Calculate regular withdrawal size (Extra Withdrawals are not taken into account). Used in helpers.
835835
836836
Parameters
837837
----------

okama/portfolios/dcf_calculations.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def get_wealth_indexes_fv_with_cashflow(
7777
elif cashflow_parameters.NAME == "CWID":
7878
withdrawal_without_drawdowns = amount * (1 + indexation_per_period) ** n
7979
if drawdowns[date] < 0:
80-
cashflow = cashflow_parameters.calculate_withdrawal_size(
80+
cashflow = cashflow_parameters._calculate_withdrawal_size(
8181
drawdown=drawdowns[date],
8282
withdrawal_without_drawdowns=withdrawal_without_drawdowns,
8383
)
@@ -116,15 +116,15 @@ def get_wealth_indexes_fv_with_cashflow(
116116
elif cashflow_parameters.NAME == "fixed_percentage":
117117
cashflow_value = cashflow_parameters.percentage / periods_per_year * period_initial_amount
118118
elif cashflow_parameters.NAME == "VDS":
119-
cashflow_value = cashflow_parameters.calculate_withdrawal_size(
119+
cashflow_value = cashflow_parameters._calculate_withdrawal_size(
120120
last_withdrawal=last_regular_cash_flow if n > 0 else 0,
121121
balance=period_initial_amount,
122122
number_of_periods=n,
123123
)
124124
elif cashflow_parameters.NAME == "CWID":
125125
withdrawal_without_drawdowns = amount * (1 + indexation_per_period) ** n
126126
if drawdowns[last_date] < 0:
127-
cashflow_value = cashflow_parameters.calculate_withdrawal_size(
127+
cashflow_value = cashflow_parameters._calculate_withdrawal_size(
128128
drawdown=drawdowns[last_date],
129129
withdrawal_without_drawdowns=withdrawal_without_drawdowns,
130130
)
@@ -218,7 +218,7 @@ def get_cash_flow_fv(
218218
elif cashflow_parameters.NAME == "CWID":
219219
withdrawal_without_drawdowns = amount * (1 + indexation_per_period) ** n
220220
if drawdowns[date] < 0:
221-
cashflow = cashflow_parameters.calculate_withdrawal_size(
221+
cashflow = cashflow_parameters._calculate_withdrawal_size(
222222
drawdown = drawdowns[date],
223223
withdrawal_without_drawdowns = withdrawal_without_drawdowns,
224224
)
@@ -258,15 +258,15 @@ def get_cash_flow_fv(
258258
elif cashflow_parameters.NAME == "fixed_percentage":
259259
cashflow_value = cashflow_parameters.percentage / periods_per_year * period_initial_amount
260260
elif cashflow_parameters.NAME == "VDS":
261-
cashflow_value = cashflow_parameters.calculate_withdrawal_size(
261+
cashflow_value = cashflow_parameters._calculate_withdrawal_size(
262262
last_withdrawal=last_regular_cash_flow if n > 0 else 0,
263263
balance=period_initial_amount,
264264
number_of_periods=n,
265265
)
266266
elif cashflow_parameters.NAME == "CWID":
267267
withdrawal_without_drawdowns = amount * (1 + indexation_per_period) ** n
268268
if drawdowns[last_date] < 0:
269-
cashflow_value = cashflow_parameters.calculate_withdrawal_size(
269+
cashflow_value = cashflow_parameters._calculate_withdrawal_size(
270270
drawdown = drawdowns[last_date],
271271
withdrawal_without_drawdowns = withdrawal_without_drawdowns,
272272
)

0 commit comments

Comments
 (0)