Data source

10 years trading data of TESLA INC. were collected by me to to conduct some tests and comparison. I have collected the data through RStudio. First I had to call both the library quantmod and tidyverse in order get packages that need for the collection of database.The was collected by the package called getSymbols.yahoo. The was from 2011-01 to date 2020-12.

library(quantmod)
library(tidyverse)
fd<- '2011-01-01'
td<- '2020-12-30'
t<-getSymbols.yahoo('TSLA', from = fd, to= td, auto.assign=F)
tsla<- getSymbols.yahoo('TSLA', from = fd, to= td, auto.assign=F)[,6]

Exploratory Analysis

The downloaded data cosist detailes including closinng price, open, price, high, low, adjusted price of tesla’s stocks. The closing price is the data that keeps tracks about last traded prices whereas the open price is the price that was at the opening of the market. The highest price is the peak price of that stock at the particuar day and low is the other way around. the adjusted price is the price which is calculated through adjustment such as subtructing divident payout. # Mothly Returns ## Arithmatic

tslarets<- na.omit(monthlyReturn(tsla, type="arithmetic"))
mnthly<-periodReturn(tslarets, period = 'monthly', type='arithmetic')

Continous

geometric<-monthlyReturn(tsla, type = 'log')
geometric
##            monthly.returns
## 2011-01-31    -0.099450941
## 2011-02-28    -0.008751914
## 2011-03-31     0.149775693
## 2011-04-29    -0.005420062
## 2011-05-31     0.088037184
## 2011-06-30    -0.034084388
## 2011-07-29    -0.033510994
## 2011-08-31    -0.129836428
## 2011-09-30    -0.014247924
## 2011-10-31     0.185800476
##        ...                
## 2020-03-31    -0.242781458
## 2020-04-30     0.400209535
## 2020-05-29     0.065730500
## 2020-06-30     0.257108657
## 2020-07-31     0.281420674
## 2020-08-31     0.554719320
## 2020-09-30    -0.149762306
## 2020-10-30    -0.100371771
## 2020-11-30     0.380308519
## 2020-12-29     0.159857757

Quarterly Return

arithmetic

qtrly<- quarterlyReturn(tslarets, type = 'arithmetic')
qtrly
##            quarterly.returns
## 2011-03-31       -2.70678264
## 2011-06-30       -1.20739803
## 2011-09-30       -0.57783116
## 2011-12-30        8.02478051
## 2012-03-30       -1.89789448
## 2012-06-29       -0.47069491
## 2012-09-28       -0.56082457
## 2012-12-31       -0.94452895
## 2013-03-28       58.43388991
## 2013-06-28        0.11774319
## 2013-09-30        0.46844759
## 2013-12-31        0.26131218
## 2014-03-31       -1.81658956
## 2014-06-30       -2.04638249
## 2014-09-30       -1.64464245
## 2014-12-31       -0.09745287
## 2015-03-31       -0.20756746
## 2015-06-30       -1.97158518
## 2015-09-30       -1.03806526
## 2015-12-31      -16.97866030
## 2016-03-31        3.65609504
## 2016-06-30       -1.24880148
## 2016-09-30       -0.23266514
## 2016-12-30       -4.40722878
## 2017-03-31       -0.11698188
## 2017-06-30       -0.46656331
## 2017-09-29       -1.68838933
## 2017-12-29       -1.19465098
## 2018-03-29      -28.70351314
## 2018-06-29       -1.91182873
## 2018-09-28       -1.59807010
## 2018-12-31       -0.58749595
## 2019-03-29        1.48010877
## 2019-06-28       -2.65333822
## 2019-09-30       -0.67300217
## 2019-12-31        2.96069710
## 2020-03-31       -1.80462621
## 2020-06-30       -2.36012997
## 2020-09-30       -1.47440051
## 2020-12-29       -2.24629508

Continous

