The stock market recovery from the Great Depression (of 1929) was very slow compared to the recovery from the Financial Crisis (of 2008). The document compares the daily performance of $10,000
invested one month prior to the beginning of each recession.
A portfolio of $10,000
at the beginning of the Great Depression never recovers even after 12.5 years. In stark contrast, a portfolio of $10,000
recovers approximately 5.3 years after the Financial Crisis.
I thank the author of this R tutorial. I also want to thank the author of this other tutorial. And this tutorial. One of the best things about using R is the ease of copying and pasting other people’s code.
Advanced users may adjust the ticker symbol and initial investment dates in the chunk below and re-run the analysis.
### document parameters
ticker <- "^GSPC"
GDstartdate <- '1929-07-01'
FCstartdate <- '2007-11-01'
Extract historical data for the S&P 500 from Yahoo Finance.
library(tidyverse)
library(tidyquant)
GSPC <- tq_get(ticker, from = '1927-01-01',
to = "2020-05-17",
get = "stock.prices")
head(GSPC)
## # A tibble: 6 x 8
## symbol date open high low close volume adjusted
## <chr> <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 ^GSPC 1927-12-30 17.7 17.7 17.7 17.7 0 17.7
## 2 ^GSPC 1928-01-03 17.8 17.8 17.8 17.8 0 17.8
## 3 ^GSPC 1928-01-04 17.7 17.7 17.7 17.7 0 17.7
## 4 ^GSPC 1928-01-05 17.5 17.5 17.5 17.5 0 17.5
## 5 ^GSPC 1928-01-06 17.7 17.7 17.7 17.7 0 17.7
## 6 ^GSPC 1928-01-09 17.5 17.5 17.5 17.5 0 17.5
According to the NBER the Great Depression began on August 1929
while the 2008 Financial Crisis began on December 2007
. In order to simulate the performance of a portfolio that began immediately prior to the beginning of the recession, the document assumes $10,000
was invested in the S&P 500 on the following dates:
GSPC %>%
filter(date >= GDstartdate) %>%
head()
## # A tibble: 6 x 8
## symbol date open high low close volume adjusted
## <chr> <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 ^GSPC 1929-07-01 27.8 27.8 27.8 27.8 0 27.8
## 2 ^GSPC 1929-07-02 28.1 28.1 28.1 28.1 0 28.1
## 3 ^GSPC 1929-07-03 28.2 28.2 28.2 28.2 0 28.2
## 4 ^GSPC 1929-07-05 28.3 28.3 28.3 28.3 0 28.3
## 5 ^GSPC 1929-07-08 28.4 28.4 28.4 28.4 0 28.4
## 6 ^GSPC 1929-07-09 28.3 28.3 28.3 28.3 0 28.3
GSPC %>%
filter (date >= FCstartdate) %>%
head()
## # A tibble: 6 x 8
## symbol date open high low close volume adjusted
## <chr> <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 ^GSPC 2007-11-01 1546. 1546. 1507. 1508. 4241470000 1508.
## 2 ^GSPC 2007-11-02 1511. 1513. 1493. 1510. 4285990000 1510.
## 3 ^GSPC 2007-11-05 1506. 1511. 1490. 1502. 3819330000 1502.
## 4 ^GSPC 2007-11-06 1505. 1521. 1499. 1520. 3879160000 1520.
## 5 ^GSPC 2007-11-07 1515. 1515. 1475. 1476. 4353160000 1476.
## 6 ^GSPC 2007-11-08 1475. 1482. 1450. 1475. 5439720000 1475.
Split the data sets between Great Depression and Financial Crisis. Then add new variable for portfolio age (i.e., the number of days since the initial $10,000
investment). Use calendar days rather than trading days.
GD <- GSPC %>%
filter(date >= GDstartdate) %>%
mutate(PortfolioAge = interval(first(date), date) / days(1))
FC <- GSPC %>%
filter (date >= FCstartdate) %>%
mutate(PortfolioAge = interval(first(date), date) / days(1))
head(GD)
## # A tibble: 6 x 9
## symbol date open high low close volume adjusted PortfolioAge
## <chr> <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 ^GSPC 1929-07-01 27.8 27.8 27.8 27.8 0 27.8 0
## 2 ^GSPC 1929-07-02 28.1 28.1 28.1 28.1 0 28.1 1
## 3 ^GSPC 1929-07-03 28.2 28.2 28.2 28.2 0 28.2 2
## 4 ^GSPC 1929-07-05 28.3 28.3 28.3 28.3 0 28.3 4
## 5 ^GSPC 1929-07-08 28.4 28.4 28.4 28.4 0 28.4 7
## 6 ^GSPC 1929-07-09 28.3 28.3 28.3 28.3 0 28.3 8
head(FC)
## # A tibble: 6 x 9
## symbol date open high low close volume adjusted PortfolioAge
## <chr> <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 ^GSPC 2007-11-01 1546. 1546. 1507. 1508. 4241470000 1508. 0
## 2 ^GSPC 2007-11-02 1511. 1513. 1493. 1510. 4285990000 1510. 1
## 3 ^GSPC 2007-11-05 1506. 1511. 1490. 1502. 3819330000 1502. 4
## 4 ^GSPC 2007-11-06 1505. 1521. 1499. 1520. 3879160000 1520. 5
## 5 ^GSPC 2007-11-07 1515. 1515. 1475. 1476. 4353160000 1476. 6
## 6 ^GSPC 2007-11-08 1475. 1482. 1450. 1475. 5439720000 1475. 7
GD2 <- GD %>%
mutate(CumReturn1929 = adjusted / first(adjusted)) %>%
select(PortfolioAge, date, adjusted, CumReturn1929)
FC2 <- FC %>%
mutate(CumReturn2008 = adjusted / first(adjusted)) %>%
select(PortfolioAge, date, adjusted, CumReturn2008)
head(GD2)
## # A tibble: 6 x 4
## PortfolioAge date adjusted CumReturn1929
## <dbl> <date> <dbl> <dbl>
## 1 0 1929-07-01 27.8 1
## 2 1 1929-07-02 28.1 1.01
## 3 2 1929-07-03 28.2 1.01
## 4 4 1929-07-05 28.3 1.02
## 5 7 1929-07-08 28.4 1.02
## 6 8 1929-07-09 28.3 1.02
head(FC2)
## # A tibble: 6 x 4
## PortfolioAge date adjusted CumReturn2008
## <dbl> <date> <dbl> <dbl>
## 1 0 2007-11-01 1508. 1
## 2 1 2007-11-02 1510. 1.00
## 3 4 2007-11-05 1502. 0.996
## 4 5 2007-11-06 1520. 1.01
## 5 6 2007-11-07 1476. 0.978
## 6 7 2007-11-08 1475. 0.978
GD_FC <- GD2 %>%
inner_join(FC2, by="PortfolioAge") %>%
select(PortfolioAge, CumReturn1929, CumReturn2008)
head(GD_FC)
## # A tibble: 6 x 3
## PortfolioAge CumReturn1929 CumReturn2008
## <dbl> <dbl> <dbl>
## 1 0 1 1
## 2 1 1.01 1.00
## 3 4 1.02 0.996
## 4 7 1.02 0.978
## 5 8 1.02 0.964
## 6 11 1.03 0.954
We’re almost done. We need to multiply the cumulative returns by $10,000
to get the value of the portfolio in dollar terms.
GD_FC2 <- GD_FC %>%
mutate(GreatDepression1929 = CumReturn1929*10000,
FinancialCrisis2008 = CumReturn2008*10000)
head(GD_FC2)
## # A tibble: 6 x 5
## PortfolioAge CumReturn1929 CumReturn2008 GreatDepression19… FinancialCrisis20…
## <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 0 1 1 10000 10000
## 2 1 1.01 1.00 10104. 10008.
## 3 4 1.02 0.996 10198. 9958.
## 4 7 1.02 0.978 10216. 9777.
## 5 8 1.02 0.964 10184. 9637.
## 6 11 1.03 0.954 10288. 9541.
This part is a little tricky. The columns GreatDepression1929
and FinancialCrisis2008
should be converted into rows with a new column (i.e., Type
) to distinguish between the 1929 and 2008 portfolios. I perform this step to make plotting easier.
GD_FC2_gather <- GD_FC2 %>%
select(PortfolioAge, GreatDepression1929, FinancialCrisis2008) %>%
gather("Type", "PortfolioValue", -PortfolioAge)
head(GD_FC2_gather)
## # A tibble: 6 x 3
## PortfolioAge Type PortfolioValue
## <dbl> <chr> <dbl>
## 1 0 GreatDepression1929 10000
## 2 1 GreatDepression1929 10104.
## 3 4 GreatDepression1929 10198.
## 4 7 GreatDepression1929 10216.
## 5 8 GreatDepression1929 10184.
## 6 11 GreatDepression1929 10288.
tail(GD_FC2_gather)
## # A tibble: 6 x 3
## PortfolioAge Type PortfolioValue
## <dbl> <chr> <dbl>
## 1 4568 FinancialCrisis2008 18846.
## 2 4571 FinancialCrisis2008 19100.
## 3 4572 FinancialCrisis2008 19423.
## 4 4575 FinancialCrisis2008 19425.
## 5 4578 FinancialCrisis2008 18910.
## 6 4579 FinancialCrisis2008 18985.
ggplot(GD_FC2_gather, aes(x=PortfolioAge, y=PortfolioValue)) +
geom_line(aes(color=Type)) +
theme_classic() +
geom_hline(yintercept=10000, linetype="dashed", color = "black") +
scale_y_continuous(breaks=seq(0,25000,2500)) +
scale_x_continuous(name="Portfolio Age (in days)",breaks=seq(0,365*13,365)) +
scale_color_manual(values=c('blue','orange')) +
ggtitle("Investing $10,000 in the S&P 500")
Had you invested $10,000
on 1929-07-01
, your portfolio would have been worth about $3,000
after 12.5 years. In stark contrast, if you invested $10,000
on 2007-11-01
, your portfolio would have been worth about $19,000
after 12.5 years.