Part 1: Trading Data of NVDA (One US Stock)

start <- as.Date('2014-01-02')
end <- as.Date('2023-12-29')
nvda<-getSymbols('NVDA', from = start, to = end)

Part 2: Arithmetic and Geometric returns of NVDA

Arithmetic return of NVDA

Monthly returns of NVDA

nvda.monthly.ar <- periodReturn(NVDA[,'NVDA.Adjusted'], period='monthly', type='arithmetic')
nvda.monthly.ar*100
##            monthly.returns
## 2014-01-31      -1.0088221
## 2014-02-28      17.5987250
## 2014-03-31      -2.5571613
## 2014-04-30       3.1267380
## 2014-05-30       3.3433028
## 2014-06-30      -2.4210422
## 2014-07-31      -5.6094855
## 2014-08-29      11.6344949
## 2014-09-30      -5.1413943
## 2014-10-31       5.9078501
##        ...                
## 2023-03-31      19.6662462
## 2023-04-28      -0.1007908
## 2023-05-31      36.3436491
## 2023-06-30      11.8210477
## 2023-07-31      10.4652391
## 2023-08-31       5.6196246
## 2023-09-29     -11.8577972
## 2023-10-31      -6.2507201
## 2023-11-30      14.6885844
## 2023-12-28       5.8934209

Quarterly returns of NVDA

nvda.quarterly.ar <- periodReturn(NVDA[,'NVDA.Adjusted'], period='quarterly', type='arithmetic')
nvda.quarterly.ar*100
##            quarterly.returns
## 2014-03-31       13.43551115
## 2014-06-30        3.99436171
## 2014-09-30       -0.04523508
## 2014-12-31        9.13202200
## 2015-03-31        4.79092469
## 2015-06-30       -3.47307915
## 2015-09-30       23.09158053
## 2015-12-31       34.21970975
## 2016-03-31        8.49458216
## 2016-06-30       32.28200870
## 2016-09-30       46.02472903
## 2016-12-30       56.01266163
## 2017-03-31        2.18049865
## 2017-06-30       32.84881130
## 2017-09-29       23.77384469
## 2017-12-29        8.31483717
## 2018-03-29       19.75913031
## 2018-06-29        2.35607967
## 2018-09-28       18.68877618
## 2018-12-31      -52.44694148
## 2019-03-29       34.64049118
## 2019-06-28       -8.43312963
## 2019-09-30        6.09649485
## 2019-12-31       35.27524154
## 2020-03-31       12.09423826
## 2020-06-30       44.18940085
## 2020-09-30       42.50268530
## 2020-12-31       -3.48576158
## 2021-03-31        2.28154918
## 2021-06-30       49.88544632
## 2021-09-30        3.58529481
## 2021-12-31       41.98977370
## 2022-03-31       -7.20938062
## 2022-06-30      -44.43228860
## 2022-09-30      -19.89835797
## 2022-12-30       20.41962493
## 2023-03-31       90.10343336
## 2023-06-30       52.30723038
## 2023-09-29        2.83812659
## 2023-12-28       13.85631179

Yearly returns of NVDA

nvda.yearly.ar <- periodReturn(NVDA[,'NVDA.Adjusted'], period='yearly', type='arithmetic')
nvda.yearly.ar*100
##            yearly.returns
## 2014-12-31       28.68103
## 2015-12-31       67.11551
## 2016-12-30      226.96035
## 2017-12-29       81.98790
## 2018-12-31      -30.81525
## 2019-12-31       76.94301
## 2020-12-31      122.29570
## 2021-12-31      125.48203
## 2022-12-30      -50.26464
## 2023-12-28      239.01721

Geometric Returns of NVDA

Monthly returns of NVDA

nvda.monthly.gr <- periodReturn(NVDA[,'NVDA.Adjusted'], period='monthly', type='log')
nvda.monthly.gr*100
##            monthly.returns
## 2014-01-31      -1.0139452
## 2014-02-28      16.2108008
## 2014-03-31      -2.5904250
## 2014-04-30       3.0788512
## 2014-05-30       3.2886297
## 2014-06-30      -2.4508312
## 2014-07-31      -5.7729600
## 2014-08-29      11.0059910
## 2014-09-30      -5.2782764
## 2014-10-31       5.7399192
##        ...                
## 2023-03-31      17.9536400
## 2023-04-28      -0.1008416
## 2023-05-31      31.0008344
## 2023-06-30      11.1729619
## 2023-07-31       9.9530707
## 2023-08-31       5.4674007
## 2023-09-29     -12.6218735
## 2023-10-31      -6.4546202
## 2023-11-30      13.7050308
## 2023-12-28       5.7262939

Quarterly returns of NVDA

