The objective of the dashboard is to purchase oje of the securities/commodities among four Chinese stocks (listed in the U.S.), which has the maximized profits with the short term goal. Four companies are Bilibili, Alibaba Group, JD.com, and Baidu.
P-E Ratio measures the relationship between the earnings of a company and its stock price, which can be interpreted that a high score may offer higher retunrs in the future.
Price EPS Estimate helps us understand the P-E ratio, which tells us whether a stock may or may not be a good value. The lower the number, the less you have to pay to get in on the company’s expected future earnings growth.
Based on the Key Indicator analysis, JD.com is my choice. However, it’s not my final decision.
The dashboard compares the stock prices and monthly/quarterly returns of 4 companies, including Bilibili, Alibaba Group, JD.com, and Baidu, in order to decide which company to invest in for maximum short term gain.
From the historical stock price change plots, we can tell that there has been an increasing stock closing price trend for Bilibili, Alibaba, and JD.com. while Alibaba enjoys a stready growth trend, the closing price is the highest at $215, followed by JD.com at $60 and Bilibili at $45.
The third tab includes the monthly and quarterly returns comparsion for four companies in order to compare the short term gains. We can tell the return of four companies at the first quarter of 2020 dropped sharply because of the COVID-19 hit China. As a result, investors’ confidence towards Chinese companies decreased along with some financial scandals of some Chinese public companies. However, the Q2 of 2020 witnessed a growth return rate as Nasdaq stock exchanges released the tightening listing rule, which filters out the companies with bad performance.
In conclusion, Alibaba is the company I’d like to invest in. JD.com will be my second choice.
---
title: "Lab1-512"
author: "Zhuoxin Jiang"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
theme: readable
source_code: embed
---
```{r setup, include=FALSE}
library(flexdashboard)
library(tidyquant)
library(xts)
library(quantmod)
library(plyr)
library(dplyr)
library(yaml)
library(ggplot2)
```
Data Collection {data-icon="fa-database"}
=============================
Column {data-width=450}
-----------------------------------------------------------------------
### Objective
The objective of the dashboard is to purchase oje of the securities/commodities among four Chinese stocks (listed in the U.S.), which has the maximized profits with the short term goal. Four companies are Bilibili, Alibaba Group, JD.com, and Baidu.
{ width=50% }
{ width=50% }
{ width=50% }
{ width=50% }
Column {data-width=550}
-----------------------------------------------------------------------
### Key Indicator Analysis - Tabular View
```{r}
what_metrics <- yahooQF((c("Price/Sales",
"P/E Ratio",
"Price/EPS Estimate Next Year",
"PEG Ratio",
"Market Capitalization")))
tickers <- c("BILI","BABA","JD","BIDU")
metrics <- getQuote(paste(tickers, sep="", collapse=";"), what=what_metrics)
metrics <- data.frame(Symbol=tickers, metrics[,2:length(metrics)])
colnames(metrics) <- c("Symbol", "P-E Ratio", "Price EPS Estimate Next Year", "Market Cap")
# write.csv(metrics, "FinancialMetrics.csv", row.names=FALSE)
DT::datatable(metrics)
```
### Insights
P-E Ratio measures the relationship between the earnings of a company and its stock price, which can be interpreted that a high score may offer higher retunrs in the future.
Price EPS Estimate helps us understand the P-E ratio, which tells us whether a stock may or may not be a good value. The lower the number, the less you have to pay to get in on the company’s expected future earnings growth.
Based on the Key Indicator analysis, JD.com is my choice. However, it's not my final decision.
Stock Analysis {data-icon="fa-chart-line" data-orientation=rows}
=============================
Row {data-height = 180}
-----------------------------------------------------------------------
### BILI
```{r}
BILI_change <- getQuote("BILI", what = yahooQF(c("Change in Percent")))
valueBox(value = paste(round(BILI_change[2],digits=2),'%'), caption = "BILI Change", color = ifelse(BILI_change[2] > 0, "success", "warning"))
```
### BABA
```{R}
BABA_change <- getQuote("BABA", what = yahooQF(c("Change in Percent")))
valueBox(value = paste(round(BABA_change[2],digits=2),'%'), caption = "BABA Change", color = ifelse(BABA_change[2] > 0, "success", "warning"))
```
### JD
```{r}
JD_change <- getQuote("JD", what = yahooQF(c("Change in Percent")))
valueBox(value = paste(round(JD_change[2],digits=2),'%'), caption = "JD Change", color = ifelse(JD_change[2] > 0, "success", "warning"))
```
### BIDU
```{r}
BIDU_change <- getQuote("BIDU", what = yahooQF(c("Change in Percent")))
valueBox(value = paste(round(BIDU_change[2],digits=2),'%'), caption = "BIDU Change", color = ifelse(BIDU_change[2] > 0, "success", "warning"))
```
Row {.tabset}
-----------------------------------------------------------------------
```{r}
BILI <- tq_get("BILI", get = "stock.price", from = "2018-08-01", to = "2020-08-01")
BABA <- tq_get("BABA", get = "stock.price", from = "2018-08-01", to = "2020-08-01")
JD <- tq_get("JD", get = "stock.price", from = "2018-08-01", to = "2020-08-01")
BIDU <- tq_get("BIDU", get = "stock.price", from = "2018-08-01", to = "2020-08-01")
# Setup dates for zoom window
end <- ymd("2020-03-01")
start <- end - weeks(20)
transform <- function(table){
df <- data.frame(Open=table$open, High=table$high, Low=table$low, Close=table$close)
rownames(df) <- table$date
return(as.matrix(df))
}
BILI <- transform(BILI)
BABA <- transform(BABA)
JD <- transform(JD)
BIDU <- transform(BIDU)
```
### Bilibili-BILI
```{r}
library(dygraphs)
dygraph(BILI, ylab = "Stock Price ($)",group = "stockprices") %>%
dyCandlestick(compress = TRUE) %>%
dyRangeSelector()
```
### Alibaba-BABA
```{R}
dygraph(BABA, ylab = "Stock Price ($)",group = "stockprices") %>%
dyCandlestick(compress = TRUE) %>% dyRangeSelector()
```
### JD.com-JD
```{r}
dygraph(JD, ylab = "Stock Price ($)",group = "stockprices") %>%
dyCandlestick(compress = TRUE) %>%
dyRangeSelector()
```
### Baidu-BIDU
```{R}
dygraph(BIDU, ylab = "Stock Price ($)",group = "stockprices") %>%
dyCandlestick(compress = TRUE) %>%
dyRangeSelector()
```
Return Analysis {data-icon="fa-dollar-sign"}
=============================
Column {data-width=500}
-----------------------------------------------------------------------
### Monthly Return
```{R}
BILI_mreturn <- monthlyReturn(BILI)
BABA_mreturn <- monthlyReturn(BABA)
JD_mreturn <- monthlyReturn(JD)
BIDU_mreturn <- monthlyReturn(BIDU)
mreturn <- cbind(BILI_mreturn,BABA_mreturn,JD_mreturn,BIDU_mreturn)
colnames(mreturn) <- c("BILI","BABA","JD","BIDU")
dygraph(mreturn,
main = "Monthly Return",
ylab = "Return ($)",
) %>%
dyOptions(strokeWidth = 2,colors = RColorBrewer::brewer.pal(5, "Set2")) %>%
dyHighlight(highlightCircleSize = 3,
highlightSeriesBackgroundAlpha = 0.2,
hideOnMouseOut = TRUE) %>%
dyRangeSelector()
```
Column {data-width=500}
-----------------------------------------------------------------------
### Quarterly Return
```{r}
BILI_qreturn <- quarterlyReturn(BILI)
BABA_qreturn <- quarterlyReturn(BABA)
JD_qreturn <- quarterlyReturn(JD)
BIDU_qreturn <- quarterlyReturn(BIDU)
qreturn <- cbind(BILI_qreturn,BABA_qreturn,JD_qreturn,BIDU_qreturn)
colnames(qreturn) <- c("BILI","BABA","JD","BIDU")
dygraph(qreturn,
main = "Quarterly Return",
ylab = "Return ($)",
) %>%
dyOptions(strokeWidth = 2,colors = RColorBrewer::brewer.pal(5, "Set2")) %>%
dyHighlight(highlightCircleSize = 3,
highlightSeriesBackgroundAlpha = 0.2,
hideOnMouseOut = TRUE) %>%
dyRangeSelector()
```
Summary {data-icon="fa-book"}
=============================
Column
-----------------------------------------------------------------------
### Conclusion
The dashboard compares the stock prices and monthly/quarterly returns of 4 companies, including Bilibili, Alibaba Group, JD.com, and Baidu, in order to decide which company to invest in for maximum short term gain.
From the historical stock price change plots, we can tell that there has been an increasing stock closing price trend for Bilibili, Alibaba, and JD.com. while Alibaba enjoys a stready growth trend, the closing price is the highest at \$215, followed by JD.com at \$60 and Bilibili at \$45.
The third tab includes the monthly and quarterly returns comparsion for four companies in order to compare the short term gains. We can tell the return of four companies at the first quarter of 2020 dropped sharply because of the COVID-19 hit China. As a result, investors' confidence towards Chinese companies decreased along with some financial scandals of some Chinese public companies. However, the Q2 of 2020 witnessed a growth return rate as Nasdaq stock exchanges released the tightening listing rule, which filters out the companies with bad performance.
In conclusion, Alibaba is the company I'd like to invest in. JD.com will be my second choice.