Overview

ANLY 512: Lab1

Dashboard Laboratory

The objective is to conduct analysis on 4 companies to support the decision to make an investment in securities or commodities for the purpose of making short term gains. As such, the main purpose of the investment is to maximize profit.

Companies Selected

Relevant Information For the purpose of this analysis, 5 major valuations of the selected companies were selected;

For further analysis, the stock price of each company, as well as the trade volume was analysed.

Data Organization and Visualization The relevant data was then organized into various groups, and created into a graphic to display the information

Finacial Ratio Visualization

Column

Financial Metrics Table

Price/Book Ratio

test

PE Ratio

Market Cap

Trading Volumes

Trading Volume is simply the number of shares of a company traded within a given period of time. The Trading Volume is important as it indicates investors’ interest in a given company shares. To make profit off the short term ownership of a stock, the stock needs to be easily bought and sold, ie there is market available for that company’s stock, regardless of how the company is doing.

Walt Disney appears to have the highest spike in trade volume follwowed by JP Morgan. However, JM Morgan appers to have a higher trade Volume majority of the time.

Volume

Stock Prices

The stock price is the price at which a company’s single stock is sold in the stock market. Stock prices are determined by various factors which include company’s performance, investor’s confidence in the company, market conditions and even environmental factors. JP Morgan’s stock price reached its peek of the past two years in Oct of 2021, after that, it has had a downward trend with descending peaks and troughs. Further analysis of the JMP stock price trend which indicate that the JMP stock is selling for prices lower than it has in two, this indicates that is could be the best time to buy the stock. Considering the company financial ratios, JPM shows a growth potential will is expected to reflect in it’s stock price in the short term.

Column

Combined Closing Price

Walt Disney

Proctor & Gamble

Progressive

JP Morgan

Conclusion

JP Morgan’s stock price reached its peek of the past two years in Oct of 2021, after that, it has had a downward trend with descending peaks and troughs. Further analysis of the JMP stock price trend indicates that the JMP stock is selling for prices lower than it has in two years. This indicates that it could be the best time to buy the stock. Considering the company financial ratios, JPM shows a growth potential which is expected to reflect in it’s stock price in the short term. While Disney also has a similar stock price trend, JP Morgan appeared to have more trade volume and has been higher in the past few weeks.

In conclusion,considering the P-E Ratio, Price- Book ratio, Market Cap and Dividend yield, I believe JP Morgan will be the best of the 4 companies to invest in for short term gains.

---
title: "ANLY 512: Lab1 Dashboard Laboratory"
author: "M O"
date: "`r Sys.Date()`"
output:  
  flexdashboard::flex_dashboard:
           orientation: columns
           source_code: embed
    
 
---


---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```

```{r include=FALSE}



library(ggplot2)
library(tidyr)
library(vcd)
library(dygraphs)
library(quantmod)
library(plyr)
library(tidyquant)
library(xts)
library(pdfetch)
```

# Overview

ANLY 512: Lab1

Dashboard Laboratory

The objective is to conduct analysis on 4 companies to support the decision to make an investment in securities or commodities for the purpose of making short term gains. As such, the main purpose of the investment is to maximize profit.

Companies Selected

  * Walt Disney (DIS)
  * Procter & Gamble (PG)
  * Progressive Corp. (PGR)
  * JPMorgan Chase & Co (JPM)


Relevant Information
For the purpose of this analysis, 5 major valuations of the selected companies were selected; 

  * PE Ratio, 
  * Price/EPS Estimate Next Year,
  * Price-to-Book (P/B) Ratio, 
  * Dividend Yield,  
  * Market Capitalization. 
    
For further analysis, the stock price of each company, as well as the trade volume was analysed. 

Data Organization and Visualization
The relevant data was then organized into various groups, and created into a graphic to display the information




```{r echo=FALSE}


what_metrics <- yahooQF(c("Price/Sales", 
                          "P/E Ratio",
                          "Price/EPS Estimate Next Year",
                          "Price/Book",
                          "Dividend Yield", 
                          "Market Capitalization"))

