Lab 1 Instructions

Column

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, goverment, 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.

Column

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:

Delineate the necessary decision (I will do that below). Identify what information will be relevant to decision making. Find and collect the data necessary to create your visualization plan. Organize and summarize the collected data. Design and create the best visualizations to present that information. Finally organize the layout of those visualizations in a way that conforms to the theory of dashboarding. Write a summary about what decisions you made based on the visualizations that you developed.

Column

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 or commodities and determine which one of the four will produce the most short term gains. Use your imagination.

Column

Dates & Deliverables

You are responsible for submitting a link to your dashboard hosted on the Rpubs site. The dashboard must include the source_code = TRUE parameter.

The due date for this project is XX at the start of class. This assignment is worth 75 points, 3x a normal homework, the additional time should allow you to spend the neccessary effort on this assignment.

You are welcome to work in groups of ≤2 people. However, each person in a group must submit their own link to the assignment on moodle for grading! Each team member can submit the same link to a single rpubs account, however it may be a good idea for each of you to post your own copy to rpubs in case you want to share it to prospective employers ect.

There is one caveat to this project. While you can use any package to pull or obtain data, DO NOT use package like quantmod() to make your graphics. I want to see that you designed and built all the graphics yourself and did not use a precanned stock visualizing function like chartSeries(). There a number of great packages that allow you to use financial graphic types for which you build them see candlestick dygraphs for examples.

Here is another great resource for visualizing financial time series data using ggplot here

Column

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 Indicators Analysis

Column

This part is to create a table view for the key financial indicators for the four companies: Amazon, Meta, Google, and Netflix. Indicators such as Symbol, P-E Ratio, Price EPS Estimate Next Year, Devision Yeils, and Market cap are included. All the companies has large-cap therefore by comparsion, the companies we are evaluating does not necessarily bring in huge returns in a short period of time.

Google has the lowest P-E Ratio. Therefore I will choose to invest in Google.


Stock Closing Prices

[1] "AMZN" "GOOG" "META" "NFLX"

Analysis of the 4 stocks

Candlestick

AMZN

[1] "AMZN"

GOOG

[1] "GOOG"

META

[1] "META"

NFLX

[1] "NFLX"

Other Analysis

Column

---
title: "Lab 1 - Dashboards"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    social: ["menu"]
    source: embed
    vertical_layout: scroll
---
# Conclusion {.sidebar}
* This dashboard shows analysis for 4 companies, Amazon, Google, Meta and Netflix.
* All four companies had price corrections during 2022
* Meta and Netflix rebounded from the bottom while Amazon and Google have not recovered yet
* Both Google and Meta has P/E at 22x and forward P/E at around 17x, lower than Netflix and Amazon

*I will choose Google based on lower P/E while its market price still at the bottom
 

```{r setup, include=FALSE}

```

# Lab 1 Instructions

Column 
-----------------------------------------------------------------------

### 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, goverment, 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.

Column 
----------------------------------------------------------------------
### 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:

Delineate the necessary decision (I will do that below).
Identify what information will be relevant to decision making.
Find and collect the data necessary to create your visualization plan.
Organize and summarize the collected data.
Design and create the best visualizations to present that information.
Finally organize the layout of those visualizations in a way that conforms to the theory of dashboarding.
Write a summary about what decisions you made based on the visualizations that you developed.


Column 
----------------------------------------------------------------------
### 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 or commodities and determine which one of the four will produce the most short term gains. Use your imagination.

Column 
----------------------------------------------------------------------
### Dates & Deliverables

You are responsible for submitting a link to your dashboard hosted on the Rpubs site. The dashboard must include the source_code = TRUE parameter.

The due date for this project is XX at the start of class. This assignment is worth 75 points, 3x a normal homework, the additional time should allow you to spend the neccessary effort on this assignment.

You are welcome to work in groups of ≤2
 people. However, each person in a group must submit their own link to the assignment on moodle for grading! Each team member can submit the same link to a single rpubs account, however it may be a good idea for each of you to post your own copy to rpubs in case you want to share it to prospective employers ect.

There is one caveat to this project. While you can use any package to pull or obtain data, DO NOT use package like quantmod() to make your graphics. I want to see that you designed and built all the graphics yourself and did not use a precanned stock visualizing function like chartSeries(). There a number of great packages that allow you to use financial graphic types for which you build them see candlestick dygraphs for examples.

