Key Metrics Analysis

Data Table

Amazon

[1] "AMZN"

Target

[1] "TGT"

Walmart

[1] "WMT"

Ebay

[1] "EBAY"

Comparative analysis

              AMZN.Close     TGT.Close   WMT.Close   EBAY.Close
2008-01-02            NA            NA          NA           NA
2008-01-03 -0.0108640054  0.0012111831 -0.01114936  0.010714906
2008-01-04 -0.0698109255 -0.0305194802 -0.01433249 -0.048029103
2008-01-07  0.0003378076  0.0187499047  0.01820596 -0.027860575
2008-01-08 -0.0106396365 -0.0008168471 -0.01275279 -0.014226918
2008-01-09 -0.0307360536  0.0196222946  0.02002869 -0.004676062

Extended Analysis

---
title: "Lab1 - Dashboarding"
output:
  flexdashboard::flex_dashboard:
    orientation: rows
    social: [ "menu" ]
    source: embed
    verticle_layout: scroll
---
# Conclusion {.sidebar}

* This dashboard shows the stock analysis of the four major US retailers: Amazon Inc., Target Corporation, Walmart and Ebay.

* Analysis Parameters like P-E Ratio, EPS or earnings Per Share, Dividend Yield and Market Cap.It can be inferred from the table below that Amazon’s higher P-E ratio (which is calculated by Dividing Market value per share by projected earnings per share) shows that the investors are anticipating higher growth in the future. Which is clearly evident from its performance in Q1 of 2019. This growth might have been the result of its drive to expand into the grocery retail presence. Alexa and AWS are some of the other factors that contributed to its higher P-E.

* The tabs here shows Amazon, Target, Walmart and eBay’s Share price trend and Volume of shared traded in the market over the last 10-year period.
It is quite evident from the charts that all the 4 multinationals have shown an upward trend in their market performance as all the charts are showing an upward trend owing to a positive market sentiment for all the 4 giants. Clearly Amazon has been the highest gainer in this regard rising from a sub $100 share price to the current price of over $1800. Amazon exponential gains have been driven through its continuous business expansion in the cloud space. Moreover, Amazon’s revenue has shown tremendous growth in the past 5 years and there has been a speculation that the Amazon stocks could be worth upward of $6000 in the next 5 years period.

```{r setup, include=FALSE}
# Installing & calling Required packages
library(flexdashboard)
install.packages("xts",repos = "http://cran.us.r-project.org")
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(ggplot2)
library(quantmod)
library(plyr)
library(DT)
library(dplyr)
library(magrittr)
library(dygraphs)
```

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

tickers <- c("AMZN", "EBAY", "WMT", "TGT")
# 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")
```
### Data Table
```{r, echo=TRUE}
DT::datatable(metrics)
```

```{r}
start <- as.Date("2008-01-01")
end <- as.Date("2018-12-31")
```


# Amazon

```{r}
getSymbols("AMZN",from="2008-01-01",to="2018-12-31")
AMZN_log_returns<-AMZN%>%Ad()%>%dailyReturn(type='log')
candleChart(AMZN, up.col="black",dn.col="red", theme = "white")
```


# Target

```{r}
getSymbols("TGT",from="2008-01-01",to="2018-12-31")
TGT_log_returns<-TGT%>%Ad()%>%dailyReturn(type='log')
candleChart(TGT, up.col="black",dn.col="red", theme = "white")
```


# Walmart

```{r}
getSymbols("WMT",from="2008-01-01",to="2018-12-31")
WMT_log_returns<-WMT%>%Ad()%>%dailyReturn(type='log')
candleChart(WMT, up.col="black",dn.col="red", theme = "white")
```


# Ebay

```{r}
getSymbols("EBAY",from="2008-01-01",to="2018-12-31")
EBAY_log_returns<-EBAY%>%Ad()%>%dailyReturn(type='log')
candleChart(EBAY, up.col="black",dn.col="red", theme = "white")
```


# Comparative analysis

```{r, echo=TRUE}
stocks<-as.xts(data.frame(AMZN=AMZN[,"AMZN.Close"],TGT=TGT[,"TGT.Close"],WMT=WMT[,"WMT.Close"],EBAY=EBAY[,"EBAY.Close"]))

stock_change<-stocks%>%log%>%diff
head(stock_change)
```


# Extended Analysis

```{r}
m.rt.AMZN <- monthlyReturn(AMZN)
m.rt.TGT <- monthlyReturn(TGT)
m.rt.WMT <- monthlyReturn(WMT)
m.rt.EBAY <- monthlyReturn(EBAY)

mg.return <- merge.xts(m.rt.AMZN,m.rt.TGT, m.rt.WMT, m.rt.EBAY)
colnames(mg.return) <- c(' Amazon.com, Inc.','Target Corporation','Walmart Inc','eBay')


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)
```