Path: blob/main/notebooks/02/03-mad-portfolio-optimization.ipynb
663 views
2.3 Mean Absolute Deviation (MAD) portfolio optimization
Portfolio optimization and modern portfolio theory has a long and important history in finance and investment. The principal idea is to find a blend of investments in financial securities that achieves an optimal trade-off between financial risk and return. The introduction of modern portfolio theory is generally attributed to the 1952 doctoral thesis of Harry Markowitz who subsequently was award a share of the 1990 Nobel Memorial Prize in Economics for his fundamental contributions to this field. The well-known "Markowitz Model" models measure risk using covariance of the portfolio with respect to constituent assets, then solves a minimum variance problem by quadratic optimization problem subject to constraints to allocate of wealth among assets.
In a remarkable 1991 paper, Konno and Yamazaki proposed a different approach using the mean absolute deviation (MAD) in portfolio return as a measure of financial risk. The proposed implementation directly incorporates historical price data into a large scale linear optimization problem.
Preamble: Install Pyomo and a solver
The following cell sets and verifies a global SOLVER for the notebook. If run on Google Colab, the cell installs Pyomo and the HiGHS solver, while, if run elsewhere, it assumes Pyomo and HiGHS have been previously installed. It then sets to use HiGHS as solver via the appsi module and a test is performed to verify that it is available. The solver interface is stored in a global object SOLVER for later use.
Installing yfinance
The notebook uses the yfinance module to read data from Yahoo Finance. Web interfaces for financial services are notoriously fickle and subject to change, and a particular issue with Google Colaboratory.
Download historical stock price data
The following cell downloads a list of stock symbols from Yahoo Finance. By changing n_years we can change the historical period. The first step in this analysis is to load and consolidate the asset price information into a single DataFrame named assets. The consolidated price information consists of the adjusted closing price reported by Yahoo Finance which includes adjustments for stock splits and dividend distributions.
Analysis of historical asset prices
Scaled asset prices
The historical prices are scaled to a value to have unit value at the start of the historical period. Scaling facilitates plotting and subsequent calculations while preserving arithmetic and logarithmic returns needed for analysis.
Statistics of daily returns
The scaled price of asset on trading day is designated . The daily return is computed as
where . The mean return for asset is
The following cells compute and display the daily returns for all assets and displays as time series and histograms.
Mean Absolute Deviation
The mean absolute deviation for asset is
where is the period under consideration. We now calculate the mean daily return and the mean absolute deviation in daily returns for all assets and display the distributions of daily returns for all assets. For each asset, we depict the mean return (in red) and the interval whose size corresponds to its mean absolute deviation (in green).
The mean daily return and the mean absolute deviation in daily returns are plotted as bar charts in the following cell. The side by side comparison provides a comparison of return vs. volatility for individual assets.
We now plot the mean return and mean absolute deviation for all assets using a scatter plot. The scatter plot provides a visual comparison of the trade-off between return and volatility for individual assets.
Analysis of a portfolio of assets
Return on a portfolio
Given a portfolio with value at time , return on the portfolio at is defined as
For the period from we assume there are shares of asset with a starting value of per share. The initial and final values of the portfolio are then
The return of the portfolio is given by
where is the return on asset at time .
Defining as the wealth invested in asset at time , then is the fraction of total wealth invested in asset at time . The return on a portfolio of assets is then given by
on a single interval extending from to .
Mean Absolute Deviation (MAD) portfolio optimization
The portfolio optimization problem is to find an allocation of investments weights to minimize the portfolio measure of risk subject to constraints on required return and any other constraints that an investor wishes to impose. Assume that we can make investment decisions on every trading day over a fixed time horizon ranging from and that there is a set of assets in which we can choose to invest.
If we want to have a guaranteed minimum portfolio return , but at the same time minimize risk, we could choose to have the mean absolute deviation (MAD) in portfolio returns as the objective function. More specifically, we can consider the return on a portfolio of assets over a period of intervals with weights for asset given by
where is the return on asset at time , is the mean return for asset , and is the fraction of the total portfolio that is invested in asset . Note that due to the use of absolute values, the MAD for the portfolio is not the weighted sum of the MADs for individual assets.
The resulting Mean Absolute Deviation (MAD) portfolio optimization problem then is
where is the minimum required portfolio return. The lower bound is a "no short sales" constraint. The upper bound enforces a required level of diversification in the portfolio.
Defining two sets of auxiliary variables and for every , leads to a reformulation of the problem as a linear optimization:
Pyomo model
MAD risk versus return
The portfolio optimization problem has been formulated as the minimization of a risk measure, MAD, subject to a lower bound on mean portfolio return. Increasing the required return for the portfolio therefore comes at the cost of tolerating a higher level of risk. Finding the optimal trade off between risk and return is a central aspect of any investment strategy.
The following cell creates a plot of the risk/return trade off by solving the MAD portfolio optimization problem for increasing values of required return . This should be compared to the similar construction commonly used in presentations of the portfolio optimization problem due to Markowitz.
Addition of a Risk-free Asset
The option of a holding a risk-free asset as a component of investment can substantially reduce financial risk. The risk-free asset is designated as with a fixed return . The fraction invested in asset will be . The optimization model becomes
Like for the original MAD portfolio optimization problem, also this one can be reformulated as an LO:
MAD risk versus return with a risk-free asset
As above, it is instructive to plot the MAD risk versus required return . The result is similar, but not exactly the same, as the standard presentation from modern portfolio theory (MPT) for efficient frontier of investing, and the capital market line. A careful look at the the plot below shows minor difference at very high levels of return and risk that departs from the MPT analysis.