Skip to content

Commit c6fca97

Browse files
committed
chore: update typehints for matplotlib Axes
1 parent 946079a commit c6fca97

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
# rebalancing_strategy=ok.Rebalance(period="year"), # set rebalancing period to one year
3535
)
3636

37-
ef_points = x.ef_points
37+
x.plot_transition_map(x_axe="risk")
3838

39-
print(ef_points[["Mean return", "CAGR"]])
39+
plt.show()
4040

okama/common/make_asset_list.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import numpy as np
66
import pandas as pd
77
import matplotlib.pyplot as plt
8+
from matplotlib.axes import Axes
89

910
from okama import macro, asset, settings
1011
from okama.common import validators
@@ -436,7 +437,7 @@ def plot_assets(
436437
tickers: Union[str, list] = "tickers",
437438
pct_values: bool = False,
438439
xy_text: tuple = (0, 10),
439-
) -> plt.axes:
440+
) -> Axes:
440441
"""
441442
Plot the assets points on the risk-return chart with annotations.
442443

okama/frontier/single_period.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import pandas as pd
55
import numpy as np
66
import matplotlib.pyplot as plt
7+
from matplotlib.axes import Axes
78

89
from scipy.optimize import minimize
910

@@ -940,7 +941,7 @@ def get_monte_carlo(self, n: int = 100, kind: str = "mean") -> pd.DataFrame:
940941
random_portfolios = helpers.Frame.change_columns_order(random_portfolios, ["Risk", second_column])
941942
return random_portfolios
942943

943-
def plot_transition_map(self, x_axe: str = "risk", figsize: Optional[tuple] = None) -> plt.axes:
944+
def plot_transition_map(self, x_axe: str = "risk", figsize: Optional[tuple] = None) -> Axes:
944945
"""
945946
Plot Transition Map for optimized portfolios on the single period Efficient Frontier.
946947
@@ -960,12 +961,6 @@ def plot_transition_map(self, x_axe: str = "risk", figsize: Optional[tuple] = No
960961
961962
Parameters
962963
----------
963-
bounds : tuple of ((float, float),...)
964-
Bounds for the assets weights. Each asset can have weights limitation from 0 to 1.0.
965-
If an asset has limitation for 10 to 20%, bounds are defined as (0.1, 0.2).
966-
bounds = ((0, .5), (0, 1)) shows that in Portfolio with two assets first one has weight limitations
967-
from 0 to 50%. The second asset has no limitations.
968-
969964
x_axe : {'risk', 'cagr'}, default 'risk'
970965
Show the relation between weights and CAGR (if 'cagr') or between weights and Risk (if 'risk').
971966
CAGR or Risk are displayed on the x-axis.
@@ -1013,7 +1008,7 @@ def plot_transition_map(self, x_axe: str = "risk", figsize: Optional[tuple] = No
10131008
fig.tight_layout()
10141009
return ax
10151010

1016-
def plot_pair_ef(self, tickers="tickers", figsize: Optional[tuple] = None) -> plt.axes:
1011+
def plot_pair_ef(self, tickers="tickers", figsize: Optional[tuple] = None) -> Axes:
10171012
"""
10181013
Plot Efficient Frontier of every pair of assets.
10191014
@@ -1089,7 +1084,7 @@ def plot_pair_ef(self, tickers="tickers", figsize: Optional[tuple] = None) -> pl
10891084
self.plot_assets(kind="mean", tickers=tickers)
10901085
return ax
10911086

1092-
def plot_cml(self, rf_return: float = 0, y_axe: str = "cagr", figsize: Optional[tuple] = None) -> plt.axes:
1087+
def plot_cml(self, rf_return: float = 0, y_axe: str = "cagr", figsize: Optional[tuple] = None) -> Axes:
10931088
"""
10941089
Plot Capital Market Line (CML).
10951090

0 commit comments

Comments
 (0)