# Mean-Variance Portfolio Optimization#

This section provides several self-contained Jupyter notebooks which discuss the modeling of typical features in mean-variance (M-V) portfolio optimization.

Data Preparation. This notebook prepares the example data that is used throughout the other modeling notebooks. The data is based on historical returns for 462 stocks from the S&P 500 and incorporates shrinkage for the first moment.

## Basic Markowitz model#

There exist three different basic kinds of M-V models, depending on which quantity is to be optimized, and which quantity is constrained:

Maximizing Return. We show a basic M-V problem where we maximize the expected return subject to a prescribed maximum variance.

Minimizing Variance. We show a basic M-V problem where we minimize the expected variance subject to a prescribed minimum expected return.

Maximizing Utility. We show a basic M-V problem where we optimize a combination of risk and return, parametrized by a risk-aversion coefficient.

## Factor models#

Another set of tools for representing risk are *factor models*, which
comprise a combination of market risks and idiosyncratic risk information on
the assets. Such representations can be used either as part of the objective
function, or to formulate constraints on the admissible variance:

## Portfolio constraints#

The following notebooks explain how to model certain portfolio features on top of the above base formulations:

Minimum Buy-In. Tiny transaction sizes can be avoided by enforcing a minimum amount whenever a position is opened.

Cardinality Constraints. To avoid scattering the investment across too many assets, one can impose

*cardinality constraints*on the portfolio, that is, bounding the number of open positions.Enforcing Diversification. To increase diversification, one can impose bounds on the individual positions and enforce that a given minimum number of positions is traded.

Leverage by Short-Selling. We show how to incorporate short-selling into the base model and how to add limits on the total short-sell (e.g., 130/30 strategy).

Leverage by Borrowing Cash. We include a risk-free asset (e.g., money market) that can be used for leveraging long positions within prescribed bounds.

Limiting Turnover. If a given portfolio is to be rebalanced, we show how to limit the turnover, that is, the total change to the starting portfolio.

Round Lot Constraints. Securities are often traded in

*lots*(i.e., a fixed number of units). To avoid small positions, one might also require a minimum number of units if a position is opened.

## Transaction costs and slippage#

For trading assets on the market, it is possible to incorporate further pricing mechanisms into the optimization model:

Investing with Transaction Costs. We show how to include fixed-charges and proportional transaction costs.

Rebalancing with Transaction Costs. Instead of starting from an all-cash position, we show how to rebalance an existing portfolio subject to fixed-charges and proportional costs.

Market Impact Costs. Huge transactions can affect the market price by itself, and in this notebook we show one standard approach for modeling such slippage.