library(quantmod)
library(plyr)
##
## Attaching package: 'plyr'
## The following object is masked from 'package:lubridate':
##
## here
what_metrics <- yahooQF(c("Price/Sales",
"P/E Ratio",
"Price/EPS Estimate Next Year",
"PEG Ratio",
"Dividend Yield",
"Market Capitalization"))
tickers <- c("FB", "ORCL", "AMZN", "GOOGL")
# 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", "Earnings Multiple",
"Earnings Multiple (Forward)", "Div Yield", "Market Cap")
#Persist this to the csv file
#write.csv(metrics, "FinancialMetrics.csv", row.names=FALSE)
datatable(head(metrics, 20), options = list(
initComplete = JS(
"function(settings, json) {",
"$(this.api().table().header()).css({'background-color': 'grey', 'color': '#fff'});",
"}")
))
invisible(getSymbols("FB", src = "yahoo", from='2014-03-01'))
FB_x <- FB
dygraph(FB_x[, -5], main = "Facebook") %>%
dyCandlestick() %>%
dyAxis("y", label="Closing Price") %>%
dyOptions(colors= RColorBrewer::brewer.pal(4, "Set2")) %>%
dyHighlight(highlightCircleSize = 3.5,
highlightSeriesOpts = list(strokeWidth = 3),
highlightSeriesBackgroundAlpha = 1) %>%
dyRangeSelector(height = 40)
invisible(getSymbols("ORCL", src = "yahoo", from='2014-03-01'))
ORCL_x <- ORCL
dygraph(ORCL_x[, -5], main = "Oracle") %>%
dyCandlestick() %>%
dyAxis("y", label="Closing Price") %>%
dyOptions(colors= RColorBrewer::brewer.pal(4, "Set2")) %>%
dyHighlight(highlightCircleSize = 3.5,
highlightSeriesOpts = list(strokeWidth = 3),
highlightSeriesBackgroundAlpha = 1) %>%
dyRangeSelector(height = 40)
invisible(getSymbols("AMZN", src = "yahoo", from='2014-03-01'))
AMZN_x <- AMZN
dygraph(AMZN_x[, -5], main = "Amazon") %>%
dyCandlestick() %>%
dyAxis("y", label="Closing Price") %>%
dyOptions(colors= RColorBrewer::brewer.pal(4, "Set2")) %>%
dyHighlight(highlightCircleSize = 3.5,
highlightSeriesOpts = list(strokeWidth = 3),
highlightSeriesBackgroundAlpha = 1) %>%
dyRangeSelector(height = 40)
invisible(getSymbols("GOOGL", src = "yahoo", from='2014-03-01'))
GOOGL_x <- GOOGL
dygraph(GOOGL_x[, -5], main = "Google") %>%
dyCandlestick() %>%
dyAxis("y", label="Closing Price") %>%
dyOptions(colors= RColorBrewer::brewer.pal(4, "Set2")) %>%
dyHighlight(highlightCircleSize = 3.5,
highlightSeriesOpts = list(strokeWidth = 3),
highlightSeriesBackgroundAlpha = 1) %>%
dyRangeSelector(height = 40)
```