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.

Objective

The objective of this laboratory is to plan, design, and create an information dashboard to support quantitative decision making. 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.

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.

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 30th June by 11:59 P.M. 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.

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.

Key Indicators

This section takes a look at some key ratios and indicators on the four stocks mentioned. The indicators included are Price/Earnings ratio, Price/EPS estimate for next year, dividend yield, market capitalization of the company, 50 day moving average, 200 day Moving average and average daily volume traded for the stock. The first few indicators are to spot check the outlook and health of the company (Price/Earnings ratio, Price/EPS estimate for next year, dividend yield, market capitalization), while the last few are for checking the short-term profitability out of trading the stock (0 day moving average, 200 day Moving average and average daily volume)

Based on the short-term indicators, my choice is to buy & hold JP Morgan, with a view of creating some short-term gains.

Summary

Analysis

The first graph shows the change in closing stock price for the four companies, from June 15, 2010 to June 15, 2020

The second graph shows the volume of shares traded each day, the convergence/divergence of the moving average, and the upper/lower range of the stock price as it moves through the observation period.

Column

[1] "UAL"
[1] "FB"
[1] "AMZN"
[1] "JPM"

United Airlines

Facebook

Amazon

JP Morgan

Stock Closing Price

Monthly Return

---
title: "Anly 512, Lab 1- Deepika Grover"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    source_code: embed
    vertical_layout: fill
    html_document:
    df_print: paged
---

```{r setup, echo = TRUE, include = FALSE, message = FALSE}

library(quantmod)
library(plyr)
library(xts)
library(ggplot2)
library(pdfetch)
library(DT)
library(lubridate)
library(dygraphs)
library(dplyr)
library(knitr)
library(tidyr)
library(PerformanceAnalytics)
library(stocks)
library(flexdashboard)
```

# Lab 1 Instructions

Column {.tabset}
-----------------------------------------------------------------------

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


### Objective

*The objective of this laboratory is to plan, design, and create an information dashboard to support quantitative decision making. 
*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.

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

### 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 30th June by 11:59 P.M. 
*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. 

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


### Key Indicators

This section takes a look at some key ratios and indicators on the four stocks mentioned. The indicators included are Price/Earnings ratio, Price/EPS estimate for next year, dividend yield, market capitalization of the company, 50 day moving average, 200 day Moving average and average daily volume traded for the stock. The first few indicators are to spot check the outlook and health of the company (Price/Earnings ratio, Price/EPS estimate for next year, dividend yield, market capitalization), while the last few are for checking the short-term profitability out of trading the stock (0 day moving average, 200 day Moving average and average daily volume)

Based on the short-term indicators, my choice is to buy & hold JP Morgan, with a view of creating some short-term gains.
```{r}
what_metrics= yahooQF(c("Price/Sales", 
                          "P/E Ratio",
                          "Price/EPS Estimate Next Year",
                          "PEG Ratio",
                          "Dividend Yield", 
                          "Market Capitalization"))
                          
tickers = c("UAL", "AMZN", "FB", "JPM")
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", "Price EPS Estimate Next Year", "Div Yield", "Market Cap")
DT::datatable(metrics)
```

# Summary
* This Dasboard is to visualize the stock price trends and key ratios for four companies including United Airlines, Facebook, Amazon, JP Morgan

* UAL has lowest stock price at end of observation period which is due to less useage caused by current Covid-19 situation and is best for long term investment as it is expected to grow exponentially considering increase in usability with improvement in current conditions.

* Amazon has highest stock price at the end of observation period..

* Facebook has highest traded average daily volume during observed period

* Stock Price analysis indicates that Amazon is better for long term stock investment among four companies based on the current situation and historical data with expected low returns as the stock price is already peaked.

* Monthly Return analysis indicates that monthly return is more stable for JPM.

* Analysis indicates that short-term investment is best for JP Morgan.

# Analysis

The first graph shows the change in closing stock price for the four companies, from June 15, 2010 to June 15, 2020

The second graph shows the volume of shares traded each day, the convergence/divergence of the moving average, and the upper/lower range of the stock price as it moves through the observation period.

Column {.tabset}
-----------------------------------------------------------------------

```{r,echo=FALSE, message=FALSE}
getSymbols("UAL",from="2010-06-15",to="2020-06-15")
UAL_log_returns=UAL%>%Ad()%>%dailyReturn(type='log')

getSymbols("FB",from="2010-06-15",to="2020-06-15")
FB_log_returns=FB%>%Ad()%>%dailyReturn(type='log')

getSymbols("AMZN",from="2010-06-15",to="2020-06-15")
AMZN_log_returns=AMZN%>%Ad()%>%dailyReturn(type='log')

getSymbols("JPM",from="2010-06-15",to="2020-06-15")
JPM_log_returns=JPM%>%Ad()%>%dailyReturn(type='log')

```

### United Airlines

```{r}


UAL%>%Ad()%>%chartSeries(theme = chartTheme("white"),
                  color.vol = TRUE, multi.col = FALSE)
UAL%>%chartSeries(TA='addBBands();addVo();addMACD()',subset='2020', 
                  up.col = "Blue", dn.col = "Orange",
                  theme = chartTheme("white"),
                  color.vol = TRUE, multi.col = FALSE)


```

### Facebook

```{r}


FB%>%Ad()%>%chartSeries(theme = chartTheme("white"),
                  color.vol = TRUE, multi.col = FALSE)
FB%>%chartSeries(TA='addBBands();addVo();addMACD()',subset='2020', 
                  up.col = "Blue", dn.col = "Orange",
                  theme = chartTheme("white"),
                  color.vol = TRUE, multi.col = FALSE) 


```


### Amazon

```{r}
AMZN%>%Ad()%>%chartSeries(theme = chartTheme("white"),
                  color.vol = TRUE, multi.col = FALSE)
AMZN%>%chartSeries(TA='addBBands();addVo();addMACD()',subset='2020', 
                  up.col = "Blue", dn.col = "Orange",
                  theme = chartTheme("white"),
                  color.vol = TRUE, multi.col = FALSE)
```


### JP Morgan
```{r}
JPM%>%Ad()%>%chartSeries(theme = chartTheme("white"),
                  color.vol = TRUE, multi.col = FALSE)
JPM%>%chartSeries(TA='addBBands();addVo();addMACD()',subset='2020', 
                  up.col = "Blue", dn.col = "Orange",
                  theme = chartTheme("white"),
                  color.vol = TRUE, multi.col = FALSE)
```



### Stock Closing Price

```{r}
tickers_1=c("UAL", "FB", "AMZN", "JPM")
ClosingPrices=do.call(merge, lapply(tickers_1, function(x) Cl(get(x))))

dateperiod=c("2010-06-15", "2020-06-15")


dygraph(ClosingPrices, main="Closing Price in USD", group="Stock") %>%
  dyAxis("y", label="Closing Price(USD)") %>%
  dyOptions( colors = RColorBrewer::brewer.pal(5, "Set2")) %>%
  dyHighlight(highlightSeriesBackgroundAlpha = 0.5,
              highlightSeriesOpts = list(strokeWidth = 4)) %>%
  dyRangeSelector(height = 30)
```

### Monthly Return

```{r}
m.rt.UAL=monthlyReturn(UAL)
m.rt.FB=monthlyReturn(FB)
m.rt.AMZN=monthlyReturn(AMZN)
m.rt.JPM=monthlyReturn(JPM)

mg.return= merge.xts(m.rt.UAL,m.rt.FB, m.rt.AMZN, m.rt.JPM)
colnames(mg.return)= c('UAL','FB','AMZN','JPM')


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