Objective

Requirement:

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.

My plan:

I intend to setup investments for my company. My objective is to maximize profits through purchasing and investing securities/commodities. Due to liquidity concerns, short term gains via day-trading are preferred. Target companies include: Alibaba Group Holding Ltd (BABA), U.S. Bancorp (USB), Centene Corp (CNC), and PayPal (PYPL). I collect data from Yahoo Finance and focus on Stock Key Performance Metrics, historical stock closing price, and the historical Candlestick information for sound quantitative decision-making.

Summary

Column

Stock Key Performance Metrics


Stock Closing Prices

[1] "BABA" "USB"  "CNC"  "PYPL"

Analysis of the 4 stocks

Candlestick

BABA

[1] "BABA"

USB

[1] "USB"

CNC

[1] "CNC"

PYPL

[1] "PYPL"

Conclusion

Based on the P/E Ratio and Market Cap, PYPL and BABA serve as the more appealing candidates compared to the other two stocks. However, PYPL is better than BABA based on the EPS and stocks historical closing price plot. Moreover, the “Candlestick” plots obviously show that the PYPL stock is really in an increasing trend comparing to BABA.

---
title: "ANLY 512 Lab 1 - Dashboards and Dashboard Theory"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
    source_code: embed
---

```{r setup, include=FALSE}
library(flexdashboard)
library(quantmod)
library(plyr)
library(DT)
library(dygraphs)
library(ggplot2)
```

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

# Objective

Requirement:

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.


My plan:

I intend to setup investments for my company. My objective is to maximize profits through purchasing and investing securities/commodities. Due to liquidity concerns, short term gains via day-trading are preferred. Target companies include: Alibaba Group Holding Ltd (BABA),  U.S. Bancorp (USB), Centene Corp (CNC), and PayPal (PYPL). I collect data from Yahoo Finance and focus on Stock Key Performance Metrics, historical stock closing price, and the historical Candlestick information for sound quantitative decision-making.


# Summary

## Column

### Stock Key Performance Metrics 

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

tickers <- c("BABA", "USB", "CNC", "PYPL")
# Not all the metrics are returned by Yahoo.
metrics <- getQuote(paste(tickers, sep="", collapse=";"), what=what_metrics)

#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")

#Export financial stock key performance metrics to a csv file
write.csv(metrics, "FinancialMetrics.csv", row.names=FALSE)
DT::datatable(metrics)
```

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

### Stock Closing Prices

```{r}
getSymbols(tickers, from="2015-01-01", to="2019-05-01")
ClosingPrices <- do.call(merge, lapply(tickers, function(x) Cl(get(x))))
dateperiod<-c("2015-01-01", "2019-05-01")
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)
```

## Column {.sidebar}

Generally, a high P/E ratio means that investors are anticipating higher growth in the future. The current average market P/E ratio is roughly 20 to 25 times earnings. Companies that are losing money do not have a P/E ratio. However, a stock with a high P/E ratio is not necessarily a better investment than one with a lower P/E ratio, as a high P/E ratio can indicate that the stock is being overvalued. All the four stocks looks good to me based on the P/E ratio, expecially BABA and PYPL.

A company's earnings per share, or EPS, is found by taking net income (or profits) divided by the shares of common stock outstanding. This measure allows the analyst to understand the amount of money left over for each share of stock issued to the public. So the future earnings estimates are arguably the most important input when attempting to value a firm. Based on this, PYPL seems to be an good option.

For the Market Cap, PYPL and BABA seems to be more outstanding than the other two stocks. 

From the historical Closing Price plot for the four stocks, it looks like that the CNC and USB trends are kind of stable and recently have the trend to decrease. PYPL and BABA are in the trend of increasing since Jan 2019, expecially PYPL.


# Analysis of the 4 stocks

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

### BABA

```{r}
getSymbols("BABA", src = "yahoo", from='2015-05-01')
BABA_x <- BABA
dygraph(BABA_x[, -5], main = "BABA") %>%
  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)
```

### USB

```{r}
getSymbols("USB", src = "yahoo", from='2015-05-01')
USB_x <- USB
dygraph(USB_x[, -5], main = "USB") %>%
  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)
```

### CNC

```{r}
getSymbols("CNC", src = "yahoo", from='2015-05-01')
CNC_x <- CNC
dygraph(CNC_x[, -5], main = "CNC") %>%
  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)
```

### PYPL

```{r}
getSymbols("PYPL", src = "yahoo", from='2015-05-01')
PYPL_x <- PYPL
dygraph(PYPL_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)
```

## Column {.sidebar}

From the previous analysis, I can tell that BABA and PYPL are both good options, relatively speaking. From the "Candlestick" plots on the right side, it is obvious that the PYPL is really in an increasing trend comparing to BABA. 
With the recent crackdown on Tech companies from the Chinese government and further tightening of foreign investments, the market is expecting more fluctuation in the industry.

PYPL also seems like a good option to invest for the sake of garnishing short term gains.


# Conclusion

Based on the P/E Ratio and Market Cap, PYPL and BABA serve as the more appealing candidates compared to the other two stocks. However, PYPL is better than BABA based on the EPS and stocks historical closing price plot. Moreover, the "Candlestick" plots obviously show that the PYPL stock is really in an increasing trend comparing to BABA.