#Objective

To do:

  1. Delineate the necessary decision (I will do that below).

  2. Identify what information will be relevant to decision making.

  3. Find and collect the data necessary to create your visualization plan.

  4. Organize and summarize the collected data.

  5. Design and create the best visualizations to present that information.

  6. Finally organize the layout of those visualizations in a way that conforms to the theory of dashboarding.

  7. Write a summary about what decisions you made based on the visualizations that you developed.

My plan:

I make investments for my company, my objective is to purchase securities/commodities for the key objective of maximizing profits. I want to make an investment in securities/commodities to make some short term gains. I am considering investing in one of any four companies, Alibaba Group Holding Ltd (BABA), U.S. Bancorp (USB), Centene Corp (CNC), and PayPal (PYPL). I collect data from Yahoo Finance and I will focus on the Stock Key Performance Metrics, historical stock closing price, and the historical Candlestick information when I make a quantitative decision.

#Summary

##Column

###Stock Key Performance Metrics

###Stock Closing Prices

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

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

[1] "BABA"

###USB

[1] "USB"

###CNC

[1] "CNC"

###PYPL

[1] "PYPL"

##Column {.sidebar}

From the previous analysis, I can tell that BABA and PYPL are both good options. From the “Candlestick” plots on the right side, it is obviously that the PYPL is really in an increasing trend comparing to BABA. PYPL should be a good option to be invested to make some short term gains.

#Conclusion

I was considering investing in one of any four companies, Alibaba Group Holding Ltd (BABA), U.S. Bancorp (USB), Centene Corp (CNC), and PayPal (PYPL). I collected data from Yahoo Finance and I focused on the Stock Key Performance Metrics, historical stock closing price, and the historical Candlestick information when I wanted to make a quantitative decision.

Based on the P/E Ratio and Market Cap, PYPL and BABA seems to be more outstanding than 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. PYPL should be a good option to be invested to make some short term gains.

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

```{r setup, include=FALSE}
library(flexdashboard)
#install.packages("quantmod")
library(quantmod)
library(plyr)
#install.packages("DT")
library(DT)
#install.packages("dygraphs")
library(dygraphs)
#install.packages("tidyquant")
#library(tidyquant)
#library(ggplot2)
```

#Objective

To do:

1. Delineate the necessary decision (I will do that below).

2. Identify what information will be relevant to decision making.

3. Find and collect the data necessary to create your visualization plan.

4. Organize and summarize the collected data.

5. Design and create the best visualizations to present that information.

6. Finally organize the layout of those visualizations in a way that conforms to the theory of dashboarding.

7. Write a summary about what decisions you made based on the visualizations that you developed.


My plan:

I make investments for my company, my objective is to purchase securities/commodities for the key objective of maximizing profits. I want to make an investment in securities/commodities to make some short term gains. I am considering investing in one of any four companies, Alibaba Group Holding Ltd (BABA),  U.S. Bancorp (USB), Centene Corp (CNC), and PayPal (PYPL). I collect data from Yahoo Finance and I will focus on the Stock Key Performance Metrics, historical stock closing price, and the historical Candlestick information when I make a quantitative decision.


#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="2019-01-01", to="2022-10-01")
ClosingPrices <- do.call(merge, lapply(tickers, function(x) Cl(get(x))))
dateperiod<-c("2019-01-01", "2022-10-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='2019-01-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='2019-01-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='2019-01-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='2019-01-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. From the "Candlestick" plots on the right side, it is obviously that the PYPL is really in an increasing trend comparing to BABA. 
PYPL should be a good option to be invested to make some short term gains.

#Conclusion

I was considering investing in one of any four companies, Alibaba Group Holding Ltd (BABA),  U.S. Bancorp (USB), Centene Corp (CNC), and PayPal (PYPL). I collected data from Yahoo Finance and I focused on the Stock Key Performance Metrics, historical stock closing price, and the historical Candlestick information when I wanted to make a quantitative decision.

Based on the P/E Ratio and Market Cap, PYPL and BABA seems to be more outstanding than 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. 
PYPL should be a good option to be invested to make some short term gains.