#Overview
Due to the inherent growth in the electronic production and storage ofinformation, there is often a feeling of “information overload” or inundationwhen facing the process of quantitative decision making. As an analyst your jobwill often be to conduct analyses or create tools to support quantitativedecision making.A principle tool used in industry, goverment, non-profits, and academic fieldsto compensate for the information overload is the information dashboard.Functionally, a dashboard is meant to provide a user with a central resource topresent in a clear and concise manner all the information neccessary to supportday-to-day decision making and support operations.
#Objective
The objective of this laboratory is to plan, design, and create an informationdashboard to support quantitative decision making. To accomplish this task youwill have to complete a number of steps:1. Delineate the necessary decision (I will do that) 2. Identify what information will be relevant to decision making. 3. Find and collect the data necessary to create your visualization plan.4. Organize and summarize the collected data.5. Design and create the best visualizations to present that information.6. Finally organize the layout of those visualizations in a way that conforms tothe theory of dashboarding.7. Write a summary about what decisions you made based on the visualizationsthat you developed.
#The Decision & Rules
You make investments for an organization, your objective is to purchasesecurities/commodities for the key objective of maximizing profits. You want tomake an investment in securities/commodities to make some short term gains. Youare considering investing in one of any four companies, for example: Twitter(TWTR), Microsoft (MSFT), or Apple (AAPL) (don’t use these). Choose 4 companiesor commodities and determine which one of the four will produce the most shortterm gains. Use your imagination.
#Getting data
There are lots of places we can get financial data to support these decision.The simplest would be to go to for instance to the Yahoo Finance(https://finance.yahoo.com/) for data on the Hershey Company (HSY) the URL wouldbe: (https://finance.yahoo.com/quote/HSY/history?p=HSY) and collect historical price data, and other financial and company information.
#Key Indicator Analysis
[1] "WMT"
[1] "META"
[1] "DXCM"
[1] "AMZN"
---
title: "Lab 1 Dashboard"
output:
flexdashboard::flex_dashboard:
orientation: rows
social: menu
source: embed
vertical_layout: fill
html_document:
df_print: paged
---
Overview
=====================================
#Overview
Due to the inherent growth in the electronic production and storage ofinformation, there is often a feeling of "information overload" or inundationwhen facing the process of quantitative decision making. As an analyst your jobwill often be to conduct analyses or create tools to support quantitativedecision making.A principle tool used in industry, goverment, non-profits, and academic fieldsto compensate for the information overload is the information dashboard.Functionally, a dashboard is meant to provide a user with a central resource topresent in a clear and concise manner all the information neccessary to supportday-to-day decision making and support operations.
#Objective
The objective of this laboratory is to plan, design, and create an informationdashboard to support quantitative decision making. To accomplish this task youwill have to complete a number of steps:1. Delineate the necessary decision (I will do that)
2. Identify what information will be relevant to decision making.
3. Find and collect the data necessary to create your visualization plan.4. Organize and summarize the collected data.5. Design and create the best visualizations to present that information.6. Finally organize the layout of those visualizations in a way that conforms tothe theory of dashboarding.7. Write a summary about what decisions you made based on the visualizationsthat you developed.
#The Decision & Rules
You make investments for an organization, your objective is to purchasesecurities/commodities for the key objective of maximizing profits. You want tomake an investment in securities/commodities to make some short term gains. Youare considering investing in one of any four companies, for example: Twitter(TWTR), Microsoft (MSFT), or Apple (AAPL) (don't use these). Choose 4 companiesor commodities and determine which one of the four will produce the most shortterm gains. Use your imagination.
Methods Help
=====================================
#*Getting data*
There are lots of places we can get financial data to support these decision.The simplest would be to go to for instance to the Yahoo Finance(https://finance.yahoo.com/) for data on the Hershey Company (HSY) the URL wouldbe: (https://finance.yahoo.com/quote/HSY/history?p=HSY) and collect historical price data, and other financial and company information.
#Key Indicator Analysis
1. Earnings per share (EPS) is calculated as a company's profit divided by the outstanding shares of its common stock.
2. The price-to-earnings ratio (P/E ratio) is the ratio for valuing a company that measures its current share price relative to its per-share earnings.
3. Market capitalization refers to the total dollar market value of a company's outstanding shares.
4. The closing price is the final price at which a security is traded on a given trading day.
```{r, echo = TRUE, include = FALSE, message = FALSE}
library(xts) # create Candlestick Charts using the dyCandlestick function
library(pdfetch)
library(DT)
library(lubridate)
library(dygraphs)
library(quantmod)
library(dplyr)
library(knitr)
library(ggplot2)
library(tidyr)
library(plyr)
library(PerformanceAnalytics)
library(stocks)
what_metrics <- yahooQF(c("Price/Sales",
"Earnings/Share",
"P/E Ratio",
"Price/EPS Estimate Next Year",
"PEG Ratio",
"Dividend Yield",
"Market Capitalization"))
what_metrics
tickers <- c( "WMT", "META", "DXCM", "AMZN")
# Not all the metrics are returned by Yahoo.
metrics <- getQuote(paste(tickers, sep="", collapse=";"),what=what_metrics)
class(metrics)
#Add tickers as the first column and remove the first column which had datestamps
metrics <- data.frame(Symbol=tickers,metrics[,2:length(metrics)])
metrics
#Change colnames
#colnames(metrics) <- c("Symbol", "P-E Ratio", "Price EPS Estimate Next Year","Div Yield", "Market Cap")
#Persist this to the csv file
#write.csv(metrics, "FinancialMetrics.csv", row.names=FALSE)
DT::datatable(metrics)
```
Stock Valuation Analysis
=====================================
```{r}
#`r kableExtra::text_spec(paste0("**Earning Share**"), color = "#5c5c5c")` - Earnings per share (EPS) is calculated as a company's profit divided by the outstanding shares of its common stock.
#`r kableExtra::text_spec(paste0("**P-E Ratio**"), color = "#5c5c5c")` - The price-to-earnings ratio (P/E ratio) is the ratio for valuing a company that measures its current share price relative to its per-share earnings.
#`r kableExtra::text_spec(paste0("**Market Capitalization**"), color = "#5c5c5c")` - Market capitalization refers to the total dollar market value of a company's outstanding shares.
#`r kableExtra::text_spec(paste0("**Closing Price**"), color = "#5c5c5c")` - The closing price is the final price at which a security is traded on a given trading day.
```
### **Summary**
From the EPS & P/E ratio charts, META has the best valuation here. EPS is the second best and P/E ratio is the lowest, means the stock of this company is the most profitable one among these 4 companies. Same goes for WMT, third best P/E ratio and not bad EPS. META is also the company with the biggest market capitalization.
We can see AMZN gives the best EPS but due to its high stock price, AMZN has the second worst P/E ratio. DXCM is the healthcare start up with lowest EPS and highest P/E.
Based on the charts, WMT is the stock that is worth to invest.
```{r}
metrics<-data.frame(na.fill(metrics,0))
ggplot(metrics,aes(x=Symbol,y=Earnings.Share,fill=Symbol))+
geom_col()+
labs(x="Company name",y="Earnings/Share")
ggplot(metrics,aes(x=Symbol,y=P.E.Ratio,fill=Symbol))+
geom_col()+
labs(x="Company name",y="P/E Ratio")
ggplot(metrics,aes(x=Symbol,y=Market.Capitalization,fill=Symbol))+
geom_col()+
coord_polar("y",start=0)
```
```{r}
getSymbols("WMT",from="2018-01-01",to="2023-01-01")
WMT_log_returns<-WMT%>%Ad()%>%dailyReturn(type='log')
getSymbols("META",from="2018-01-01",to="2023-01-01")
META_log_returns<-WMT%>%Ad()%>%dailyReturn(type='log')
getSymbols("DXCM",from="2018-01-01",to="2023-01-01")
DXCM_log_returns<-WMT%>%Ad()%>%dailyReturn(type='log')
getSymbols("AMZN",from="2018-01-01",to="2023-01-01")
AMZN_log_returns<-WMT%>%Ad()%>%dailyReturn(type='log')
```
Stock Closing Price
=====================================
### **Summary**
The closing price represents the most up-to-date valuation of a security untiltrading commences again on the next trading day. As we can see from the StrawBroom Charts that Walmart have the most stable and pretty similar stock closing price while Meta have the most fluctuated stock closing price thourghout the years from 2018 to 2022.
```{r}
tickers <- c("WMT", "META", "DXCM", "AMZN")
ClosingPrices <- do.call(merge, lapply(tickers, function(x) Cl(get(x))))
dateWindow<-c("2018-01-01", "2023-01-01")
dygraph(ClosingPrices, main="Stock Closing Price", group="Stock")%>%
dyAxis("y", label="Closing Price ($) ") %>%
dyOptions( colors = RColorBrewer::brewer.pal(4, "Set1")) %>%
dyHighlight(highlightSeriesBackgroundAlpha = 0.5,
highlightSeriesOpts = list(strokeWidth = 3))%>%
dyRangeSelector(height = 35, dateWindow=dateWindow)
```