Stock Closing Prices

## [1] "AAPL" "GOOG" "BABA" "FANH"

### Tabular View

what_metrics <- yahooQF(c("Price/Sales", 
                          "P/E Ratio"
                          ,"Previous Close","52-week Low", "52-week High",
                          "Market Capitalization"))

tickers <- c("AAPL", "GOOG", "BABA", "FANH")

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

DT::datatable(metrics)

### Apple

invisible(getSymbols("AAPL", src = "yahoo", from='2018-01-01'))
AAPL_x <- AAPL
dygraph(AAPL_x[, -5], main = "Apple") %>%
  dyCandlestick() %>%
  dyAxis("y", label="Closing Price") %>%
  dyOptions(colors= RColorBrewer::brewer.pal(5, "Set1")) %>%
  dyHighlight(highlightCircleSize = 4,
              highlightSeriesOpts = list(strokeWidth = 3),
              highlightSeriesBackgroundAlpha = 1) %>%
  dyRangeSelector(height = 65)

Google

invisible(getSymbols("GOOG", src = "yahoo", from='2018-01-01'))
GOOG_x <- GOOG
dygraph(GOOG_x[, -5], main = "Google") %>%
  dyCandlestick() %>%
  dyAxis("y", label="Closing Price") %>%
  dyOptions(colors= RColorBrewer::brewer.pal(5, "Set1")) %>%
  dyHighlight(highlightCircleSize = 4,
              highlightSeriesOpts = list(strokeWidth = 3),
              highlightSeriesBackgroundAlpha = 1) %>%
  dyRangeSelector(height = 130)

BABA

invisible(getSymbols("BABA", src = "yahoo", from='2018-01-01'))
BABA_x <- BABA
dygraph(BABA_x[, -5], main = "Google") %>%
  dyCandlestick() %>%
  dyAxis("y", label="Closing Price") %>%
  dyOptions(colors= RColorBrewer::brewer.pal(5, "Set1")) %>%
  dyHighlight(highlightCircleSize = 4,
              highlightSeriesOpts = list(strokeWidth = 3),
              highlightSeriesBackgroundAlpha = 1) %>%
  dyRangeSelector(height = 130)

FANH

invisible(getSymbols("FANH", src = "yahoo", from='2018-01-01'))
FANH_x <- FANH
dygraph(FANH_x[, -5], main = "Google") %>%
  dyCandlestick() %>%
  dyAxis("y", label="Closing Price") %>%
  dyOptions(colors= RColorBrewer::brewer.pal(5, "Set1")) %>%
  dyHighlight(highlightCircleSize = 4,
              highlightSeriesOpts = list(strokeWidth = 3),
              highlightSeriesBackgroundAlpha = 1) %>%
  dyRangeSelector(height = 130)