---
title: "Major U.S. Banks Stocks Analysis"
author: "Alexander Kurochkin"
date: "03/28/2023"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
source: embed
html_document:
df_print: paged
pdf_document: default
---
```{r setup, include=FALSE}
library(flexdashboard)
library(quantmod)
library(plyr)
library(DT)
library(dygraphs)
library(ggplot2)
library(broom)
```
-----------------------------------------------------------------------
# Summary
## Column
### Stock Key Performance Metrics
```{r}
skp_metrics = yahooQF(c("Price/Sales",
"P/E Ratio",
"Price/EPS Estimate Next Year",
"PEG Ratio",
"Dividend Yield",
"Market Capitalization"))
tickers = c("JPM", "BAC", "C", "WFC")
metrics = getQuote(paste(tickers, sep="", collapse=";"), what=skp_metrics)
metrics = data.frame(Symbol=tickers, metrics[,2:length(metrics)])
colnames(metrics) = c("Symbol", "P-E Ratio", "Price EPS Estimate Next Year", "Div Yield", "Market Cap")
write.csv(metrics, "FinMetrics.csv", row.names=FALSE)
DT::datatable(metrics)
```
-----------------------------------------------------------------------
### Stock Closing Prices
```{r}
x = getSymbols(tickers, from="2018-03-29", to="2023-03-28")
ClosingPrices = do.call(merge, lapply(tickers, function(x) Cl(get(x))))
dateperiod<-c("2018-03-29", "2023-03-28")
dygraph(ClosingPrices, main="Closing Price in USD", group="Stock") %>%
dyAxis("y", label="Closing Price(USD)") %>%
dyOptions(axisLineWidth = 1.5, digitsAfterDecimal=2, colors = RColorBrewer::brewer.pal(5, "Set1")) %>%
dyHighlight(highlightSeriesBackgroundAlpha = 1.0, highlightSeriesOpts = list(strokeWidth = 3)) %>%
dyRangeSelector(height = 50)
```
## Overview {.sidebar}
### Overview
Nowadays, the banking industry is making the one of the worlds' news headliners. Last month we saw several banks' valuations crash hard. People around the world are concerned that this might be the 2008 crisis repeating itself again, a sharp stockmarket drop like the one during first the Covid lockdowns era, or worse. Therefore, it is important, more than ever, to stay on top of events happening in this sector.
Let's help others make decisions based not only on the news but actual numbers reported. This dashboard provides easy-to-use infographics and a comparison of the 4 major U.S. banks key stock performance metrics. Please, enjoy.
# Stock Closing Prices
## Candlestick {.tabset data-width=650}
### JPMorgan Chase & Co.
```{r}
j = getSymbols("JPM", src = "yahoo", from='2018-03-29')
JPM_x = JPM
dygraph(JPM_x[, -5], main = "JPM Stock Closing Prices") %>%
dyCandlestick() %>%
dyAxis("y", label="Daily Stock Closing Price (USD)") %>%
dyOptions(colors= RColorBrewer::brewer.pal(5, "Set1")) %>%
dyHighlight(highlightCircleSize = 4, highlightSeriesOpts = list(strokeWidth = 5), highlightSeriesBackgroundAlpha = 1) %>%
dyRangeSelector(height = 60)
```
### Bank of America Corporation
```{r}
b = getSymbols("BAC", src = "yahoo", from='2018-03-29')
BAC_x = BAC
dygraph(BAC_x[, -5], main = "BAC Stock Closing Prices") %>%
dyCandlestick() %>%
dyAxis("y", label="Daily Stock Closing Price (USD)") %>%
dyOptions(colors= RColorBrewer::brewer.pal(5, "Set1")) %>%
dyHighlight(highlightCircleSize = 4, highlightSeriesOpts = list(strokeWidth = 5), highlightSeriesBackgroundAlpha = 1) %>%
dyRangeSelector(height = 60)
```
### Citigroup Inc.
```{r}
c = getSymbols("C", src = "yahoo", from='2018-03-29')
C_x = C
dygraph(C_x[, -5], main = "C Stock Closing Prices") %>%
dyCandlestick() %>%
dyAxis("y", label="Daily Stock Closing Price (USD)") %>%
dyOptions(colors= RColorBrewer::brewer.pal(5, "Set1")) %>%
dyHighlight(highlightCircleSize = 4, highlightSeriesOpts = list(strokeWidth = 5), highlightSeriesBackgroundAlpha = 1) %>%
dyRangeSelector(height = 60)
```
### Wells Fargo & Company
```{r}
w = getSymbols("WFC", src = "yahoo", from='2018-03-29')
WFC_x = WFC
dygraph(WFC_x[, -5], main = "WFC Stock Closing Prices") %>%
dyCandlestick() %>%
dyAxis("y", label="Daily Stock Closing Price (USD)") %>%
dyOptions(colors= RColorBrewer::brewer.pal(5, "Set1")) %>%
dyHighlight(highlightCircleSize = 4, highlightSeriesOpts = list(strokeWidth = 5), highlightSeriesBackgroundAlpha = 1) %>%
dyRangeSelector(height = 60)
```
## Analysis {.sidebar}
### Analysis Help
These interactive candlestick graphs serve as a great tool to analyze daily stock closing prices for the 4 major U.S. bank stocks for the last 5 years until 03/28/2023.
-----------------------------------------------------------------------
# Stocks Overall Daily Trend
## Chart {.tabset data-width=650}
```{r, fig.align="center", fig.width = 14,, fig.height = 8}
so = getSymbols(tickers, src = "yahoo", from = "2008-03-29", to = "2023-03-28")
stocks = as.xts(data.frame(J = JPM[, "JPM.Adjusted"],
B = BAC[, "BAC.Adjusted"], C = C[, "C.Adjusted"],
W = WFC[,"WFC.Adjusted"]))
names(stocks) = c("JPM", "BAC", "C", "WFC")
index(stocks) = as.Date(index(stocks))
stocks_series = tidy(stocks) %>%
ggplot(aes(x=index,y=value, color=series)) +
labs(title = "Daily Stock Adjusted Prices Comparison from 03/29/2008 - 03/28/2023",
subtitle = "4 Major U.S. Banks",
caption = " Source: Yahoo Finance",
color = "Ticker",
x = "Date",
y = "End of day Adjusted Price (USD)") +
scale_color_manual(values = c("black", "red", "blue","purple"))+
scale_x_date(date_breaks = "1 year", date_labels = "%b %Y")+
geom_line()
stocks_series
```
## Conclusion {.sidebar}
### Conclusion
Currently, the situation with banks looks not as bad as in 2008 or during the 2020 spring lockdowns. However, that might change quickly.
Otherwise, all four banks' stock price movements seem to be similar.
Looking at the summary, JPMorgan Chase seems to be more promising as its EPS Estimate for the next year is the highest within the quad.