-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
modern-portfolio-theory.qmd
290 lines (224 loc) · 15.6 KB
/
modern-portfolio-theory.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
# Modern Portfolio Theory {#sec-modernPortfolioTheory}
## Getting Started {#sec-modernPortfolioTheoryGettingStarted}
### Load Packages {#sec-modernPortfolioTheoryLoadPackages}
```{r}
library("quantmod")
library("fPortfolio")
library("tidyverse")
```
## Overview {#sec-modernPortfolioTheoryOverview}
## Fantasy Football is Like Stock Picking {#sec-likeStockPicking}
Selecting players for your fantasy team is like picking stocks.
In both fantasy football and the stock market, your goal is to pick assets (i.e., players/stocks) that will perform best and that others undervalue.
But what is the best way to do that?
Below, we discuss approaches to picking players/stocks.
### The Wisdom of the Crowd (or Market) {#sec-wisdomOfTheCrowd}
In picking players, there are various approaches one could take.
You could do lots of research to pick players/stocks with strong fundamentals that you think will do particularly well next year.
By picking these players/stocks, you are predicting that they will *outperform* their expectations.
However, all of your information is likely already reflected in the current valuation of the player/stock, so your prediction is basically a gamble.
This is evidenced by the fact that people do not reliably beat the crowd/market.
Even so-called experts do not beat the market reliably.
There is little consistency in the performance of mutual fund managers over time.
In the book, "The Drunkard's Walk: How Randomness Rules Our Lives", @Mlodinow2008 reported essentially no correlation between performance of the top mutual funds in a five-year period with their performance over the subsequent five years.
That is, the best funds in a one period were not necessarily the best funds in another period.
This suggests that mutual fund managers differ in great part because of luck or chance rather than reliable skill.
In any given year, some mutual funds will do better than other mutual funds.
But this overperformance in a given year likely reflects more randomness than skill.
That is likely why [a cat beat professional investors in a stock market challenge](http://www.npr.org/blogs/money/2013/01/14/169326326/housecat-beats-investors-in-stock-market-challenge) (archived at <https://perma.cc/R3XU-K6J8>).
That is, "few stock pickers, if any, have the skill needed to beat the market consistently, year after year" [@Kahneman2011, p. 214].
Although our sample size is much smaller with fantasy football projections, there also appears to be little consistency in fantasy football sites' rank in accuracy over time [INSERT], suggesting that the projection sources are not reliably better than each other (or the crowd) over time.
The market reflects all of the knowledge of the crowd.
One common misconception is that if you go with the market, you will receive "average" returns (by "average", I mean that you will be in the 50th percentile among investors).
This is not true—it has been shown that most mutual funds (about 80%) underperform the average returns of the stock market.
So, by going with the market average, you will likely perform better than the "average" fund/investor.
Consistent with this, crowd-averaged fantasy football projections tend to be more accurate than any individual's projection: INSERT
This evidence is consistent with the notion of the [wisdom of the crowd](#sec-wisdomOfCrowd), described in @sec-wisdomOfCrowd.
Moreover, even if the stock market is relatively accurate ("efficient") in terms of valuing stocks based on all (publicly) available information (i.e., the efficient market hypothesis), your fantasy football league is likely not.
Thus, it may be effective to use crowd-based projections to identify players who are undervalued by your league.
### Diversification {#sec-diversification}
Modern portfolio theory (mean-variance theory) is a framework for determining the optimal composition of an investment portfolio to maximize expected returns for a given level of risk.
Here, *risk* refers to the [variability](#sec-descriptiveStatisticsSpread) (e.g., standard deviation or variance) of returns across time.
Given two portfolios with the same expected returns over time, people will prefer the "safer" portfolio—that is, the portfolio with less [variability](#sec-descriptiveStatisticsSpread)/volatility across time.
One of the powerful notions of modern portfolio theory is that, through diversification, one can achieve lower risk with the same expected returns.
In investing, *diversification* involves owning multiple asset classes (e.g., domestic and international stocks and bonds), with the goal of having asset classes that are either uncorrelated or negatively correlated.
That is, owning different types of assets is safer than owning only one type.
If you have too much money in one asset and that asset tanks, you will lose your money.
In other words, you do not want to put all of your eggs in one basket.
By owning different asset classes, you can limit your downside risk without sacrificing much in terms of expected return.
This lesson can also apply to fantasy football.
When assembling a team, you are essentially putting together a portfolio of assets (i.e., team of players).
As with stocks, each player has an expected return (i.e., projection) and a degree of risk.
In fantasy football, a player's risk might be quantified in terms of the [variability](#sec-descriptiveStatisticsSpread) of projected scores for a player across projection sources (e.g., Projection Source A, Source B, Souce C, etc.), or as historical game-to-game [variability](#sec-descriptiveStatisticsSpread).
Variability of projected scores for a player across projection sources could reflect the *uncertainty* of projections for a player.
Variability of historical (actual) fantasy points across games could reflect many factors, including risks due to injuries, situational changes (e.g., being traded to a new team or changes in team composition such as due to the acquisition of new players on the team), game scripts, and the tendency for the player to be "boom-or-bust" (e.g., if they are highly dependent on scoring touchdowns or long receptions for fantasy points).
All things equal, we want to minimize our risk for a given level of expected returns.
That way, we have the best chance of winning any given week.
For the same level of expected returns, higher risk teams might have a few amazing games, but their teams might fall flat in other weeks.
That is, for a given (high) rate of return, [you are best off in the long run (i.e., over the course of a season) with a lower risk team](https://eng.wealthfront.com/2012/01/17/moneyball-using-modern-portfolio-theory-to-win-your-fantasy-sports-league/) compared to a higher risk team (archived at <https://perma.cc/NE35-G6LR>).
In terms of diversification, it can be helpful to diversify in multiple ways.
First, it can be helpful not to rely on just one or two "stud" players.
If they are on bye or have a down week, your team is more likely to suffer.
Also, there are risks in picking multiple offensive players from the same team.
If you draft your starting Quarterback and Wide Receiver from the same team (e.g., the Cowboys), you are exposing your fantasy team to considerable risk.
For instance, if you have the Quarterback and Wide Receiver from the same team, and the team has a poor offensive outing, that will have a greater impact.
You can limit your downside risk by diversifying—drafting players from different teams.
That way if the Cowboys' offense does poorly in a given week, your fantasy team will not be as affected.
Having multiple players on a juggernaut offense can be a boon, but it can be challenging to predict which offense will lead the league.
However, sometimes having two players on the same team might be beneficial because some positions may be uncorrelated or even negatively correlated, which can also reduce risk.
For instance, the performance of the Tight End and Running Back on the same team tends to be slightly negatively correlated, so it might not be a bad idea to start the Tight End and Running Back from the same team.
For a correlation matrix of all positions on the team, see: <https://assets-global.website-files.com/5f1af76ed86d6771ad48324b/607a4434a565aa7763bd1312_AndyAsh-Sharpstack-RPpaper.pdf> (archived at <https://perma.cc/JQ6G-KSRT>).
Another important idea from modern portfolio theory is that, if you want to achieve higher returns, you may be able to by accepting additional—and the right combination of—risk.
In general, risk is positively correlated with return.
That is, receiving higher returns generally requires taking on additional risk—at least as long as we stay along the [efficient frontier](#sec-efficientFrontier), described next.
## The Efficient Frontier of a Stock Portfolio {#sec-efficientFrontier}
The ultimate goal in fantasy football is to draft players for your starting lineup that provide the most projected points (i.e., the highest returns) and the smallest downside risk.
That is, your goal is to achieve the optimal portfolio at a given level of risk, depending on how much risk you are willing to tolerate.
One of the key tools in modern portfolio theory for identifying the optimal portfolio (for a given risk level) is the efficient frontier.
The efficient frontier is a visual depiction of the maximum expected returns for a given level of risk (where risk is the [variability](#sec-descriptiveStatisticsSpread) in returns over time).
The efficient frontier is helpful for identifying the optimal portfolio—the optimal combination and weighting of assets—for a given risk level.
Anything below the efficient frontier is considered inefficient (i.e., lower-than-maximum returns for a given level of risk).
In the example below, we use historical returns (since YEAR) as the expected future returns.
However, using historical returns as the expected future returns is risky because, as described in the common disclaimer, "Past performance does not guarantee future results."
If you select a relatively short period of historical returns, you may be selecting a period when the stock performed particularly well.
When evaluating historical returns it is preferable to evaluate long time horizons and to evaluate how the stock performed during period of both boom (i.e., "bull markets") and bust (i.e., "bear markets", such as in a recession).
### Download Historical Stock Prices {#sec-downloadStockPrices}
```{r}
symbols <- c(
"AAPL", # Apple
"MSFT", # Microsoft
"GOOGL", # Google
"AMZN", # Amazon
"META", # Meta/Facebook
"V", # Visa
"DIS", # Disney
"NKE", # Nike
"TSLA") # Tesla
quantmod::getSymbols(symbols)
```
### Calculate Stock Returns {#sec-calculateStockReturns}
```{r}
prices <- do.call(
merge,
lapply(
symbols,
function(sym) quantmod::Cl(get(sym))))
returns <- na.omit(
TTR::ROC(
prices,
type = "discrete"))
returns_ts <- timeSeries::as.timeSeries(returns)
```
### Create Portfolio {#sec-createPortfolio}
```{r}
portfolioSpec <- fPortfolio::portfolioSpec()
fPortfolio::setNFrontierPoints(portfolioSpec) <- 1000
```
### Determine the Efficient Frontier {#sec-determineEfficientFrontier}
```{r}
efficientFrontier <- fPortfolio::portfolioFrontier(
returns_ts,
spec = portfolioSpec)
efficientFrontier
```
```{r}
#| label: fig-efficientFrontier
#| fig-cap: "Efficient Frontier for a Stock Portfolio."
#| fig-alt: "Efficient Frontier for a Stock Portfolio."
# Extract the coordinates of individual assets
asset_means <- colMeans(returns)
asset_sd <- apply(returns, 2, sd)
# Add some padding to plot limits (so ticker symbols don't get cut off)
xlim <- range(asset_sd) * c(0.9, 1.1)
ylim <- range(asset_means) * c(0.9, 1.1)
xlim[1] <- 0
ylim[1] <- 0
# Set scientific notation penalty
options(scipen = 999)
plot(
efficientFrontier,
which = c(
1, # efficient frontier
3, # tangency portfolio
4), # risk/return of individual assets
control = list(
xlim = xlim,
ylim = ylim
))
# Add text labels for individual assets
points(
asset_sd,
asset_means,
col = "red",
pch = 19)
text(
asset_sd,
asset_means,
labels = symbols,
pos = 4,
cex = 0.8,
col = "black")
```
### Identify the Optimal Weights {#sec-portfolioOptimalWeights}
#### Tangency Portfolio {#sec-tangencyPortfolio}
The tangency portfolio is the portfolio with the highest Sharpe ratio (i.e., the highest ratio of return to risk).
In other words, it is the portfolio with the greatest risk-adjusted returns.
```{r}
# Find the tangency portfolio (portfolio with the highest Sharpe ratio)
tangencyPortfolio <- fPortfolio::tangencyPortfolio(
data = returns_ts,
spec = portfolioSpec)
# Extract optimal weights
tangencyPortfolio_optimalWeights <- fPortfolio::getWeights(tangencyPortfolio)
tangencyPortfolio_optimalWeights
# Output the results
summary(tangencyPortfolio)
```
#### Portfolio with Max Return at a Given Risk Level {#sec-maxReturnPortfolio}
```{r}
#| eval: false
# Define target risk levels
targetRisks <- seq(0, 0.3, by = 0.01)
# Initialize storage for optimal portfolios
optimalPortfolios <- list()
optimalWeights_list <- list()
# Find optimal weightings for each target risk level
for (risk in targetRisks) {
# Create a portfolio optimization specification with the target risk
portfolioSpec <- fPortfolio::portfolioSpec()
fPortfolio::setTargetRisk(portfolioSpec) <- risk
# Solve for the maximum return at this target risk
optimal_portfolio <- fPortfolio::maxreturnPortfolio(
returns_ts,
spec = portfolioSpec)
# Store the optimal portfolio
optimalPortfolios[[as.character(risk)]] <- optimal_portfolio
# Store the optimal portfolio weights with risk level
optimal_weights <- fPortfolio::getWeights(optimal_portfolio)
optimalWeights_list[[as.character(risk)]] <- c(RiskLevel = risk, optimal_weights)
}
optimalWeightsByRisk <- dplyr::bind_rows(optimalWeights_list)
optimalWeightsByRisk
```
## The Efficient Frontier of a Fantasy Team {#sec-efficientFrontierFantasy}
In fantasy football, the efficient frontier can be helpful for identifying the optimal players to draft for a given risk level (and potentially within the salary cap).
It can also be helpful for identifying potential trades.
In this way, modern portfolio theory and the efficient frontier can be helpful for arbitrage—buying and selling the same asset (in this case, player) to take advantage of different prices for the same asset.
That is, you could buy low and, for players who outperform expectations, sell high—in the form of a trade.
### Based on Variability Across Projection Sources {#sec-efficientFrontierFantasyProjectionsUncertainty}
### Based on Historical Game-to-Game Variability {#sec-efficientFrontierFantasyProjectionsGameToGameVariability}
<https://eng.wealthfront.com/2012/01/17/moneyball-using-modern-portfolio-theory-to-win-your-fantasy-sports-league/> (archived at <https://perma.cc/JQ6G-KSRT>)
## Conclusion {#sec-modernPortfolioTheoryConclusion}
In summary, fantasy football is similar to stock picking.
You are most likely to pick the best players if you go with the [wisdom of the crowd](#sec-wisdomOfTheCrowd) (e.g., average projections across projection sources) and diversify.
Most projections are public information, so you might wonder whether using crowd projections gains you anything because everybody else has access to public information.
However, this is also the case with stocks, and people still consistently perform best over time when they go with the market.
Nevertheless, crowd projections are not highly accurate.
And fantasy football is a game, so feel free to have fun and deviate from the crowd!
However, you may be just as (if not more) likely to be wrong by deviating from the crowd.
::: {.content-visible when-format="html"}
## Session Info {#sec-modernPortfolioTheorySessionInfo}
```{r}
sessionInfo()
```
:::