continous<- quarterlyReturn(tsla, type = 'log')
continous
##            quarterly.returns
## 2011-03-31        0.04157284
## 2011-06-30        0.04853273
## 2011-09-30       -0.17759535
## 2011-12-30        0.15783392
## 2012-03-30        0.26537641
## 2012-06-29       -0.17408503
## 2012-09-28       -0.06639384
## 2012-12-31        0.14562492
## 2013-03-28        0.11215761
## 2013-06-28        1.04150038
## 2013-09-30        0.58841778
## 2013-12-31       -0.25110746
## 2014-03-31        0.32620126
## 2014-06-30        0.14118968
## 2014-09-30        0.01085485
## 2014-12-31       -0.08722119
## 2015-03-31       -0.16399315
## 2015-06-30        0.35142732
## 2015-09-30       -0.07691639
## 2015-12-31       -0.03435967
## 2016-03-31       -0.04360185
## 2016-06-30       -0.07917261
## 2016-09-30       -0.03963913
## 2016-12-30        0.04625933
## 2017-03-31        0.26417328
## 2017-06-30        0.26186657
## 2017-09-29       -0.05839056
## 2017-12-29       -0.09125802
## 2018-03-29       -0.15693271
## 2018-06-29        0.25359969
## 2018-09-28       -0.25872314
## 2018-12-31        0.22868020
## 2019-03-29       -0.17325222
## 2019-06-28       -0.22505707
## 2019-09-30        0.07502499
## 2019-12-31        0.55201317
## 2020-03-31        0.22522114
## 2020-06-30        0.72304869
## 2020-09-30        0.68637769
## 2020-12-29        0.43979451

#Yearly return ## Arithmetic

yearlya<- yearlyReturn(tsla, type = 'arithmetic')
yearlya
##            yearly.returns
## 2011-12-30     0.07287734
## 2012-12-31     0.18592429
## 2013-12-31     3.44139411
## 2014-12-31     0.47849488
## 2015-12-31     0.07913319
## 2016-12-30    -0.10966213
## 2017-12-29     0.45701711
## 2018-12-31     0.06889354
## 2019-12-31     0.25700119
## 2020-12-29     6.96010366

Continous

yearlyg<-yearlyReturn(tsla, type = 'log')
yearlyg
##            yearly.returns
## 2011-12-30     0.07034415
## 2012-12-31     0.17052246
## 2013-12-31     1.49096832
## 2014-12-31     0.39102460
## 2015-12-31     0.07615811
## 2016-12-30    -0.11615426
## 2017-12-29     0.37639127
## 2018-12-31     0.06662404
## 2019-12-31     0.22872888
## 2020-12-29     2.07444202

Ploting the monthly return

tsla_A_returns<- ggplot(mnthly, aes(x=mnthly))+
                  geom_histogram(bins = 120)+geom_density()+geom_rug()
tsla_A_returns

tsla_C_returns<- ggplot(geometric, aes(x=geometric))+
                  geom_histogram(bins = 120)+geom_density()+geom_rug()
tsla_C_returns

# comparing both returns Both histogram shows the distribution of stocks. The first one which arithmetic shows that the distribution is normal and is right skewed which means the return is positive. Though the return is not that high but still countable. On the other hand the second graph shows that the distribution is still right skewed but is much more clear than the other one which is good. the return is terms of the first one is not clearly visible is because it has out lire which made the distribution much more stretched. But in-terms of the second graph which is the continuous return the distribution is less stretched which makes the graph more readable.

Plotting 10 years of discret/arithmetic reutrn

chartSeries(t)

addSMA(n=60)

addRSI(100)

addVolatility()

Here the Daily return are plotted into the graph which shows it was stable until the year 2019 and got uplifted after that which was probably due Covid 19 the market was not normal. The SMA(simple Moving Average) shows that return fluctuated a little until 2019 and after that it fluctuated too much the reason can be same due to Covid-19. The volatility on the other hand have positive correlation with the volume which indicates the higher the volume traded the higher the volatility. The RSI looks normal though it indicates that the stock was nearly oversold in the year 2019-2020. But moved to previous state after a whike.