The four companines selected are Telsa, Amazon, JP MOrgan and Chase and Microsoft. Here are some key ratios and indicators on the four stocks mentioned. The indicators included are Price/Earnings ratio, Price/EPS estimate for next year, dividend yield, market capitalization of the company. Those indicators are to check the outlook of the company (Price/Earnings ratio, Price/EPS estimate for next year, dividend yield, market capitalization)
High PER will bring higher risk and lower growth. High EPS means that the company has the potential to bring in more money to the share of stocks. Lower Devidend Yeild, meaning the company has less income compare to the ones that has Div Yield.
library(xts) # create Candlestick Charts using the dyCandlestick function
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
library(pdfetch)
## Warning: package 'pdfetch' was built under R version 4.2.3
library(DT)
library(lubridate)
##
## Attaching package: 'lubridate'
## The following objects are masked from 'package:base':
##
## date, intersect, setdiff, union
library(dygraphs)
## Warning: package 'dygraphs' was built under R version 4.2.3
library(quantmod)
## Loading required package: TTR
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:xts':
##
## first, last
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(knitr)
library(ggplot2)
library(tidyr)
library(plyr)
## ------------------------------------------------------------------------------
## You have loaded plyr after dplyr - this is likely to cause problems.
## If you need functions from both plyr and dplyr, please load plyr first, then dplyr:
## library(plyr); library(dplyr)
## ------------------------------------------------------------------------------
##
## Attaching package: 'plyr'
## The following objects are masked from 'package:dplyr':
##
## arrange, count, desc, failwith, id, mutate, rename, summarise,
## summarize
library(PerformanceAnalytics)
## Warning: package 'PerformanceAnalytics' was built under R version 4.2.3
##
## Attaching package: 'PerformanceAnalytics'
## The following object is masked from 'package:graphics':
##
## legend
library(stocks)
## Warning: package 'stocks' was built under R version 4.2.3
## Loading required package: rbenchmark
## Warning in !is.null(rmarkdown::metadata$output) && rmarkdown::metadata$output
## %in% : 'length(x) = 2 > 1' in coercion to 'logical(1)'
what_metrics <- yahooQF(c("Price/Sales",
"Earnings/Share",
"P/E Ratio",
"Price/EPS Estimate Next Year",
"PEG Ratio",
"Dividend Yield",
"Market Capitalization"))
what_metrics
## [[1]]
## [1] "epsTrailingTwelveMonths" "trailingPE"
## [3] "forwardPE" "trailingAnnualDividendYield"
## [5] "marketCap"
##
## [[2]]
## [1] "Earnings/Share" "P/E Ratio"
## [3] "Price/EPS Estimate Next Year" "Dividend Yield"
## [5] "Market Capitalization"
##
## attr(,"class")
## [1] "quoteFormat"
tickers <- c( "JPM", "MSFT", "TSLA", "AMZN")
# Not all the metrics are returned by Yahoo.
metrics <- getQuote(paste(tickers, sep="", collapse=";"), what=what_metrics)
class(metrics)
## [1] "data.frame"
#Add tickers as the first column and remove the first column which had date stamps
metrics <- data.frame(Symbol=tickers, metrics[,2:length(metrics)])
metrics
#Change colnames
colnames(metrics) <- c("Symbol", "P-E Ratio", "Price EPS Estimate Next Year","Div Yield", "Market Cap")
#Persist this to the csv file
#write.csv(metrics, "FinancialMetrics.csv", row.names=FALSE)
DT::datatable(metrics)
Due to the inherent growth in the electronic production and storage of information, there is often a feeling of “information overload” or inundation when facing the process of quantitative decision making. As an analyst your job will often be to conduct analyses or create tools to support quantitative decision making.
A principle tool used in industry, goverment, non-profits, and academic fields to compensate for the information overload is the information dashboard. Functionally, a dashboard is meant to provide a user with a central resource to present in a clear and concise manner all the information neccessary to support day-to-day decision making and support operations.
The objective of this laboratory is to plan, design, and create an information dashboard to support quantitative decision making. To accomplish this task you will have to complete a number of steps:
You make investments for an organization, your objective is to purchase securities/commodities for the key objective of maximizing profits. You want to make an investment in securities/commodities to make some short term gains. You are considering investing in one of any four companies, for example: Twitter (TWTR), Microsoft (MSFT), or Apple (AAPL) (don’t use these). Choose 4 companies or commodities and determine which one of the four will produce the most short term gains. Use your imagination.
There are lots of places we can get financial data to support these decision. The simplest would be to go to for instance to the Yahoo Finance (https://finance.yahoo.com/) for data on the Hershey Company (HSY) the URL would be: (https://finance.yahoo.com/quote/HSY/history?p=HSY) and collect historical price data, and other financial and company information.
getSymbols("MSFT",from="2014-06-01",to="2022-06-1")
## [1] "MSFT"
MSFT_log_returns<-MSFT%>%Ad()%>%dailyReturn(type='log')
getSymbols("TSLA",from="2014-06-01",to="2022-06-1")
## [1] "TSLA"
TSLA_log_returns<-TSLA%>%Ad()%>%dailyReturn(type='log')
getSymbols("JPM",from="2014-06-01",to="2022-06-1")
## [1] "JPM"
JPM_log_returns<-JPM%>%Ad()%>%dailyReturn(type='log')
getSymbols("AMZN",from="2014-06-01",to="2022-06-1")
## [1] "AMZN"
AMZN_log_returns<-AMZN%>%Ad()%>%dailyReturn(type='log')
The closing price represents the most up-to-date valuation of a security until trading commences again on the next trading day. As we can see from the Straw Broom Charts that overall, JPMorgan Chase & Co and Amazon have the most stable and pretty similar stock closing price thourghout the years from 2014 to 2019, with fluctuations from 2020 through 2022. Closing price for Tesla is the highest amongst all 4 companies which started increasing since 2020 and almost reached $410 in the beginning of 2022 then down to $209 by June 2022. Microsoft’s has surpassed Tesla by June 2022 after lagging brhind Tesla for so long.
tickers <- c("JPM", "MSFT", "TSLA", "AMZN")
ClosingPrices <- do.call(merge, lapply(tickers, function(x) Cl(get(x))))
dateWindow<-c("2014-06-01", "2022-06-01")
dygraph(ClosingPrices, main="Stock Closing Price", group="Stock") %>%
dyAxis("y", label="Closing Price ($) ") %>%
dyOptions( colors = RColorBrewer::brewer.pal(4, "Set1")) %>%
dyHighlight(highlightSeriesBackgroundAlpha = 0.5,
highlightSeriesOpts = list(strokeWidth = 3)) %>%
dyRangeSelector(height = 35, dateWindow=dateWindow)
Here is the comparison of their Monthly return in one combined plot. This chart shows all stocks monthly return in one chart, so it is easier for use to find which one has better return.Monthly Return is the period returns re-scaled to a period of 1 month. This allows investors to compare returns of different assets that they have owned for different lengths of time. Monthly Return = Closing Price on Last Day of Month / Closing Price on Last Day of Previous Month. Compared to 3 other companies, Tesla has the highest fluctuation in the recent 5 years.Microsoft and JP MOrgan are relatively stable looking at the overall comparison data.
m.rt.TSLA <- monthlyReturn(TSLA)
m.rt.JPM <- monthlyReturn(JPM)
m.rt.AMZN <- monthlyReturn(AMZN)
m.rt.MSFT <- monthlyReturn(MSFT)
mg.return <- merge.xts(m.rt.TSLA,m.rt.JPM, m.rt.AMZN, m.rt.MSFT)
colnames(mg.return) <- c('Tesla','JPMorgan Chase & Co','Amazon','Microsoft
Corporation')
dateWindow<-c("2014-06-01", "2022-06-01")
dygraph(mg.return, main = "Monthly Return") %>%
dyAxis("y", label = "Return") %>%
dyOptions(colors = RColorBrewer::brewer.pal(4, "Set1")) %>%
dyHighlight(highlightSeriesBackgroundAlpha = 0.5,
highlightSeriesOpts = list(strokeWidth = 4)) %>%
dyRangeSelector(height = 35, dateWindow=dateWindow)
This dashboard show the analysis for 4 companies, Tesla, JP MOrgan & Chase, Microsoft and Amazon.Compare to 3 other companies, Tesla has the highest fluctuation in the recent 5 years. Microsoft Corporation and JPMorgan Chase & Co are the more stable which is similar to what we found when looking at Closing Price.Therefore for short term gains, I would consider investing in Tesla.