Here is another great resource for visualizing financial time series data using ggplot here

Column 
----------------------------------------------------------------------
### 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.


```{r, echo = TRUE, include = FALSE, message = FALSE}
install.packages("xts",repos = "http://cran.us.r-project.org")
library(xts)
install.packages("dygraphs",repos = "http://cran.us.r-project.org")
install.packages("lubridate",repos = "http://cran.us.r-project.org")
install.packages("DT",repos = "http://cran.us.r-project.org")
install.packages("pdfetch", repos = "http://cran.us.r-project.org")
install.packages("PerformanceAnalytics", repos = "http://cran.us.r-project.org")
install.packages("stocks", repos = "http://cran.us.r-project.org")
library(pdfetch)
library(DT)
library(lubridate)
library(dygraphs)
library(dplyr)
library(knitr)
library(ggplot2)
library(plyr)
library(PerformanceAnalytics)
library(stocks)
```

# Key Indicators Analysis

Column{.tabset}
----------------------------------------------------------------------
This part is to create a table view for the key financial indicators for the four companies: Amazon, Meta, Google, and Netflix. Indicators such as Symbol, P-E Ratio, Price EPS Estimate Next Year, Devision Yeils, and Market cap are included. All the companies has large-cap therefore by comparsion, the companies we are evaluating does not necessarily bring in huge returns in a short period of time.

Google has the lowest P-E Ratio. Therefore I will choose to invest in Google.

```{r}
metrics_list <- yahooQF(c("P/E Ratio",
                          "Price/EPS Estimate Next Year",
                          "Dividend Yield",
                          "Market Capitalization"))

tickers <- c("AMZN","GOOG","META","NFLX")

metrics <- getQuote(paste(tickers, sep=",", collapse=";"), what=metrics_list)

# Add tickers as the first column and remove the first column which had date stamps
metrics <- data.frame(Symbol=tickers, metrics[,2:length(metrics)]) 
#Change colnames
colnames(metrics) <- c("Symbol", "P/E Ratio", "Price EPS Estimate Next Year", "Div Yield", "Market Cap")

DT::datatable(metrics)

```

-----------------------------------------------------------------------

### Stock Closing Prices

```{r}
getSymbols(tickers, from="2022-03-25", to="2023-03-24")
ClosingPrices <- do.call(merge, lapply(tickers, function(x) Cl(get(x))))
dateperiod<-c("2022-03-25", "2023-03-24")
dygraph(ClosingPrices, main="Closing Price in Dollars", group="Stock") %>%
  dyAxis("y", label="Closing Price(USD)") %>%
  dyOptions(axisLineWidth = 1.5,  colors = RColorBrewer::brewer.pal(5, "Set1")) %>%
  dyHighlight(highlightSeriesBackgroundAlpha = 1.0, highlightSeriesOpts = list(strokeWidth = 3)) %>%
  dyRangeSelector(height = 50)
```

# Analysis of the 4 stocks

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

### AMZN

```{r}
getSymbols("AMZN", src = "yahoo", from="2022-03-25")
AMZN_x <- AMZN
dygraph(AMZN_x[, -5], main = "AMZN") %>%
  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-25")
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)
```

### META

```{r}
getSymbols("META", src = "yahoo", from="2022-03-25")
META_x <- META
dygraph(META_x[, -5], main = "META") %>%
  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)
```

### NFLX

```{r}
getSymbols("NFLX", src = "yahoo", from="2022-03-25")
NFLX_x <- NFLX
dygraph(NFLX_x[, -5], main = "PYPL") %>%
  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)
```

# Other Analysis

Column 
----------------------------------------------------------------------
```{r}
m.rt.AMZN <- monthlyReturn(AMZN)
m.rt.GOOG <- monthlyReturn(GOOG)
m.rt.META <- monthlyReturn(META)
m.rt.NFLX <- monthlyReturn(NFLX)

mg.return <- merge.xts(m.rt.AMZN,m.rt.GOOG, m.rt.META, m.rt.NFLX)
colnames(mg.return) <- c('AMZN','GOOG','META','NFLX')


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