Skip to content

Commit

Permalink
docs: add docstrings to new classes and methods
Browse files Browse the repository at this point in the history
  • Loading branch information
chilango74 committed Oct 2, 2024
1 parent 67e0844 commit e26e673
Show file tree
Hide file tree
Showing 4 changed files with 222 additions and 58 deletions.
4 changes: 2 additions & 2 deletions okama/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class Asset:
Parameters
----------
symbol: str, default "SPY.US"
Symbol is an asset ticker with namespace after dot. The default value is "SPY.US" (SPDR S&P 500 ETF Trust).
symbol: str, default 'SPY.US'
Symbol is an asset ticker with a namespace after dot. The default value is 'SPY.US' (SPDR S&P 500 ETF Trust).
"""

def __init__(self, symbol: str = settings.default_ticker):
Expand Down
12 changes: 6 additions & 6 deletions okama/common/helpers/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,16 +224,16 @@ def get_wealth_indexes_with_cashflow(
portfolio_position = 0
ror = ror.to_frame()

if cashflow_parameters.frequency == "month" or cashflow_parameters.name == "time_series":
if cashflow_parameters.frequency == "month" or cashflow_parameters.NAME == "time_series":
s = pd.Series(dtype=float, name=portfolio_symbol)
for n, row in enumerate(ror.itertuples()):
date = row[0]
r = row[portfolio_position + 1]
if cashflow_parameters.name == "fixed_amount":
if cashflow_parameters.NAME == "fixed_amount":
cashflow = amount * (1 + cashflow_parameters.indexation / settings._MONTHS_PER_YEAR) ** n
elif cashflow_parameters.name == "fixed_percentage":
elif cashflow_parameters.NAME == "fixed_percentage":
cashflow = cashflow_parameters.percentage * period_initial_amount
elif cashflow_parameters.name == "time_series":
elif cashflow_parameters.NAME == "time_series":
try:
cashflow = cashflow_parameters.time_series[date]
if dcf_object.use_discounted_values:
Expand All @@ -256,9 +256,9 @@ def get_wealth_indexes_with_cashflow(
for n, x in enumerate(ror.resample(rule=pandas_frequency, convention="start")):
ror_df = x[1].iloc[:, portfolio_position] # select ror part of the grouped data
period_wealth_index = period_initial_amount * (1 + ror_df).cumprod()
if cashflow_parameters.name == "fixed_amount":
if cashflow_parameters.NAME == "fixed_amount":
cashflow_value = amount * (1 + cashflow_parameters.indexation / periods_per_year) ** n
elif cashflow_parameters.name == "fixed_percentage":
elif cashflow_parameters.NAME == "fixed_percentage":
cashflow_value = cashflow_parameters.percentage * period_initial_amount
else:
raise ValueError("Wrong cashflow_method value.")
Expand Down
2 changes: 1 addition & 1 deletion okama/macro.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def annual_inflation_ts(self):
@property
def purchasing_power_1000(self) -> float:
"""
Calculate purchasing power of 1000 (in the currency of inflation) after period from first_date to last_date.
Purchasing power of 1000 (in the currency of inflation) after period from first_date to last_date.
Returns
-------
Expand Down
Loading

0 comments on commit e26e673

Please sign in to comment.