Professional Documents
Culture Documents
Equity Analytics - Modern Portfolio Theory-Jonathan Kinlay
Equity Analytics - Modern Portfolio Theory-Jonathan Kinlay
In 1952, Harry Markowitz introduced the concept of Modern Portfolio Theory through his doctoral
thesis, commonly referred to as the Markowitz model. This theory is based on the idea that investors
aim to maximize a portfolio' s expected return while considering a certain level of risk. Efficient
portfolios, which meet this criterion, are those where achieving a higher expected return necessitates
taking on more risk. As a result, investors must strike a balance between risk and expected return. The
relationship between risk and expected return for efficient portfolios is illustrated by the efficient
frontier, a graph that displays this trade - off. All efficient portfolios, represented as points on the
efficient frontier, are diversified to minimize risk. In this chapter we review some of the core concepts of
MTP and illustrate how to approach the portfolio optimization problem in the Wolfram Language.
Portfolio Construction
We begin our exploration of the topic of modern portfolio theory by defining a universe of stocks
comprising a random sample of 25 of the constituents of the S&P 500 index as a selected point in time:
I n [ ] : = startDate = DateObject[{2018, 1, 3}]
O u t [ ] =
25
O u t [ ] / / S h o r t =
The RandomWeighting function is used to generate 10,000 different sets of weights that are applied to
the stocks in the investment universe to create 10,000 different portfolios. All of the portfolio weights
must lie in the range {0, 1}, i.e. we do not allow short sales and the sum of the weights must equal 1.0
(no leverage). We examine the annual return and volatility of these portfolios over the preceding 5
years.
2 Modern Portfolio Theory.nb
I n [ ] : = AbsoluteTiming[
portfolioRiskReturn = ParallelTable[PortfolioRiskReturn[tsPortfolioReturns,
weights /. weights wgt], {wgt, wgts}, Method "CoarsestGrained"];]
O u t [ ] =
{101.076, Null}
The result is an array of annual return and volatilities for each of the 10,000 portfolios:
I n [ ] : = portfolioRiskReturn〚1 ;; 5, 1 ;; 2〛
O u t [ ] =
{0.104783, 0.0998676}
For completeness, we also find the volatility and return of the S&P 500 index over the same period
{0.118687, 0.120999}
lying on the frontier using the FindMinimum function to identify the allocation weights for portfolios
that have the lowest volatility for a specified rate of return (in the range of 1% to 32%).
I n [ ] : = effFrontier = ParallelTable[{FindMinimum[{portfolioVolatility,
portfolioConstraints && portfolioAverageReturns i}, weights]〚1〛, i},
{i, 0.01, 0.32, .02}, Method "CoarsestGrained"] // Quiet;
We will also compute the allocation weights for several portfolios on the frontier:
I n [ ] : = effFrontierWgts = ParallelTable[FindMinimum[{portfolioVolatility, Total[weights] 1 &&
portfolioAverageReturns i && And @@ (0 ≤ # ≤ 1 & /@ weights)}, weights]〚2〛,
{i, 0.15, 0.30, .05}, Method "CoarsestGrained"] // Quiet;
Finally, we are ready to combine all of the above information in a single plot that shows the efficient
frontier, global minimum variance portfolio and other portfolios on the frontier and the collection of
portfolios we created using random sets of allocation weights:
O u t [ ] =
Return
0.30
0.20
0.15
0.10
0.05
Volatility
0.11 0.12 0.13 0.14 0.15 0.16 0.17
PEP 0.405446, REG 0.0580264, RHI 3.98111 × 10-6 , RJF 7.00697 × 10-6 ,
I n [ ] : = PieChart3D[portfolio1,
ChartLegends Placed[Automatic, Right], SectorOrigin {Automatic, 1}]
O u t [ ] =
I n [ ] : = DateListPlot[
{CompoundReturn[tsPortReturns], CompoundReturn[tsSP500Returns]}, Filling Axis,
PlotLabels Join[Table[StringJoin["Portfolio ", ToString[i]], {i, 4}], {" SP500"}],
ImageSize Large, PlotRange All]
O u t [ ] =
4 Portfolio 4
3
Portfolio 3
2
Portfolio 2
Portfolio 1
1
SP500
When we evaluate portfolio performance after the formation period, however, the story is very differ-
ent. Although efficient portfolios outperform the S&P500 over the period from 2018-2022, there are
times when they under-perform the index and the equity curve suffers from several large periodic
declines lasting for several days, or weeks. This is the result of the extreme allocation profile of the
portfolios, which entails making several large bets on stocks such as PEP and CME, which performed
well during the formation period, but did much less well in the subsequent period from 2018. This
variability in performance is a typical characteristic of portfolios constructed by mean-variance opti-
mization.
For this reason equity portfolio managers will typically impose additional constraints on the allocation
weights, to avoid over- or under-weighting specific stocks or industry sectors, with the aim of construct-
ing portfolios that perform more robustly out of sample.
I n [ ] : = DateListPlot[
{CompoundReturn[tsPortReturns], CompoundReturn[tsSP500Returns]}, Filling Axis,
PlotLabels Join[Table[StringJoin["Portfolio ", ToString[i]], {i, 4}], {" SP500"}],
ImageSize Large]
O u t [ ] =
1.5
1.0
Portfolio 3
Portfolio 2
Portfolio 1
Portfolio 4
0.5
SP500
0.0
Depending on the year in question, we observe that an optimal portfolio with an expected return of,
say, 12% per year, might have an estimated annual volatility of as low as 7% (in 2015) to as high as 12%
(in 2019).
Modern Portfolio Theory.nb 7
0.02 0.04 0.06 0.08 0.02 0.04 0.06 0.08 0.10 0.12 0.0980.1000.1020.1040.1060.1080.110
0.106 0.108 0.110 0.112 0.114 0.116 0.116 0.117 0.118 0.119 0.120 0.121 0.118 0.120 0.122 0.124 0.126
Notes
◼ More on Modern Portfolio Theory