A stock (also known as equity) is a security that represents the ownership of a fraction of a corporation. This entitles the owner of the stock to a proportion of the corporation’s assets and profits equal to how much stock they own. Units of stock are called “shares.”
The stock market refers to the collection of markets and exchanges where regular activities of buying, selling, and issuance of shares aka stocks of publicly-held companies take place. Such financial activities are conducted through institutionalized formal exchanges or over-the-counter (OTC) marketplaces which operate under a defined set of regulations. https://www.investopedia.com/
Tesla, Inc. is an American electric vehicle and clean energy company based in Palo Alto, California. Tesla’s current products include electric cars, battery energy storage from home to grid scale, solar panels and solar roof tiles, as well as other related products and services. Tesla is ranked as the world’s best-selling plug-in and battery electric passenger car manufacturer. https://en.wikipedia.org/wiki/Tesla,_Inc.
OBJECTIVE: This analysis aims to look at the historical performance of TESLA (TSLA) in the stock market. We will also attempt to give a statistical forecast of Tesla’s closing price for the next 30 days. Please take note that the recommendation coming out from this analysis does not represent the overall performance of the stock but personal observation and analysis subject to your own due deligence.
DATA RETRIEVAL AND STRUCTURE
We will be using R packages that specializes in market analysis such as quantmod, rugarch, performance analytics and xts. Run other relevant libraries as well
library(quantmod)
library(PerformanceAnalytics)
library(rugarch)
library(xts)
getSymbols("TSLA",from="2020-01-01")
㤼㸱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.
[1] "TSLA"
chartSeries(TSLA)
Looking at the chart, TESLA has been performing really well and have increased its value as much as 4 times for the last 15 months.
tesla <- TSLA
str(tesla)
An ‘xts’ object on 2020-01-02/2021-04-01 containing:
Data: num [1:315, 1:6] 84.9 88.1 88.1 92.3 94.7 ...
- attr(*, "dimnames")=List of 2
..$ : NULL
..$ : chr [1:6] "TSLA.Open" "TSLA.High" "TSLA.Low" "TSLA.Close" ...
Indexed by objects of class: [Date] TZ: UTC
xts Attributes:
List of 2
$ src : chr "yahoo"
$ updated: POSIXct[1:1], format: "2021-04-03 11:17:27"
OPEN: Opening price of the day
HIGH: Highest price of the day
LOW: Lowest price of the day
CLOSE: Closing price of the day
VOLUME: Total Volume to traded shares of the day
ADJUSTED: Adjusted price of the day
For this analysis and forecast we will be focusing on the closing price only
return <- CalculateReturns(TSLA$TSLA.Close)
return <- return[-1]
head(return)
TSLA.Close
2020-01-03 0.029633186
2020-01-06 0.019254668
2020-01-07 0.038800516
2020-01-08 0.049204848
2020-01-09 -0.021945005
2020-01-10 -0.006627343
We created an object “return” as a ratio of the closing prices. This will be the basis of our analysis
hist(return, main = "TESLA Returns Jan 2020 - Apr 1, 2021")
mean(return)
[1] 0.008002769
The average daily return over 15 months is normally distributed at 0.8%
chart.Histogram(return,
methods = c("add.density", "add.normal", "add.risk"),
colorset = c("blue","green","red"))
1-pnorm(0.1,mean(return),sd(return))
[1] 0.04603278
4.6% of the distribution observed has 10% returns
1-pnorm(0.05,mean(return),sd(return))
[1] 0.2209379
22% of the distribution observed has 5% returns
RISK MANAGEMENT (example)
risk <- qnorm(0.05, mean(return),sd(return))
risk
[1] -0.08182383
RISK demarcation at 5% is -0.0818 returns.
Sample Risk Management for Closing Price (Today vs Yesterday) as a function of Returns
Close_yest <- 661.75 #Closing price of April 1
Close_Today <- Close_yest/(1-risk)
Close_Today # Price Risk consideration for April 2 or next trading day
[1] 611.6985
We are looking at Closing Price today (April 2) of 611.7 for risk consideration.
summary(return)
Index TSLA.Close
Min. :2020-01-03 Min. :-0.210628
1st Qu.:2020-04-27 1st Qu.:-0.020617
Median :2020-08-17 Median : 0.003868
Mean :2020-08-17 Mean : 0.008003
3rd Qu.:2020-12-07 3rd Qu.: 0.036865
Max. :2021-04-01 Max. : 0.198949
Statistical summary that of the normal distribution chart above.
VOLATILITY
Volatility is a statistical measure of the dispersion of returns for a given security or market index. In most cases, the higher the volatility, the riskier the security https://www.investopedia.com/terms/v/volatility.asp
sd(return)
[1] 0.05461069
return_volatility <- return
chartSeries(return_volatility, theme = "white",)
Tesla’s Volatility over 15months is 5.5% with peaks as high as 20%
You can cross check economic or company news that could have caused those major volatility peaks.
chart.RollingPerformance(R=return["2020::2021"],
width = 22,
FUN = "sd.annualized",
scale = 252,
main = "TESLA Volatiliy by month")
Looking at volatility consolidated by month, what could have caused the peaks? Checking for economic and company indicators will let you know how it affects TESLA’s performance over time.
STAN GDARDARCH MODEL with constant mean
s <- ugarchspec(mean.model = list(armaOrder = c(0,0)),
variance.model = list(model = "sGARCH"),
distribution.model = "norm")
m <- ugarchfit(data = return, spec = s)
plot(m)
Make a plot selection (or 0 to exit):
1: Series with 2 Conditional SD Superimposed
2: Series with 1% VaR Limits
3: Conditional SD (vs |returns|)
4: ACF of Observations
5: ACF of Squared Observations
6: ACF of Absolute Observations
7: Cross Correlation
8: Empirical Density of Standardized Residuals
9: QQ-Plot of Standardized Residuals
10: ACF of Standardized Residuals
11: ACF of Squared Standardized Residuals
12: News-Impact Curve
12
Make a plot selection (or 0 to exit):
1: Series with 2 Conditional SD Superimposed
2: Series with 1% VaR Limits
3: Conditional SD (vs |returns|)
4: ACF of Observations
5: ACF of Squared Observations
6: ACF of Absolute Observations
7: Cross Correlation
8: Empirical Density of Standardized Residuals
9: QQ-Plot of Standardized Residuals
10: ACF of Standardized Residuals
11: ACF of Squared Standardized Residuals
12: News-Impact Curve
0
The symmetrical shape of our News impact curve shows that news accounts for the positive or negative impact on the returns.
TESLA FORECAST for the next 10 days
f <- ugarchforecast(fitORspec = m,
n.ahead = 10)
f
*------------------------------------*
* GARCH Model Forecast *
*------------------------------------*
Model: sGARCH
Horizon: 10
Roll Steps: 0
Out of Sample: 0
0-roll forecast [T0=2021-04-01]:
Series Sigma
T+1 0.008615 0.04226
T+2 0.008615 0.04414
T+3 0.008615 0.04576
T+4 0.008615 0.04719
T+5 0.008615 0.04844
T+6 0.008615 0.04954
T+7 0.008615 0.05051
T+8 0.008615 0.05138
T+9 0.008615 0.05215
T+10 0.008615 0.05284
SUMMARY Forecast Estimated daily returns of 0.008615 or 0.8% with daily deviation at sigma.
SAMPLE Computation
Close_yest <- 661.75 #Closing price of April 1
Close_Today <- Close_yest/(1-0.008)
Close_Today # Price profit consideration for April 2 or next trading day
[1] 667.0867
Close_yest <- 661.75 #Closing price of April 1
return_withsigma <- 0.008 + 0.04225 #plus max sigma
Close_Today <- Close_yest/(1-return_withsigma)
Close_Today # Price max profit consideration for April 2 or next trading day
[1] 696.7623
BUY at 661.75 and close trade at A Next day Closing Price between 667 - 696 would be considered within safe statistical estimates.
Close_yest <- 661.75 #Closing price of April 1, BUY
return_withsigma <- 0.008 - 0.04225 #plus max sigma
Close_Today <- Close_yest/(1-return_withsigma)
Close_Today # Price max profit consideration for April 2 or next trading day
[1] 639.8356
SELL at 661.75 and close trade at A Next day Closing Price between 667 - 640 would be considered within safe statistical estimates.
Reminder: The market can change any time. Any news or events could impact the outcome of of the market sentiment and price action. Due diligence is necessary for consideration.
Prepared by Dodgecarl Incila
Special Thanks to Dr. Bharatendra Rai
#Tesla