The stock price of AliBaba has grown intriguingly over time. With this model, I will compare moving averages of historical data to predict the stock price of BABA after 7 years, i.e. the Market Price of BABA in 2026. Step 1: Taking the Market Price for BABA from 2014-01-01 to 2019-02-01, create a time series and calculate the mean and standard deviation of the market price. Step 2: Use Technical Analysis tools such as Bollinger Bands and Moving Averages to analyze the stock outcomes. Step 3: Use the price data to determine the mean and standard deviation of the log return of the stock. Step 4: Create a Probability Distribution Function in order to calculate the probability of return in each quantile. Step 5:Use the mean log return to extraplote prices for the next 7 years using Random Walk.
DATA SET:
Using the data directly from the Yahoo Finance page to make calculations. Use the quantmod package to directly input data from Yahoo Finance into R. The data is collected from 1/1/17 to 17/10/18.
getSymbols("BABA", from = "2014-01-01", to = "2019-02-10")
## 'getSymbols' currently uses auto.assign=TRUE by default, but will
## use auto.assign=FALSE in 0.5-0. You will still be able to use
## 'loadSymbols' to automatically load data. getOption("getSymbols.env")
## and getOption("getSymbols.auto.assign") will still be checked for
## alternate defaults.
##
## This message is shown once per session and may be disabled by setting
## options("getSymbols.warning4.0"=FALSE). See ?getSymbols for details.
##
## WARNING: There have been significant changes to Yahoo Finance data.
## Please see the Warning section of '?getSymbols.yahoo' for details.
##
## This message is shown once per session and may be disabled by setting
## options("getSymbols.yahoo.warning"=FALSE).
## [1] "BABA"
summary(BABA$BABA.Open)
## Index BABA.Open
## Min. :2014-09-19 Min. : 57.30
## 1st Qu.:2015-10-23 1st Qu.: 83.34
## Median :2016-11-28 Median :103.84
## Mean :2016-11-28 Mean :120.59
## 3rd Qu.:2018-01-03 3rd Qu.:165.36
## Max. :2019-02-08 Max. :209.95
str(BABA)
## An 'xts' object on 2014-09-19/2019-02-08 containing:
## Data: num [1:1105, 1:6] 92.7 92.7 88.9 88.5 91.1 ...
## - attr(*, "dimnames")=List of 2
## ..$ : NULL
## ..$ : chr [1:6] "BABA.Open" "BABA.High" "BABA.Low" "BABA.Close" ...
## Indexed by objects of class: [Date] TZ: UTC
## xts Attributes:
## List of 2
## $ src : chr "yahoo"
## $ updated: POSIXct[1:1], format: "2019-02-11 04:30:19"
The graph below shows us the Market Price of BABA stock price from 01/01/14 to 02/01/19. As we can see, BABA has seen a steady increase in price, showing a bullish trend along the years. However as of recent there was a steep drop in market price and growth has been slower ever since.
ggplot(data = BABA, aes(x = Index, y = BABA.Open)) +
geom_line(color = "#D12803", size = 1) + labs(title = "Graph #1 - Alibaba (BABA) price trend since IPO")
This next graph shows us the trend in Market Price of BABA in 2018, along with other Technical Indicators such as Bollinger Bands, Volume Graphs and Moving Averages.
BABA %>% chartSeries(TA = "addBBands();
addBBands(draw=\"p\");
addVo();
addMACD()",
subset = "2018", theme = "white")
Using Market price data for BABA from 1/1/14 to 02/01/19, we calculate the Percentage return of the stock in natural log form.
Since Log price scales adjust prices based on percentage change rather than magnitude.
In the graph below, we create a histogram, with 100 bins. From the graph below, we can tell that the Percentage log return of TSLA stock is crowded around 1%, however further analysis needs to be done to find out the potential return.
BABA_log_returns <- BABA$BABA.Open %>% dailyReturn(type = "log")
names(BABA_log_returns) <- "BABA.Log.Returns"
BABA_log_returns %>% exp() %>% ggplot(aes(x = BABA.Log.Returns)) +
geom_histogram(bins = 100) + geom_density() + geom_rug(alpha = 0.5) +
labs(title = "Graph #3 - Alibaba Log Returns")
The graph shows that the return can be approximated to a normal distribution. We know this because on calculating the mean and median for the BABA log returns, the results is the same (0.1)
Now we create a quantile in order to represent the daily rate of return in another format. From the Quantiles below we can find the probability of the Log return at Each Quantile.
probs <- c(0.25, 0.5, 0.75)
dist_log_returns <- BABA_log_returns %>% exp() %>%
quantile(probs = probs, na.rm = TRUE)
dist_log_returns
## 25% 50% 75%
## 0.9885137 1.0003446 1.0125937
The median return per day of Alibaba stock is 1.00034%