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.
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.
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.
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
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.
This part is to create a table view for the key financial indicators for the four companies: Amazon, Facebook, Google, and IBM. 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.
Amazon has the highest P-E Ratio and EPS. Therefore I will choose to invest in Amazon.
Now we have four companies left: Google, Facebook, HP and IBM. In this dashboard, the stock closing price will be presented in a visualized method.
The first chart series graph is straightforward as it shows Amazon’s price chart. The second chart series show the Bollinger Band chart, % Bollinger change, Volume Traded and Moving Average Convergence Diverence in 2018 alone.
[1] "AMZN"
[1] "GOOG"
[1] "FB"
[1] "IBM"
Amazon
---
title: "Lab 1_Chenyi Zhang_ANLY 512-92-O-2019/Late Fall-Data Visualization"
output:
flexdashboard::flex_dashboard:
orientation: columns
social: ["menu"]
source: embed
vertical_layout: scroll
---
# Conclusion {.sidebar}
* This dashboard shows analysis for 4 companies, Amazon, Google, Facebook and IBM.
* Amazon has the highest stock price.
* Amazon also has the highest PER.
* Stock price of Google and Amazon are gradually increasing.
* Goggle has the second highest price.
* Overall monthly return for four companies are stable, except Facebook in the period of 2012-2014.
In conclusion I will choose Amazon to invest among all four companies.
```{r setup, include=FALSE}
library(flexdashboard)
```
# 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(quantmod)
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, Facebook, Google, and IBM. 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.
Amazon has the highest P-E Ratio and EPS. Therefore I will choose to invest in Amazon.
```{r}
metrics_list <- yahooQF(c("P/E Ratio",
"Price/EPS Estimate Next Year",
"Dividend Yield",
"Market Capitalization"))
tickers <- c("AMZN","GOOG","FB","IBM")
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 Analyasis by Company
Column{.tabset}
----------------------------------------------------------------------
Now we have four companies left: Google, Facebook, HP and IBM. In this dashboard, the stock closing price will be presented in a visualized method.
The first chart series graph is straightforward as it shows Amazon’s price chart.
The second chart series show the Bollinger Band chart, % Bollinger change, Volume Traded and Moving Average Convergence Diverence in 2018 alone.
```{r,echo=FALSE, message=FALSE}
getSymbols("AMZN",from="2008-08-01",to="2018-08-17")
AMZN_log_returns<-AMZN%>%Ad()%>%dailyReturn(type='log')
getSymbols("GOOG",from="2008-08-01",to="2018-08-17")
GOOG_log_returns<-GOOG%>%Ad()%>%dailyReturn(type='log')
getSymbols("FB",from="2008-08-01",to="2018-08-17")
FB_log_returns<-FB%>%Ad()%>%dailyReturn(type='log')
getSymbols("IBM",from="2008-08-01",to="2018-08-17")
IBM_log_returns<-IBM%>%Ad()%>%dailyReturn(type='log')
```
Amazon
```{r}
AMZN%>%Ad()%>%chartSeries()
AMZN%>%chartSeries(TA='addBBands();addVo();addMACD()',subset='2018')
```
Google
```{r}
GOOG%>%Ad()%>%chartSeries()
GOOG%>%chartSeries(TA='addBBands();addVo();addMACD()',subset='2018')
```
Facebook
```{r}
FB%>%Ad()%>%chartSeries()
FB%>%chartSeries(TA='addBBands();addVo();addMACD()',subset='2018')
```
IBM
```{r}
IBM%>%Ad()%>%chartSeries()
IBM%>%chartSeries(TA='addBBands();addVo();addMACD()',subset='2018')
```
# Other Analysis
Column
----------------------------------------------------------------------
### Stock Closing Price
```{r}
tickers_1 <- c("AMZN", "GOOG", "FB", "IBM")
ClosingPrices <- do.call(merge, lapply(tickers_1, function(x) Cl(get(x))))
dateperiod<-c("2015-01-01", "2018-05-19")
dygraph(ClosingPrices, main="Closing Price in Dollars", group="Stock") %>%
dyAxis("y", label="Closing Price(USD)") %>%
dyOptions( colors = RColorBrewer::brewer.pal(5, "Set1")) %>%
dyHighlight(highlightSeriesBackgroundAlpha = 0.5,
highlightSeriesOpts = list(strokeWidth = 4)) %>%
dyRangeSelector(height = 30)
```
### Monthly Return
Column
----------------------------------------------------------------------
```{r}
m.rt.AMZN <- monthlyReturn(AMZN)
m.rt.GOOG <- monthlyReturn(GOOG)
m.rt.FB <- monthlyReturn(FB)
m.rt.IBM <- monthlyReturn(IBM)
mg.return <- merge.xts(m.rt.AMZN,m.rt.GOOG, m.rt.FB, m.rt.IBM)
colnames(mg.return) <- c('AMZN','GOOG','FB','IBM')
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)
```