Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions okama/common/helpers/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down Expand Up @@ -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.
"""
Expand Down
Loading