Covid-19 began battering the financial markets in February. Which sectors are faring best?
I’ll compare each sector in the S&P 500 with the overall market. And I’ll baseline each at 100% as of February 19th, 2020 so we can see which have recovered lost ground.
symbols <-
c(
"EOD/SPY",
"EOD/XLV",
"EOD/XLK",
"EOD/XLE",
"EOD/XLF",
"EOD/XLC",
"EOD/XLI",
"EOD/XLY",
"EOD/XLP",
"EOD/XLRE",
"EOD/XLU",
"EOD/XLB"
)
from <- "2020-02-19"
eod_sectors <-
tq_get(symbols, get = "quandl", from = from) %>%
group_by(symbol) %>%
mutate(
norm_close = adj_close / first(adj_close),
type = if_else(symbol == "EOD/SPY", "Market", "Sector"),
sector = case_when(
symbol == "EOD/SPY" ~ "S&P 500",
symbol == "EOD/XLB" ~ "Materials",
symbol == "EOD/XLE" ~ "Energy",
symbol == "EOD/XLU" ~ "Utilities",
symbol == "EOD/XLI" ~ "Industrical",
symbol == "EOD/XLRE" ~ "Real Estate",
symbol == "EOD/XLV" ~ "Health",
symbol == "EOD/XLK" ~ "Technology",
symbol == "EOD/XLF" ~ "Financial",
symbol == "EOD/XLC" ~ "Communication",
symbol == "EOD/XLY" ~ "Consumer Discretionary",
symbol == "EOD/XLP" ~ "Consumer Staples",
TRUE ~ "Other"
)
) %>%
ungroup()
With all that ...