---
title: maxutil
description: Documentation page of the maxutil module in the OpenBB Terminal's portfolio
optimization tool. It includes the module's function signature with its parameters,
default values, and optional indicators. Specializations like risk measures and
return calculations are also detailed. Examples of use are provided for better understanding.
keywords:
- Docusaurus SEO
- Portfolio Optimization
- maxutil function
- Portfolio Management Tools
- Python in Finance
- Algorithmic Trading
- Risk Measures
- OpenBB maxutil
---
import HeadTitle from '@site/src/components/General/HeadTitle.tsx';
Optimize maximum utility weights
Source Code: [[link](https://github.com/OpenBB-finance/OpenBBTerminal/tree/main/openbb_terminal/portfolio/portfolio_optimization/po_model.py#L539)]
```python
openbb.portfolio.po.maxutil(portfolio_engine: portfolio_optimization.po_engine.PoEngine = None, symbols: List[str] = None, kwargs: Any)
```
---
## Parameters
| Name | Type | Description | Default | Optional |
| ---- | ---- | ----------- | ------- | -------- |
| portfolio_engine | PoEngine | Portfolio optimization engine, by default None
Use `portfolio.po.load` to load a portfolio engine | None | True |
| symbols | List[str] | List of symbols, by default None | None | True |
| interval | str | Interval to get data, by default '3y' | None | True |
| start_date | str | If not using interval, start date string (YYYY-MM-DD), by default "" | None | True |
| end_date | str | If not using interval, end date string (YYYY-MM-DD). If empty use last weekday, by default "" | None | True |
| log_returns | bool | If True use log returns, else arithmetic returns, by default False | None | True |
| freq | str | Frequency of returns, by default 'D'. Options: 'D' for daily, 'W' for weekly, 'M' for monthly | None | True |
| maxnan | float | Maximum percentage of NaNs allowed in the data, by default 0.05 | None | True |
| threshold | float | Value used to replace outliers that are higher than threshold, by default 0.0 | None | True |
| method | str | Method used to fill nan values, by default 'time'
For more information see `interpolate `__. | None | True |
| value | float | Amount to allocate to portfolio in long positions, by default 1.0 | None | True |
| value_short | float | Amount to allocate to portfolio in short positions, by default 0.0 | None | True |
| objective | str | Objective function of the optimization model, by default 'Sharpe'
Possible values are:
- 'MinRisk': Minimize the selected risk measure.
- 'Utility': Maximize the risk averse utility function.
- 'Sharpe': Maximize the risk adjusted return ratio based on the selected risk measure.
- 'MaxRet': Maximize the expected return of the portfolio. | None | True |
| risk_measure | str | The risk measure used to optimize the portfolio, by default 'MV'
Possible values are:
- 'MV': Standard Deviation.
- 'MAD': Mean Absolute Deviation.
- 'MSV': Semi Standard Deviation.
- 'FLPM': First Lower Partial Moment (Omega Ratio).
- 'SLPM': Second Lower Partial Moment (Sortino Ratio).
- 'CVaR': Conditional Value at Risk.
- 'EVaR': Entropic Value at Risk.
- 'WR': Worst Realization.
- 'ADD': Average Drawdown of uncompounded cumulative returns.
- 'UCI': Ulcer Index of uncompounded cumulative returns.
- 'CDaR': Conditional Drawdown at Risk of uncompounded cumulative returns.
- 'EDaR': Entropic Drawdown at Risk of uncompounded cumulative returns.
- 'MDD': Maximum Drawdown of uncompounded cumulative returns. | None | True |
| risk_free_rate | float | Risk free rate, annualized. Used for 'FLPM' and 'SLPM' and Sharpe objective function, by default 0.0 | None | True |
| risk_aversion | float | Risk aversion factor of the 'Utility' objective function, by default 1.0 | None | True |
| alpha | float | Significance level of VaR, CVaR, EDaR, DaR, CDaR, EDaR, Tail Gini of losses, by default 0.05 | None | True |
| target_return | float | Constraint on minimum level of portfolio's return, by default -1.0 | None | True |
| target_risk | float | Constraint on maximum level of portfolio's risk, by default -1.0 | None | True |
| mean | str | The method used to estimate the expected returns, by default 'hist'
Possible values are:
- 'hist': use historical estimates.
- 'ewma1': use ewma with adjust=True. For more information see `EWM `__.
- 'ewma2': use ewma with adjust=False. For more information see `EWM `__. | None | True |
| covariance | str | The method used to estimate the covariance matrix, by default 'hist'
Possible values are:
- 'hist': use historical estimates.
- 'ewma1': use ewma with adjust=True. For more information see `EWM `__.
- 'ewma2': use ewma with adjust=False. For more information see `EWM `__.
- 'ledoit': use the Ledoit and Wolf Shrinkage method.
- 'oas': use the Oracle Approximation Shrinkage method.
- 'shrunk': use the basic Shrunk Covariance method.
- 'gl': use the basic Graphical Lasso Covariance method.
- 'jlogo': use the j-LoGo Covariance method. For more information see: `a-jLogo`.
- 'fixed': denoise using fixed method. For more information see chapter 2 of `a-MLforAM`.
- 'spectral': denoise using spectral method. For more information see chapter 2 of `a-MLforAM`.
- 'shrink': denoise using shrink method. For more information see chapter 2 of `a-MLforAM`. | None | True |
| d_ewma | float | The smoothing factor of ewma methods, by default 0.94 | None | True |
---
## Returns
| Type | Description |
| ---- | ----------- |
| Tuple[pd.DataFrame, Dict] | Tuple with weights and performance dictionary |
---
## Examples
```python
from openbb_terminal.sdk import openbb
openbb.portfolio.po.maxutil(symbols=["AAPL", "MSFT", "AMZN"])
```
```
( value
AAPL 1.0
MSFT 0.0
AMZN 0.0,
{'Return': 0.3448948339574538,
'Volatility': 0.36513261935342495,
'Sharpe ratio': 0.9445741510802071})
```
```python
from openbb_terminal.sdk import openbb
p = openbb.portfolio.po.load(symbols_file_path="~/openbb_terminal/miscellaneous/portfolio_examples/allocation/60_40_Portfolio.xlsx")
weights, performance = openbb.portfolio.po.maxutil(portfolio_engine=p)
```
---