nvda.quarterly.gr <- periodReturn(NVDA[,'NVDA.Adjusted'], period='quarterly', type='log')
nvda.quarterly.gr*100
##            quarterly.returns
## 2014-03-31       12.60643057
## 2014-06-30        3.91664974
## 2014-09-30       -0.04524532
## 2014-12-31        8.73881744
## 2015-03-31        4.67969857
## 2015-06-30       -3.53482440
## 2015-09-30       20.77584495
## 2015-12-31       29.43078962
## 2016-03-31        8.15300517
## 2016-06-30       27.97658872
## 2016-09-30       37.86057983
## 2016-12-30       44.47669823
## 2017-03-31        2.15706581
## 2017-06-30       28.40415385
## 2017-09-29       21.32858813
## 2017-12-29        7.98719592
## 2018-03-29       18.03122921
## 2018-06-29        2.32875251
## 2018-09-28       17.13345549
## 2018-12-31      -74.33240768
## 2019-03-29       29.74380120
## 2019-06-28       -8.81006569
## 2019-09-30        5.91788228
## 2019-12-31       30.21413431
## 2020-03-31       11.41697446
## 2020-06-30       36.59575331
## 2020-09-30       35.41906578
## 2020-12-31       -3.54796401
## 2021-03-31        2.25591108
## 2021-06-30       40.47011251
## 2021-09-30        3.52251917
## 2021-12-31       35.05848528
## 2022-03-31       -7.48246356
## 2022-06-30      -58.75678837
## 2022-09-30      -22.18738324
## 2022-12-30       18.58123314
## 2023-03-31       64.23981241
## 2023-06-30       42.07295474
## 2023-09-29        2.79859795
## 2023-12-28       12.97670445

Yearly returns of NVDA

nvda.yearly.gr <- periodReturn(NVDA[,'NVDA.Adjusted'], period='yearly', type='log')
nvda.yearly.gr*100
##            yearly.returns
## 2014-12-31       25.21665
## 2015-12-31       51.35151
## 2016-12-30      118.46687
## 2017-12-29       59.87700
## 2018-12-31      -36.83897
## 2019-12-31       57.06575
## 2020-12-31       79.88383
## 2021-12-31       81.30703
## 2022-12-30      -69.84540
## 2023-12-28      122.08807

plot of both returns

par(mfrow=c(2,1))
plot(nvda.monthly.ar)
plot(nvda.monthly.gr)

plot(nvda.quarterly.ar)
plot(nvda.quarterly.gr)

plot(nvda.yearly.ar)
plot(nvda.yearly.gr)

Interpret:

  1. Arithmetic Return (AR): A simple way to measure overall investment gain. It’s calculated as the difference between the ending and starting prices divided by the starting price.

  2. “Geometric Return (GR): Reflects the average annual return earned over the investment period. It considers the compounding effect of reinvesting returns. GR represents the average annual growth rate. In AR shows total growth, while GR reflects average annual growth considering reinvestment.”

Part 3: Plot and compare between Ar & GR

par(mfrow=c(1,2))
nvda.hist1 <- hist(nvda.monthly.ar, main='Arithmetic Monthly returns', breaks = 40)
nvda.hist2 <- hist(nvda.monthly.gr, main='Geometric Monthly returns', breaks = 40)

Interpret:

Based on the graph shows that, arithmetic monthly returns tend to be higher than geometric monthly returns, and geometric returns tend to be lower than arithmetic returns. This is because the arithmetic return simply takes the average of the monthly returns, while the geometric return considers the compounding effect of those returns.

Part 4: Chartseries to plot discrete returns

nvda.xts <- Ad(get(nvda))
chartSeries(nvda.xts, theme = chartTheme("black"))

Part 5: Plotting 3 technical analysis indicators and explaination

nvda.xts %>%
  chartSeries(TA='addBBands();
                  addRSI();
                  addMACD()',
              theme="black" )

Interpret:

BOLLINGER BANDS:

Bollinger Bands are a technical analysis tool used in financial markets to assess price volatility and identify potential buy or sell signals. It can be used to identify a number of different trading signals, including:

  1. Overbought and oversold conditions: When the price of a security moves close to the upper band, it may be an indication that the security is overbought and may be due for a pullback.When the price of a security moves close to the lower band, it may be an indication that the security is oversold and may be due for a rally.

  2. Breakouts: When the price of a security breaks above the upper band or below the lower band, it may be an indication that a new trend is beginning.

  3. Volatility: The width of the Bollinger Bands can be used to gauge the volatility of a security. Wider bands indicate higher volatility, while narrower bands indicate lower volatility.

RSI

RSI stands for Relative Strength Index. It’s another technical analysis tool used to measure the price momentum of a security and gauge whether it’s overbought or oversold. It calculates the speed and magnitude of recent price changes to assess if a security is overvalued or undervalued.The RSI is a single line indicator that oscillates between 0 and 100.Including:

  1. Overbought: Traditionally, an RSI above 70 indicates an overbought condition, suggesting the price may be due for a correction (price goes down).

  2. Oversold: Conversely, an RSI below 30 suggests an oversold condition, potentially indicating a buying opportunity.

  3. Neutral: The zone between 30 and 70 is considered neutral, where the RSI doesn’t necessarily signal a strong buy or sell. RSI can also be used to identify trends. Generally, during an uptrend, the RSI stays above 30 and frequently reaches 70. In a downtrend, the RSI stays below 70 and often dips below 30.

MACD

MACD stands for Moving Average Convergence Divergence. It’s a widely used technical analysis indicator designed.MACD helps visualize the direction and strength of a trend in the market. It gauges how rapidly the price is moving, indicating if the trend is strengthening or weakening.By analyzing the interactions between the MACD lines and other elements, traders can identify possible buying and selling opportunities.Including:

  1. Crossovers: When the MACD line crosses above the signal line, it might indicate a bullish signal. Conversely, a crossover below the signal line could suggest a bearish signal.

  2. Divergence: Sometimes, the price movement might diverge from the MACD’s movement. For instance, if the price keeps rising but the MACD starts to decline, it could be a sign that the uptrend might be weakening.

  3. Focuses on momentum: MACD is primarily a momentum indicator and may not necessarily identify overbought or oversold conditions.