column

Historical Price Trend for Energy Stocks

Financial Metrics for Energy Stocks

Column

Exxon Mobil Corporation (XOM)

Chevron Corporation (CVX)

ConocoPhillips Company (COP)

EOG Resources, Inc.(EOG)

---
title: "ANLY 512 - Lab 1"
subtitle: _Dashboards & Dashboard Theory_
author: _Ayesha Khan_
date: _`r Sys.Date()`_

output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
    social: menu
    source_code: embed
---

```{r setup, include=FALSE, message=FALSE}
packages <- c('flexdashboard','lubridate','dygraphs','quantmod','plyr','DT','xts')
for(p in packages){
  if(!require(p,character.only = TRUE)) install.packages(p, dependencies = TRUE)
  suppressMessages(library(p,character.only = TRUE, quietly = TRUE))
}

```
Sidebar {.sidebar}
---------------------------------------------------------------------

_It is a common strategy to invest in energy stocks in winters when You want to make an investment in securities/commodities to make some short term gains._

#### **Objective:**
The objective of this dashboard is to test this by comparing top four energy stocks companies: Exxon Mobil Corporation (XOM), Chevron Corporation (CVX), ConocoPhillips Company (COP) and EOG Resources, Inc.(EOG) to determine which one of these four will produce the most short term gains.

#### **Findings:**
Exxon has the highest Earnings multiple and Dividend yield. Hence, it seems like the best of these 4 energy stocks to invest in for short-term gains. However, it is interesting to note the incredibility of the common hearsay that energy stocks rise as the temperatures drop. The closing prises trends do not validate this idea; in fact we see a declining trend going from May to November. \n

#### **Considerations:**
While Exxon seems like the best option, its year-to-date closing price trends exhibit significant volatility which should be kept in mind as well.

column {data-height=200}
-------------------------------------

### Historical Price Trend for Energy Stocks
```{r,echo=FALSE, message = FALSE}
tickers <- c("XOM", "CVX", "COP", "EOG")
invisible(getSymbols(tickers, from="2019-01-01", to="2019-11-01"))
ClosingPrices <- do.call(merge, lapply(tickers, function(x) Cl(get(x))))
dateperiod<-c("2019-01-01", "2019-11-01")
dygraph(ClosingPrices, main="Closing Price", group="Stock") %>%
    dyAxis("y", label="Closing Price(USD)") %>%
  dyOptions(axisLineWidth = 2.0,  colors = RColorBrewer::brewer.pal(5, "Set1")) %>%
  dyHighlight(highlightSeriesBackgroundAlpha = 1.0, highlightSeriesOpts = list(strokeWidth = 3)) %>%
  dyRangeSelector(height = 55)
```

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

tickers <- c("XOM", "CVX", "COP", "EOG")

metrics <- getQuote(paste(tickers, sep="", collapse=";"), what=what_metrics)

#Add tickers as the first column and remove the first column with date stamps
metrics <- data.frame(Symbol=tickers, metrics[,2:length(metrics)]) 
#Change column names:
colnames(metrics) <- c("Symbol", "Earnings Multiple", 
                       "Earnings Multiple (Forward)", "Div Yield", "Market Cap ($mm)")

#Format data:
metrics$'Market Cap ($mm)'<-as.numeric(as.character(metrics$'Market Cap ($mm)')) /1000000
metrics <- format(metrics, digits=2, big.mark=",", nsmall=3)
#Write to csv file
#write.csv(metrics, "FinancialMetrics.csv", row.names=FALSE)
DT::datatable(metrics)
```

Column {data-height=650 .tabset .tabset-fade}
-----------------------------------------------------------------------

### Exxon Mobil Corporation (XOM)
```{r}
invisible(getSymbols("XOM", src = "yahoo", from='2019-01-01'))
XOM_x <- XOM
dygraph(XOM_x[, -5], main = "Exxon Mobil Corporation") %>%
  dyCandlestick() %>%
  dyAxis("y", label="Closing Price") %>%
  dyOptions(colors= RColorBrewer::brewer.pal(5, "Set1")) %>%
  dyHighlight(highlightCircleSize = 5,
              highlightSeriesOpts = list(strokeWidth = 4),
              highlightSeriesBackgroundAlpha = 1) %>%
  dyRangeSelector(height = 80)
```


### Chevron Corporation (CVX)
```{r}
invisible(getSymbols("CVX", src = "yahoo", from='2018-01-01'))
CVX_x <- CVX
dygraph(CVX_x[, -5], main = "Chevron Corporation") %>%
  dyCandlestick() %>%
  dyAxis("y", label="Closing Price") %>%
  dyOptions(colors= RColorBrewer::brewer.pal(5, "Set1")) %>%
  dyHighlight(highlightCircleSize = 5,
              highlightSeriesOpts = list(strokeWidth = 4),
              highlightSeriesBackgroundAlpha = 1) %>%
  dyRangeSelector(height = 80)
```


### ConocoPhillips Company (COP)
```{r}
invisible(getSymbols("COP", src = "yahoo", from='2018-01-01'))
COP_x <- COP
dygraph(COP_x[, -5], main = "ConocoPhillips Company") %>%
  dyCandlestick() %>%
  dyAxis("y", label="Closing Price") %>%
  dyOptions(colors= RColorBrewer::brewer.pal(5, "Set1")) %>%
  dyHighlight(highlightCircleSize = 5,
              highlightSeriesOpts = list(strokeWidth = 4),
              highlightSeriesBackgroundAlpha = 1) %>%
  dyRangeSelector(height = 80)
```

### EOG Resources, Inc.(EOG)
```{r}
invisible(getSymbols("EOG", src = "yahoo", from='2018-01-01'))
EOG_x <- EOG
dygraph(EOG_x[, -5], main = "EOG Resources") %>%
  dyCandlestick() %>%
  dyAxis("y", label="Closing Price") %>%
  dyOptions(colors= RColorBrewer::brewer.pal(5, "Set1")) %>%
  dyHighlight(highlightCircleSize = 5,
              highlightSeriesOpts = list(strokeWidth = 4),
              highlightSeriesBackgroundAlpha = 1) %>%
  dyRangeSelector(height = 80)
```