library(quantmod)
library(flexdashboard)
library(dygraphs)
library(lubridate)I am making an investment plan for my company. Goal is to purchase
assets to maximize profit*s.
I am focusing on short term gains. Portfolio consists in
Meta, Oracle, IBM and
MSFT.
I collected relevant data from YahooFinance looking at stock
key performance metrics and historical candlestick plots for each
company in the portfolio.
Click on closing prices to see historical charts of all stocks in the
portfolio
Click on tabular view to see a table comparing financial metrics
More tickers can be added, we can search and filter the table by
ticker
## [1] "META" "IBM" "ORCL" "MSFT"
library(quantmod)
library(plyr)## Warning: package 'plyr' was built under R version 4.2.3
Metrics <- yahooQF(c("Price/Sales",
"P/E Ratio",
"Price/EPS Estimate Next Year",
"Dividend Yield",
"Market Capitalization"))
tickers <- c("META", "ORCL", "IBM", "MSFT")
metrics <- getQuote(paste(tickers, sep="", collapse=";"), what=Metrics)
metrics <- data.frame(Symbol=tickers,metrics[,2:length(metrics)])
colnames(metrics) <- c("Symbol", "Revenue Multiple", "Earnings Multiple", "Div Yield", "Market Cap")
DT::datatable(metrics)getSymbols("META", src = "yahoo", from='2021-01-01')## [1] "META"
META_x <- META
dygraph(META_x[, -5], main = "Facebook") %>%
dyCandlestick() %>%
dyAxis("y", label="Closing Price") %>%
dyOptions(colors= RColorBrewer::brewer.pal(4, "Set1")) %>%
dyHighlight(highlightCircleSize = 4,
highlightSeriesOpts = list(strokeWidth = 5),
highlightSeriesBackgroundAlpha = 1) %>%
dyRangeSelector(height = 75) %>%
dyLegend(show = "always", width=130) %>%
dyShading(from='2021-1-1', to='2023-3-28', color='black')getSymbols("ORCL", src = "yahoo", from='2021-01-01')## [1] "ORCL"
ORCL_x <- ORCL
dygraph(ORCL_x[, -5], main = "Oracle") %>%
dyCandlestick() %>%
dyAxis("y", label="Closing Price") %>%
dyOptions(colors= RColorBrewer::brewer.pal(4, "Set1")) %>%
dyHighlight(highlightCircleSize = 5,
highlightSeriesOpts = list(strokeWidth = 2),
highlightSeriesBackgroundAlpha = 1) %>%
dyRangeSelector(height = 75) %>%
dyLegend(show = "always", width=130) %>%
dyShading(from='2021-1-1', to='2023-3-28', color='black')getSymbols("IBM", src = "yahoo", from='2021-01-01')## [1] "IBM"
IBM_x <- IBM
dygraph(IBM_x[, -5], main = "IBM") %>%
dyCandlestick() %>%
dyAxis("y", label="Closing Price") %>%
dyOptions(colors= RColorBrewer::brewer.pal(6, "Set1")) %>%
dyHighlight(highlightCircleSize = 5,
highlightSeriesOpts = list(strokeWidth = 6),
highlightSeriesBackgroundAlpha = 1) %>%
dyRangeSelector(height = 75) %>%
dyLegend(show = "always", width=130) %>%
dyShading(from='2021-1-1', to='2023-3-28', color='black')getSymbols("MSFT", src = "yahoo", from='2021-01-01')## [1] "MSFT"
MSFT_x <- MSFT
dygraph(MSFT_x[, -5], main = "MSFT") %>%
dyCandlestick() %>%
dyAxis("y", label="Closing Price") %>%
dyOptions(colors= RColorBrewer::brewer.pal(5, "Set1")) %>%
dyHighlight(highlightCircleSize = 4,
highlightSeriesOpts = list(strokeWidth = 3),
highlightSeriesBackgroundAlpha = 1) %>%
dyRangeSelector(height = 75) %>%
dyLegend(show = "always", width=130) %>%
dyShading(from='2021-1-1', to='2023-3-28', color='black')Looking at the stock closing metrics, I can conclude that MSFT is the
best investment.
Since January 2021, MSFT experienced the biggest gain even though all
other stocks also appreciated.
Beginning of year 2022, MSFT and META experienced significant losses but
bounced back.
Volatility for these 2 stocks is significantly higher than IBM and
Oracle.
Looking at stock key performance metrics and the historical plot analysis, I recommend investing in MSFT to benefit from short term gains.