# MVFRONTIER

## Description

Solve for multiple mean-variance optimal portfolios on the efficient frontier. Evaluate the absolute return and risk tradeoffs. The function allows you to specify both linear and non-linear constraints and is able to account for friction penalties (transaction costs).

{% hint style="warning" %}
The convexity of the efficient frontier may not necessarily hold when transaction costs are present.
{% endhint %}

## Syntax

The following describes the function signature for use in Microsoft Excel's formula bar.

```excel-formula
=MVFRONTIER(P, mu, sigma, rho, wInitial, tc, lb, ub, constraints)
```

### Input(s)

| Argument        | Description                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **P**           | Required. Number of portfolios to solve for, $$P \geq 5$$.                                                                                                                                                                                                                                                                                                                                                                                               |
| **mu**          | Required. Vector of expected returns.                                                                                                                                                                                                                                                                                                                                                                                                                    |
| **sigma**       | Required. Vector of expected risk.                                                                                                                                                                                                                                                                                                                                                                                                                       |
| **rho**         | Required. Correlation matrix.                                                                                                                                                                                                                                                                                                                                                                                                                            |
| **wInitial**    | Optional. Vector of initial weights (or your current weights). This is used to measure the friction penalties or as a starting point should a numerical approach be necessary. If not specified, it defaults to a vector of zeros.                                                                                                                                                                                                                       |
| **tc**          | Optional. Vector of transaction costs. If the argument is not specified, it defaults to a vector zeros.                                                                                                                                                                                                                                                                                                                                                  |
| **lb**          | Optional. Vector of lower bound limits. If the argument is not specified, it defaults to a vector zeros.                                                                                                                                                                                                                                                                                                                                                 |
| **ub**          | Optional. Vector of upper bound limits. If the argument is not specified, it defaults to a vector ones.                                                                                                                                                                                                                                                                                                                                                  |
| **constraints** | <p>Optional. Matrix of constraints, operator enumeration, and values: <span class="math">\begin{bmatrix}A & op \&b\end{bmatrix}</span> </p><p><br>The operator enumeration is represented by <span class="math">op \in \begin{cases} 0: & \leq  \1: & = \ 2: & \geq \end{cases}</span> </p><p><br>If the argument is not specified, it will default to a fully-funded constraint. <br>i.e. <span class="math">\[1, 1, \ldots , 1\_{N}, 1, 1]</span> </p> |

### Output(s)

The function returns optimal weights $$w$$ across $$N$$assets for $$P$$portfolios. The portfolios' expected return, risk, and corresponding optimization's exit flag is appended at the end of the matrix.

&#x20;  $$\text{output}=  \begin{bmatrix}  w\_{1,1} & w\_{1,2} & \ldots & w\_{1,N}  & \mu\_1 & \sigma\_1 &  \text{exitFlag}*1    \  w*{2,1} & w\_{2,2} & \ldots & w\_{2,N}  & \mu\_2 & \sigma\_2 &  \text{exitFlag}*2 \ \  \vdots & \vdots & \ddots & \vdots  & \vdots & \vdots &  \vdots \   \w*{P,1} & w\_{P,2} & \ldots & w\_{P,N}  & \mu\_P & \sigma\_P &  \text{exitFlag}\_P \       \end{bmatrix}$$&#x20;

The output matrix follows the vector orientation of mu (column / row). If you have specified your inputs as column-vectors, the corresponding output matrix will be transpose of the above.

| exitFlag | Description                                                                                         |
| :------: | --------------------------------------------------------------------------------------------------- |
|  **-2**  | No feasible solution found. Check your constraints and problem definition.                          |
|  **-1**  | Unexpected interruption.                                                                            |
|   **0**  | Number of iterations exceeded.                                                                      |
|   **1**  | First-order optimality measure is less than tolerance threshold and the constraints were satisfied. |
|   **2**  | Delta in optimal weights is less than the configured numerical step size.                           |
|   **3**  | Change in the expected utility value is less than the tolerance threshold.                          |
|   **4**  | Magnitude of search direction was less than the configured threshold.                               |
|   **5**  | Magnitude of directional derivative in the search direction was less than the configured threshold. |

## Example

![](https://258561627-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MK66-MGuoULhqCDXLwy%2F-MM2UQQL-If-fHvfKXhc%2F-MM2_D199BiOE2hfuC4U%2Fimage.png?alt=media\&token=0ffd05d4-46c4-41a5-a93e-2fb0cf1a0998)

{% file src="<https://258561627-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MK66-MGuoULhqCDXLwy%2F-MQVCEXREBy8OpqkO4hg%2F-MQVCL9vVCHmPZsIEcdu%2FMVFRONTIER.xlsx?alt=media&token=778de35f-95fd-4f9c-bd3b-bc3930c327b6>" %}
Example Workbook: MVFRONTIER
{% endfile %}
