Column

Introduction

Row

Overview

Due to the inherent growth in the electronic production and storage of information, there is often a feeling of “information overload” or inundation when facing the process of quantitative decision making. As an analyst your job will often be to conduct analyses or create tools to support quantitative decision making.

A principle tool used in industry, governnment, non-profits, and academic fields to compensate for the information overload is the information dashboard. Functionally, a dashboard is meant to provide a user with a central resource to present in a clear and concise manner all the information neccessary to support day-to-day decision making and support operations.

Objective

The objective of this laboratory is to plan, design, and create an information dashboard to support quantitative decision making. To accomplish this task, you will have to complete a number of steps:

1.Delineate the necessary decision (I will do that below). 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 to the theory of dashboarding. 7.Write a summary about what decisions you made based on the visualizations that you developed.

Row

The Decision & Rules

You make investments for an organization, your objective is to purchase securities/commodities for the key objective of maximizing profits. You want to make an investment in securities/commodities to make some short term gains. You are considering investing in one of any four companies, for example: Twitter (TWTR), Microsoft (MSFT), or Apple (AAPL) (don’t use these). Choose 4 companies, commodities or any financial instrument you like, and determine which one of the four will produce the most short term 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 would be: (https://finance.yahoo.com/quote/HSY/history?p=HSY) and collect historical price data, and other financial and company information.

Alternatively, and more professionally, there are tons of packages that allow you to access data from R. See here quick examples. This is not a complete list but will get you started.

Key Indicator Analysis

Row

Financial Indicators

  • P-E Ratio - It is the ratio of a company’s share price to the company’s earnings per share. This ratio is used for valuing companies and to find out whether they are overvalued or undervalued.
  • EPS - It is the portion of a company’s profit that is allocated to every individual share of the stock and helps in understanding the financial strength of a company
  • Dividend Yield Ratio - is a financial ratio that shows how much a company pays out in dividends each year relative to its stock price.
  • Market Cap - the total value of a company’s shares.

Key Indicator Analysis

Overall Daily Trend

[1] "KO"   "PM"   "VZ"   "GOOG"

Overall Daily Trend

Column

Facet Chart

Monthly Returns

Row

Monthly Returns

Individual Stock Price Trend Analysis

Candlestick

KO

[1] "KO"

PM

[1] "PM"

VZ

[1] "VZ"

GOOG

[1] "GOOG"

Conclusion

Row

Conclusion

For this exercise, we chose to analyze 4 companies in different segments in order to recommend the best investment for a short-term gain. The chosen companies were Coca-Cola (KO), Phillip Morris (PM), Verizon (VZ), Google (GOOG). Among the analyzed companies, our recommendation is that the investment be made in the Coca-Cola company. Although the company does not present large spikes in the share price, the results show a solid company with the highest P/E Ratio among the Coca-Cola options. Cola (28.39), Phillip Morris (16.74), Verizon (7.78), Google (22.82) and EPS: Coca Cola (22.20), Phillip Morris (13.95), Verizon (8.34), Google (17.32).

---
title: "ANLY 512 Lab 1 - Divya Jain, Paula Peres"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
    source_code: embed
    html_document:
    df_print: paged
    pdf_document: default
---

```{r setup, include=FALSE}
library(flexdashboard)
```

```{r}
library(dygraphs)
library(quantmod)
library(plyr)
library(DT)
library(dplyr)
library(highcharter)
library(viridisLite)
library(ggplot2)
library(broom)
library(xts)
library(zoo)
library(pdfetch)
library(DT)
library(lubridate)
library(dygraphs)
library(knitr)
library(plyr)
library(PerformanceAnalytics)
library(stocks)
```

Column {data-width=650}
-----------------------------------------------------------------------
# Table of Contents {.sidebar}

* Introduction
  
* Key Indicator Analysis                          
  
* Overall Daily Trend

* Monthly Returns

* Individual Stock Analysis

* Conclusion

# **Introduction**

Row {data-height=230}
-------------------------------------

### **Overview** 
Due to the inherent growth in the electronic production and storage of information, there is often a feeling of “information overload” or inundation when facing the process of quantitative decision making. As an analyst your job will often be to conduct analyses or create tools to support quantitative decision making.

A principle tool used in industry, governnment, non-profits, and academic fields to compensate for the information overload is the information dashboard. Functionally, a dashboard is meant to provide a user with a central resource to present in a clear and concise manner all the information neccessary to support day-to-day decision making and support operations.

    
### **Objective** 

The objective of this laboratory is to plan, design, and create an information dashboard to support quantitative decision making. To accomplish this task, you will have to complete a number of steps:

1.Delineate the necessary decision (I will do that below).
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 to the theory of dashboarding.
7.Write a summary about what decisions you made based on the visualizations that you developed.

Row
-------------------------------------

### **The Decision & Rules**

You make investments for an organization, your objective is to purchase securities/commodities for the key objective of maximizing profits. You want to make an investment in securities/commodities to make some short term gains. You are considering investing in one of any four companies, for example: Twitter (TWTR), Microsoft (MSFT), or Apple (AAPL) (don’t use these). Choose 4 companies, commodities or any financial instrument you like, and determine which one of the four will produce the most short term 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 would be: (https://finance.yahoo.com/quote/HSY/history?p=HSY) and collect historical price data, and other financial and company information.

Alternatively, and more professionally, there are tons of packages that allow you to access data from R. See here quick examples. This is not a complete list but will get you started.


# **Key Indicator Analysis**

Row
-------------------------

### **Financial Indicators**

+ `r kableExtra::text_spec("**P-E Ratio**", color = "#5c5c5c")` - It is the ratio of a company's share price to the company's earnings per share. This ratio is used for valuing companies and to find out whether they are overvalued or undervalued.
+ `r kableExtra::text_spec("**EPS**", color = "#5c5c5c")` - It is the portion of a company's profit that is allocated to every individual share of the stock and helps in understanding the financial strength of a company
+ `r kableExtra::text_spec("**Dividend Yield Ratio**", color = "#5c5c5c")` - is a financial ratio that shows how much a company pays out in dividends each year relative to its stock price.
+ `r kableExtra::text_spec("**Market Cap**", color = "#5c5c5c")` - the total value of a company's shares.

### **Key Indicator Analysis**

```{r}
what_metrics <- yahooQF(c("Price/Sales", 
                          "P/E Ratio",
                          "Price/EPS Estimate Next Year",
                          "PEG Ratio",
                          "Dividend Yield", 
                          "Market Capitalization"))
tickers <- c("KO", "PM", "VZ","GOOG")
metrics<- getQuote(paste(tickers, sep = ",", collapse = ";"), what = what_metrics)
metrics <- data.frame(Symbol = tickers, metrics[,2:length(metrics)])
colnames(metrics) <- c("Symbol", "P/E Ratio", "EPS", "Div Yield", "Market Cap")
DT::datatable(metrics)
```

# **Overall Daily Trend**



```{r}
start <- as.Date("2022-03-27") 
end <- as.Date("2023-03-27")

getSymbols(tickers, src = "yahoo", from = start, to = end)
stocks = as.xts(data.frame(A = KO[, "KO.Adjusted"], 
B = PM[, "PM.Adjusted"], C = VZ[, "VZ.Adjusted"], 
D = GOOG[,"GOOG.Adjusted"]))
```

### **Overall Daily Trend** {data-width=400}

```{r}
names(stocks) <- c("KO", "PM", "VZ","GOOG")
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/2022 - 03/2023",
       
       subtitle = "Coca Cola, Philip Morris, Verizon, Google",
       caption = " Source: Yahoo Finance",
       color = "Stock",
       x = "Date",
       y = "End of day Adjusted Price ($)") +
  scale_color_manual(values = c("red", "blue","green","orange"))+
  geom_line()

stocks_series
```

Column {data-width=700}
-----------------------------------------------------------------------

### **Facet Chart** {data-width=500}

```{r}
stocks_series2 = tidy(stocks) %>% 
  
  ggplot(aes(x=index,y=value, color=series)) + 
  geom_line() +
  facet_grid(series~.,scales = "free") + 
  labs(title = "Daily Stock Adjusted Prices Comparison from 03/2022 - 03/2023",
       
       subtitle = "Coca Cola, Philip Morris, Verizon, Google",
       caption = " Source: Yahoo Finance",
       color = "Stock",
       x = "Date",
       y = "End of day Adjusted Price ($)") +
  scale_color_manual(values = c("red", "blue","green","orange"))
stocks_series2
```

# **Monthly Returns**

Row
-------------------------

### **Monthly Returns**

```{r,echo=FALSE}
KOmr <- monthlyReturn(KO)
PMmr <- monthlyReturn(PM)
VZmr <- monthlyReturn(VZ)
GOOGmr <- monthlyReturn(GOOG)

mg.return <- merge.xts(KOmr, PMmr, VZmr, GOOGmr)
colnames(mg.return) <- c("Coca Cola", "Philip Morris", "Verizon", "Google")

dygraph(mg.return, main = "Monthly Return") %>%
  dyAxis("y", label = "Return") %>%
  dyOptions(colors = RColorBrewer::brewer.pal(4, "Set1")) %>%
  dyHighlight(highlightSeriesBackgroundAlpha = 0.3,
              highlightSeriesOpts = list(strokeWidth = 3)) %>%
  dyRangeSelector(height = 30)

```

# **Individual Stock Price Trend Analysis**

## Candlestick {.tabset data-width=650}

### KO

```{r}
getSymbols("KO", src = "yahoo", from="2022-03-27")
KO_x <- KO
dygraph(KO_x[, -5], main = "KO") %>%
  dyCandlestick() %>%
  dyAxis("y", label="Daily Stock Closing Price") %>%
  dyOptions(colors= RColorBrewer::brewer.pal(5, "Set1")) %>%
  dyHighlight(highlightCircleSize = 4, highlightSeriesOpts = list(strokeWidth = 5), highlightSeriesBackgroundAlpha = 1) %>%
  dyRangeSelector(height = 60)
```

### PM 

```{r}
getSymbols("PM", src = "yahoo", from="2022-03-27")
PM_x <- PM
dygraph(PM_x[, -5], main = "PM") %>%
  dyCandlestick() %>%
  dyAxis("y", label="Daily Stock Closing Price") %>%
  dyOptions(colors= RColorBrewer::brewer.pal(5, "Set1")) %>%
  dyHighlight(highlightCircleSize = 4, highlightSeriesOpts = list(strokeWidth = 5), highlightSeriesBackgroundAlpha = 1) %>%
  dyRangeSelector(height = 60)
```

### VZ

```{r}
getSymbols("VZ", src = "yahoo", from="2022-03-27")
VZ_x <- VZ
dygraph(VZ_x[, -5], main = "VZ") %>%
  dyCandlestick() %>%
  dyAxis("y", label="Daily Stock Closing Price") %>%
  dyOptions(colors= RColorBrewer::brewer.pal(5, "Set1")) %>%
  dyHighlight(highlightCircleSize = 4, highlightSeriesOpts = list(strokeWidth = 5), highlightSeriesBackgroundAlpha = 1) %>%
  dyRangeSelector(height = 60)
```

### GOOG

```{r}
getSymbols("GOOG", src = "yahoo", from="2022-03-27")
GOOG_x <- GOOG
dygraph(GOOG_x[, -5], main = "GOOG") %>%
  dyCandlestick() %>%
  dyAxis("y", label="Daily Stock Closing Price") %>%
  dyOptions(colors= RColorBrewer::brewer.pal(5, "Set1")) %>%
  dyHighlight(highlightCircleSize = 4, highlightSeriesOpts = list(strokeWidth = 5), highlightSeriesBackgroundAlpha = 1) %>%
  dyRangeSelector(height = 60)
```
# **Conclusion**

Row
-------------------------

#### **Conclusion**

For this exercise, we chose to analyze 4 companies in different segments in order to recommend the best investment for a short-term gain. The chosen companies were Coca-Cola (KO), Phillip Morris (PM), Verizon (VZ), Google (GOOG). Among the analyzed companies, our recommendation is that the investment be made in the Coca-Cola company. Although the company does not present large spikes in the share price, the results show a solid company with the highest P/E Ratio among the Coca-Cola options. Cola (28.39), Phillip Morris (16.74), Verizon (7.78), Google (22.82) and EPS: Coca Cola (22.20), Phillip Morris (13.95), Verizon (8.34), Google (17.32).