S&P 500
Data - yahoo
Info
LAST_COMPILE
LAST_COMPILE |
---|
2025-07-20 |
Last
date | Nobs |
---|---|
2024-05-24 | 501 |
symbol
Components
Table
1990-
Linear
Code
<- SP500 %>%
plot_linear filter(symbol %in% c("META", "TSLA", "NVDA", "AMZN", "GOOG", "MSFT", "AAPL")) %>%
filter(date >= as.Date("1990-01-01")) %>%
group_by(symbol) %>%
arrange(date) %>%
mutate(close = 100*close/close[1]) %>%
ggplot() + geom_line(aes(x = date, y = close, color = symbol)) +
theme_minimal() + xlab("") + ylab("") +
theme(legend.title = element_blank(),
legend.position = c(0.5, 0.9)) +
scale_y_continuous(breaks = seq(0, 1000000, 20000)) +
scale_x_date(breaks = as.Date(paste0(seq(1945, 2100, 5), "-01-01")),
labels = date_format("%Y"))
plot_linear
Log
Code
<- plot_linear +
plot_log scale_y_log10(breaks = 10^seq(2, 100, 1))
plot_log
Bind
Code
::ggarrange(plot_linear + ggtitle("Linear scale"), plot_log + ggtitle("Log scale"), common.legend = T) ggpubr
2010-
Linear
Code
<- SP500 %>%
plot_linear filter(symbol %in% c("META", "TSLA", "NVDA", "AMZN", "GOOG", "MSFT", "AAPL")) %>%
filter(date >= as.Date("2010-01-01")) %>%
group_by(symbol) %>%
arrange(date) %>%
mutate(close = 100*close/close[1]) %>%
ggplot() + geom_line(aes(x = date, y = close, color = symbol)) +
theme_minimal() + xlab("") + ylab("") +
theme(legend.title = element_blank(),
legend.position = c(0.2, 0.7),
axis.text.x = element_text(angle = 45, vjust = 0.5, hjust=1)) +
scale_y_continuous(breaks = seq(0, 1000000, 5000),
labels = dollar_format(pre = "", acc = 1)) +
scale_x_date(breaks = as.Date(paste0(seq(1940, 2100, 1), "-01-01")),
labels = date_format("%Y"))
plot_linear
Log
Code
<- plot_linear +
plot_log scale_y_log10(breaks = c(10^seq(1, 100, 1), 10^seq(1, 100, 1)*2, 10^seq(1, 100, 1)*5),
labels = dollar_format(pre = "", acc = 1))
plot_log
Bind
Code
::ggarrange(plot_linear + ggtitle("Linear scale"),
ggpubr+ ggtitle("Log scale"),
plot_log common.legend = T)
2014-
Linear
Code
<- SP500 %>%
plot_linear filter(symbol %in% c("META", "TSLA", "NVDA", "AMZN", "GOOG", "MSFT", "AAPL")) %>%
filter(date >= as.Date("2014-01-01")) %>%
group_by(symbol) %>%
arrange(date) %>%
mutate(close = 100*close/close[1]) %>%
ggplot() + geom_line(aes(x = date, y = close, color = Symbol)) +
theme_minimal() + xlab("") + ylab("") +
theme(legend.title = element_blank(),
legend.position = c(0.2, 0.7),
axis.text.x = element_text(angle = 45, vjust = 0.5, hjust=1)) +
scale_y_continuous(breaks = seq(0, 1000000, 5000),
labels = dollar_format(pre = "", acc = 1)) +
scale_x_date(breaks = as.Date(paste0(seq(1940, 2100, 1), "-01-01")),
labels = date_format("%Y"))
plot_linear
Log
Code
<- plot_linear +
plot_log scale_y_log10(breaks = c(10^seq(1, 100, 1), 10^seq(1, 100, 1)*2, 10^seq(1, 100, 1)*5),
labels = dollar_format(pre = "", acc = 1))
plot_log
Bind
Code
::ggarrange(plot_linear + ggtitle("Linear scale"),
ggpubr+ ggtitle("Log scale"),
plot_log common.legend = T)