From 17de52347da18e0476974f86810394c416243abe Mon Sep 17 00:00:00 2001 From: Alexandr Zaytsev Date: Sun, 26 Jul 2026 17:11:06 +0300 Subject: [PATCH 1/2] =?UTF-8?q?fix(helpers):=20fix=20type=20annotation=20b?= =?UTF-8?q?ug:=20`np.array`=20=E2=86=92=20`np.ndarray`=20in=20`helpers.py`?= =?UTF-8?q?=20(TypeError=20on=20Python=203.11+)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- okama/common/helpers/helpers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/okama/common/helpers/helpers.py b/okama/common/helpers/helpers.py index fd41586..957b55e 100644 --- a/okama/common/helpers/helpers.py +++ b/okama/common/helpers/helpers.py @@ -255,7 +255,7 @@ def get_portfolio_return_ts(cls, weights: list, ror: pd.DataFrame) -> pd.Series: return ror @ weights @classmethod - def get_portfolio_mean_return(cls, weights: list | np.array, ror: pd.DataFrame) -> float: + def get_portfolio_mean_return(cls, weights: list | np.ndarray, ror: pd.DataFrame) -> float: """ Computes arithmetic mean return of a portfolio return (monthly as ROR time series are monthly in okama). @@ -383,7 +383,7 @@ def _(wealth: pd.DataFrame, discount_rate: float, threshold: float = 0) -> pd.Se # Risk metrics @classmethod - def get_portfolio_risk(cls, weights: list | np.array, assets_ror: pd.DataFrame) -> float: + def get_portfolio_risk(cls, weights: list | np.ndarray, assets_ror: pd.DataFrame) -> float: """ Compute the standard deviation of return for monthly rebalanced portfolio. """ From 18ecc82a5b13c12c5f78212fa37ac014c1635b43 Mon Sep 17 00:00:00 2001 From: Alexandr Zaytsev Date: Sun, 26 Jul 2026 17:21:24 +0300 Subject: [PATCH 2/2] docs(readme): unify quotation marks in code examples --- README.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 7604a7d..9baec5d 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,7 @@ poetry install ```python import okama as ok -x = ok.AssetList(['SPY.US', 'BND.US', 'DBXD.XFRA'], ccy='USD') +x = ok.AssetList(["SPY.US", "BND.US", "DBXD.XFRA"], ccy="USD") x ``` ![](https://raw.githubusercontent.com/mbk-dev/okama/images/images/readmi01.jpg) @@ -144,8 +144,8 @@ x.wealth_indexes.plot() ```python weights = [0.3, 0.2, 0.2, 0.2, 0.1] -assets = ['T.US', 'XOM.US', 'FRE.XFRA', 'SNW.XFRA', 'LKOH.MOEX'] -pf = ok.Portfolio(assets, weights=weights, ccy='EUR') +assets = ["T.US", "XOM.US", "FRE.XFRA", "SNW.XFRA", "LKOH.MOEX"] +pf = ok.Portfolio(assets, weights=weights, ccy="EUR") pf.table ``` ![](https://raw.githubusercontent.com/mbk-dev/okama/images/images/readmi04.jpg) @@ -160,11 +160,11 @@ pf.dividend_yield.plot() ### 3. Draw an Efficient Frontier for 2 popular ETF: SPY and GLD ```python -ls = ['SPY.US', 'GLD.US'] -curr = 'USD' -last_date = '2020-10' +ls = ["SPY.US", "GLD.US"] +curr = "USD" +last_date = "2020-10" # Rebalancing period is one year (default value) -frontier = ok.EfficientFrontier(ls, last_date=last_date, ccy=curr, rebalancing_strategy=ok.Rebalance(period='year')) +frontier = ok.EfficientFrontier(ls, last_date=last_date, ccy=curr, rebalancing_strategy=ok.Rebalance(period="year")) frontier.names ``` ![](https://raw.githubusercontent.com/mbk-dev/okama/images/images/readmi06.jpg) @@ -175,19 +175,19 @@ import matplotlib.pyplot as plt points = frontier.ef_points -fig = plt.figure(figsize=(12,6)) +fig = plt.figure(figsize=(12, 6)) fig.subplots_adjust(bottom=0.2, top=1.5) -frontier.plot_assets(kind='cagr') # plots the assets points on the chart +frontier.plot_assets(kind="cagr") # plots the assets points on the chart ax = plt.gca() -ax.plot(points.Risk, points.CAGR) +ax.plot(points.Risk, points.CAGR) ``` ![](https://raw.githubusercontent.com/mbk-dev/okama/images/images/readmi07.jpg) ### 4. Get a Transition Map for allocations ```python -ls = ['SPY.US', 'GLD.US', 'BND.US'] -ok.EfficientFrontier(ls, ccy='USD').plot_transition_map(x_axe='risk') +ls = ["SPY.US", "GLD.US", "BND.US"] +ok.EfficientFrontier(ls, ccy="USD").plot_transition_map(x_axe="risk") ``` ![Transition map](https://raw.githubusercontent.com/mbk-dev/okama/images/images/readmi08.jpg)