tickers <- c("DIS", "PG", "PGR", "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-Book", "Price EPS Estimate Next Year", "Div Yield", "Market Cap")


write.csv(metrics, "FinancialMetrics.csv", row.names=FALSE)
```

# Finacial Ratio Visualization 

## Column{.sidebar}

To assess each company's short term  profitability, the analysis focused on 5 major financial metrics:

The PE Ratio, 
 
 * The PE ratio is an major indicator of a company's worth. It is derived by dividing the company stock price by the earnings per share for a given period of time. The PE ratio can be used to determine whether a company's stock is overvalued or undervalued. In some cases a high PE ratio could imply that the stock is overvalued, in other cases it would imply that the are willing to pay more becasue they see a high growth potential. Of the 4 companies selected for this analysis, Walt Disney appears to have the highest PE ratio at 56.51, while JP Morgan has the lowest with a PE ratio of 10.32. While all for companies are not in the same industry, the PE ration does give an insight to other investor's view of these companies.
 
Price/EPS Estimate Next Year

  * Similar to the PE ration but using the expected future earnings of the company. 

Price/Book Ratio

  * Similar to the PE ratio, the Price/Book ratio can be used to determine if a stock is overvalued or undervalued. 

Dividend Yield

  * The dividend yield shows the percentage a company pays in dividends of its share price. A higher dividend yield however, does not always been higher dividend paid by the company, particularly in a situation where the stock price of the companay is reducing.
  

Market Capitalization.

  * In simple terms, Market Capitalization the worth of a company as comuted byt the value of it's total shares based on its stock  price.

## Column

### Financial Metrics Table
```{r}


DT::datatable(metrics)
```

### Price/Book Ratio
```{r echo=FALSE}

metrics<-data.frame(metrics)

ggplot(metrics, aes(x = Symbol, y = Price.Book, fill = Symbol)) +
   geom_bar(stat="identity", width = 0.8) +
  geom_text(aes(label= round(Price.Book, 2)), vjust=1.6, color="white", size=3.5) +
  theme_classic() +
  theme(legend.position="none") +
   scale_fill_brewer(palette = 'Dark2') +
  labs(
    x = 'Company',
    y = 'Price/Book Ratio') 

```


## test 

### PE Ratio
```{r echo=FALSE}

#PE Ratio


ggplot(metrics, aes(x = Symbol, y = P.E.Ratio, fill = Symbol)) +
   geom_bar(stat="identity", width = 0.8) +
  theme_classic() +
  theme(legend.position="none") +
   scale_fill_brewer(palette = 'Dark2') +
  labs(
    x = 'Company',
    y = 'Price/Earnings Ratio') 



```




### Market Cap

```{r echo=FALSE}



metrics$Symbol<- factor(metrics$Symbol)
metrics$MarketCap <- as.numeric(metrics$Market.Cap)
metrics$MarketCap <- metrics$MarketCap/1000000000 

ggplot(metrics, aes(x = reorder(Symbol, MarketCap), y = MarketCap, fill = Symbol)) +
   geom_bar(stat="identity", width = 0.8) +
  theme_classic() +
  theme(legend.position="none") +
   scale_fill_brewer(palette = 'Dark2') +
  coord_flip() +
  labs(
    x = 'Company',
    y = 'Market Capitilization (Billions)') 


```


# Trading Volumes

Trading Volume is simply the number of shares of a company traded within a given period of time. The Trading Volume is important as it indicates investors' interest in a given company shares. To make profit off the short term ownership of a stock, the stock needs to be easily bought and sold, ie there is market available for that company's stock, regardless of how the company is doing.

Walt Disney appears to have the highest spike in trade volume follwowed by JP Morgan. However, JM Morgan appers to have a higher trade Volume majority of the time.

### Volume 
```{r echo=FALSE}


Volume<- pdfetch_YAHOO(tickers, fields = c("volume"), from = as.Date("2020-01-01"),interval = "1d")

