---
title: "Lab 1 - Dashboards and Dashboarding Theory"
author: "PN"
output:
flexdashboard::flex_dashboard:
theme:
version: 4
bg: "#ecf2e6"
fg: "#1c1f1b"
primary: "#4b4f4c"
navbar-bg: "#ace3b2"
base_font:
google: Prompt
heading_font:
google: Sen
code_font:
google:
# arguments to sass::font_google()
family: JetBrains Mono
local: false
orientation: columns
vertical_layout: fill
source_code: embed
editor_options:
chunk_output_type: console
---
# Overview of ETFs
## Sidebar {.sidebar data-width="500"}
### Which Sector is Performing Better?
Here's a comparison of some well known ETFs from four different sectors:
- United States Natural Gas Fund LP - **Energy**
- Global X Blockchain ETF - **Blockchain**
- Backwave Dry Bulk Shipping ETF - **Shipping**
- The Cannabis ETF - **Cannabis**
```{r setup, include=FALSE}
library(flexdashboard)
library(pdfetch)
library(dygraphs)
library(xts)
chooseCRANmirror(graphics=FALSE, ind=1)
options(scipen = 100)
```
## Column {.tabset data-height="400"}
### United States Natural Gas Fund LP
```{r}
UNG = pdfetch_YAHOO("UNG", fields = c("open", "high", "low", "close"),
from = as.Date("2022-01-01"),
to = Sys.Date(),
interval = "1d")
colnames(UNG)=c("Open","High","Low","Close")
#w = tail(WDAY, n = 180)
dygraph(UNG,
ylab = "Stock Price ($)",
group = "stockprices") %>%
dyCandlestick() %>%
dyLegend(width = 500) %>%
dyRangeSelector(dateWindow = c("2022-01-01", as.character(Sys.Date())))
```
------------------------------------------------------------------------
### Global X Blockchain ETF
```{r}
BKCH = pdfetch_YAHOO("BKCH", fields = c("open", "high", "low", "close"),
from = as.Date("2022-01-01"),
to = Sys.Date(),
interval = "1d")
colnames(BKCH)=c("Open","High","Low","Close")
dygraph(BKCH,
ylab = "Stock Price ($)",
group = "stockprices") %>%
dyCandlestick() %>%
dyLegend(width = 500) %>%
dyRangeSelector(dateWindow = c("2022-01-01", as.character(Sys.Date())))
```
### Breakwave Dry Bulk Shipping ETF
```{r}
BDRY = pdfetch_YAHOO("BDRY", fields = c("open", "high", "low", "close"),
from = as.Date("2022-01-01"),
to = Sys.Date(),
interval = "1d")
colnames(BDRY)=c("Open","High","Low","Close")
dygraph(BDRY,
ylab = "Stock Price ($)",
group = "stockprices") %>%
dyCandlestick() %>%
dyLegend(width = 500) %>%
dyRangeSelector(dateWindow = c("2022-01-01", as.character(Sys.Date())))
```
### The Cannabis ETF
```{r}
THCX = pdfetch_YAHOO("THCX", fields = c("open", "high", "low", "close"),
from = as.Date("2022-01-01"),
to = Sys.Date(),
interval = "1d")
colnames(THCX)=c("Open","High","Low","Close")
dygraph(THCX,
ylab = "Stock Price ($)",
group = "stockprices") %>%
dyCandlestick() %>%
dyLegend(width = 500) %>%
dyRangeSelector(dateWindow = c("2022-01-01", as.character(Sys.Date())))
```
# Trending
## Sidebar {.sidebar data-width="500"}
### Best Bet - Energy/Natural Gas
**United States Natural Gas Fund LP (UNG):**
- The natural gas rally gets turbocharged in 2022, pushing prices to the highest level in fourteen years.
- Natural gas is moving into the hurricane season.
- Asia and Europe are LNG buyers.
- US stocks are very low.
- Expect lots of volatility - UNG tracks natural gas futures prices on a short-term basis.
### Not so hot right now - Blockchain, Shipping, Cannabis
- Blockchain (BKCH) : **Global X Blockchain** holds several negative signals and it will still perform weakly in the next couple of days or weeks. A negative evaluation of this ETF is predicted in near future.
- Shipping (BDRY): **Breakwave Dry Bulk Shipping** holds several negative signals and is within a very wide and falling trend, so it will still perform weakly in the next couple of days or weeks. A negative evaluation of this ETF in near future.
- Cannabis (THCX): **The Cannabis** holds several negative signals and is within a very wide and falling trend, so it will still perform weakly in the next couple of days or weeks. A negative evaluation of this ETF in near future.
## Column {.tabset data-height="550"}
### Closing Price
```{r}
identifiers = c("UNG","BKCH","BDRY","THCX")
cp = pdfetch_YAHOO(identifiers,
fields = c("open","adjclose"),
from = as.Date("2022-01-01"),
to = Sys.Date(),
interval = "1wk")
ac = cbind(cp$UNG.adjclose,cp$BKCH.adjclose, cp$BDRY.adjclose, cp$THCX.adjclose)
colnames(ac) <- c("UNG","BKCH","BDRY","THCX")
dygraph(ac,
main = "Comparing Closing Price (YTD)",
ylab = "Closing Price ($)",
group = "trading") %>%
dyOptions(strokeWidth = 1,
colors = RColorBrewer::brewer.pal(8, "Set1"),
connectSeparatedPoints = TRUE)%>%
dyHighlight(highlightCircleSize = 3,
highlightSeriesBackgroundAlpha = 0.2,
hideOnMouseOut = TRUE)%>%
dyLegend(width = 500) %>%
dyRangeSelector(dateWindow = c("2022-01-01", as.character(Sys.Date())))
```
### Volume
```{r}
vol = pdfetch_YAHOO(identifiers,
fields =c("volume","adjclose"),
from = as.Date("2022-01-01"),
to = Sys.Date(),
interval = "1wk")
vol1 = cbind(vol$UNG.volume,vol$BKCH.volume,vol$BDRY.volume,vol$THCX.volume)
colnames(vol1) = c("UNG","BKCH","BDRY","THCX")
dygraph(vol1,
main = "Comparing Volume (YTD)",
ylab = "Volume",
group = "trading") %>%
dyOptions(strokeWidth = 2,
colors = RColorBrewer::brewer.pal(8,"Set1"),
connectSeparatedPoints = TRUE)%>%
dyHighlight(highlightCircleSize = 3,
highlightSeriesBackgroundAlpha = 0.2,
hideOnMouseOut = TRUE)%>%
dyLegend(width = 500) %>%
dyRangeSelector(dateWindow = c("2022-01-01", as.character(Sys.Date())))
```