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.
Use the following four key ratios and indicators for the companies selected. - P/E Ratio: the ratio for valuing a company that measures its current share price relative to its per-share earnings (EPS). - Price/EPS Estimated - Dividend Yield - Market Cap
historical stock data from 6/17/19 to 12/17/19
[1] "TSLA"
[1] "AAPL"
[1] "GOOG"
[1] "AMZN"
---
title: "ANLY 512 Lab 1-Jiamin Ma"
output:
flexdashboard::flex_dashboard:
orientation: columns
source_code: embed
vertical_layout: fill
html_document:
df_print: paged
---
```{r setup, include=FALSE, message=FALSE}
library(xts)
library(ggplot2)
library(pdfetch)
library(DT)
library(lubridate)
library(dygraphs)
library(quantmod)
library(dplyr)
library(knitr)
library(tidyr)
library(plyr)
library(PerformanceAnalytics)
library(stocks)
library(flexdashboard)
library(htmlwidgets)
```
# Conclusion {.sidebar}
* This Dashboard is for visualizing the stock performance and key indicatos of four companies: Tesla, Apple, Google, and Amazon.
* Amazon has the highest closing price and Apple has the lowest closing price during the observed period.
* The overall stock price movements of Tesla, Apple and Google are going up whereas the price movement of Amazon is going down during the observed period.
* The monthly return for Apple, Google, and Amazon are relatively stable. Tesla had a significant increase in monthly return in Nov 2019.
* Tesla would be the best choice for short-term investors to invest.
# 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. 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 {.tabset}
-----------------------------------------------------------------------
### 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 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
### 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
Use the following four key ratios and indicators for the companies selected.
- P/E Ratio: the ratio for valuing a company that measures its current share price relative to its per-share earnings (EPS).
- Price/EPS Estimated
- Dividend Yield
- Market Cap
```{r}
metrics_list <- yahooQF(c("P/E Ratio",
"Price/EPS Estimate Next Year",
"Dividend Yield",
"Market Capitalization"))
tickers <- c("TSLA","AAPL","GOOG","AMZN")
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 Analysis by Company
historical stock data from 6/17/19 to 12/17/19
Column {.tabset}
-----------------------------------------------------------------------
```{r, echo=FALSE, message=FALSE}
getSymbols("TSLA",from="2019-06-17",to="2019-12-17")
TSLA_log_returns<-TSLA%>%Ad()%>%dailyReturn(type='log')
getSymbols("AAPL",from="2019-06-17",to="2019-12-17")
AAPL_log_returns<-AAPL%>%Ad()%>%dailyReturn(type='log')
getSymbols("GOOG",from="2019-06-17",to="2019-12-17")
GOOG_log_returns<-GOOG%>%Ad()%>%dailyReturn(type='log')
getSymbols("AMZN",from="2019-06-17",to="2019-12-17")
AMZN_log_returns<-AMZN%>%Ad()%>%dailyReturn(type='log')
```
### Tesla
```{r}
TSLA%>%Ad()%>%chartSeries(theme = chartTheme("white"),
color.vol = TRUE, multi.col = FALSE)
TSLA%>%chartSeries(TA='addBBands();addVo();addMACD()',subset='2019',
up.col = "Blue", dn.col = "Orange",
theme = chartTheme("white"),
color.vol = TRUE, multi.col = FALSE)
```
### Apple
```{r}
AAPL%>%Ad()%>%chartSeries(theme = chartTheme("white"),
color.vol = TRUE, multi.col = FALSE)
AAPL%>%chartSeries(TA='addBBands();addVo();addMACD()',subset='2019',
up.col = "Blue", dn.col = "Orange",
theme = chartTheme("white"),
color.vol = TRUE, multi.col = FALSE)
```
### Google
```{r}
GOOG%>%Ad()%>%chartSeries(theme = chartTheme("white"),
color.vol = TRUE, multi.col = FALSE)
GOOG%>%chartSeries(TA='addBBands();addVo();addMACD()',subset='2019',
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='2019',
up.col = "Blue", dn.col = "Orange",
theme = chartTheme("white"),
color.vol = TRUE, multi.col = FALSE)
```
# Other Analysis
Column
-----------------------------------------------------------------------
## Stock Closing Price
```{r}
tickers_1 <- c("TSLA", "AAPL", "GOOG", "AMZN")
ClosingPrices <- do.call(merge, lapply(tickers_1, function(x) Cl(get(x))))
dateperiod<-c("2019-06-17", "2019-12-17")
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.TSLA <- monthlyReturn(TSLA)
m.rt.AAPL <- monthlyReturn(AAPL)
m.rt.GOOG <- monthlyReturn(GOOG)
m.rt.AMZN <- monthlyReturn(AMZN)
mg.return <- merge.xts(m.rt.TSLA,m.rt.AAPL, m.rt.GOOG, m.rt.AMZN)
colnames(mg.return) <- c('TSLA','AAPL','GOOG','AMZN')
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)
```