Volume <- Volume/1000000 

dygraph(Volume, main="Trading Volume", group= "trading") %>%
  dyAxis("y", label="Trading Volume (Millions)") %>%
  dyOptions(colors = RColorBrewer::brewer.pal(5, "Dark2")) %>%
  dyRangeSelector(height = 20)




```



# Stock Prices

The stock price is the price at which a company's single stock is sold in the stock market. Stock prices are determined by various factors which include company's performance, investor's confidence in the company, market conditions and even environmental factors. JP Morgan's stock price reached its peek of the past two years in Oct of 2021, after that, it has had a downward trend with descending peaks and troughs. Further analysis of the JMP stock price trend which indicate that the JMP stock is selling for prices lower than it has in two, this indicates that is could be the best time to buy the stock. Considering the company financial ratios, JPM shows a growth potential will is expected to reflect in it's stock price in the short term.



## Column {.tabset .tabset-fade}

### Combined Closing Price  

```{r echo=FALSE, results='hide'}


getSymbols(tickers, from="2020-01-01")
ClosingPrices <- do.call(merge, lapply(tickers, function(x) Cl(get(x))))
```

```{r echo=FALSE}

dygraph(ClosingPrices, main="Closing Price in USD", group="Stock") %>%
  dySeries("DIS.Close", label = "DIS") %>%
  dySeries("PG.Close", label = "PG") %>%
  dySeries("PGR.Close", label = "PGR") %>%
  dySeries("JPM.Close", label = "JPM") %>%
  dyAxis("y", label="Closing Price (USD)") %>%
  dyOptions(colors = RColorBrewer::brewer.pal(5, "Dark2")) %>%
  dyRangeSelector(height = 20)

```

### Walt Disney
```{r echo=FALSE}

dygraph(ClosingPrices$DIS.Close, main=" DIS Closing Price in USD", group="Stock") %>%
  dySeries("DIS.Close", label = "DIS") %>%
  dyAxis("y", label="Closing Price DIS (USD)") %>%
  dyOptions(colors = "green") %>%
  dyRangeSelector(height = 20)



```


### Proctor & Gamble
```{r echo=FALSE}
dygraph(ClosingPrices$PG.Close, main="PG Closing Price in USD", group="Stock") %>%
  dySeries("PG.Close", label = "PG") %>%
  dyAxis("y", label="Closing Price PG (USD)") %>%
  dyOptions(colors = "orange") %>%
  dyRangeSelector(height = 20)

```


### Progressive
```{r echo=FALSE}
dygraph(ClosingPrices$PGR.Close, main="PGR Closing Price in USD", group="Stock") %>%
  dySeries("PGR.Close", label = "PGR") %>%
  dyAxis("y", label="Closing Price PGR (USD)") %>%
  dyOptions(colors = "purple") %>%
  dyRangeSelector(height = 20)

```


### JP Morgan
```{r echo=FALSE}

dygraph(ClosingPrices$JPM.Close, main="JPM Closing Price in USD", group="Stock") %>%
  dySeries("JPM.Close", label = "JPM") %>%
  dyAxis("y", label="Closing Price JPM (USD)") %>%
  dyOptions(colors = "orchid") %>%
  dyRangeSelector(height = 20)
```

# Conclusion

JP Morgan's stock price reached its peek of the past two years in Oct of 2021, after that, it has had a downward trend with descending peaks and troughs. Further analysis of the JMP stock price trend indicates that the JMP stock is selling for prices lower than it has in two years. This indicates that it could be the best time to buy the stock. Considering the company financial ratios, JPM shows a growth potential which is expected to reflect in it's stock price in the short term. While Disney also has a similar stock price trend, JP Morgan appeared to have more trade volume and has been higher in the past few weeks. 


In conclusion,considering the P-E Ratio, Price- Book ratio, Market Cap and Dividend yield, I believe JP Morgan will be the best of the 4 companies to invest in for short term gains.