amcl<-read.csv("AMCL.csv")
amcl
start <- as.Date('2014-01-01')
end <- as.Date('2023-12-31')
amcl<-getSymbols('AMCL', from = start, to = end)
amcl.monthly.ar <- periodReturn(AMCL[,'AMCL.Adjusted'], period='monthly', type='arithmetic')
amcl.monthly.ar*100
## monthly.returns
## 2014-01-31 -0.30074729
## 2014-02-28 0.30165451
## 2014-03-31 -0.01504081
## 2014-04-30 -0.06016080
## 2014-05-30 -0.24077658
## 2014-06-30 0.00000000
## 2014-07-31 0.01508845
## 2014-08-29 -0.07541938
## 2014-09-30 -0.07547630
## 2014-10-31 -0.04531538
## 2014-11-28 0.19647104
## 2014-12-31 0.15082725
## 2015-01-30 0.52710612
## 2015-02-27 0.10486846
## 2015-03-31 0.14965351
## 2015-04-30 0.13449487
## 2015-05-29 0.05969395
## 2015-06-30 0.29828030
## 2015-07-31 0.00000000
## 2015-08-31 0.00000000
## 2015-09-30 0.01487307
## 2015-10-30 -0.34196157
## 2015-11-30 -0.05967614
## 2015-12-31 -0.53739457
## 2016-01-29 -0.57030957
## 2016-02-29 -2.27924851
## 2016-03-31 -2.68767056
## 2016-04-29 -0.03174676
## 2016-05-31 -0.79390283
## 2016-06-30 -0.08002439
## 2016-07-29 -0.68877191
## 2016-08-31 1.11290101
## 2016-09-30 0.01595492
## 2016-10-31 -0.03189866
## 2016-11-30 5.88704918
## 2016-12-30 0.19586748
## 2017-01-31 -0.99248671
## 2017-02-28 0.92648944
## 2017-03-31 -0.03009277
## 2017-04-28 0.10537362
## 2017-05-31 -0.75187970
## 2017-06-30 0.01515475
## 2017-07-31 -0.01515246
## 2017-08-31 0.00000000
## 2017-09-29 -0.31818043
## 2017-10-31 -4.24076741
## 2017-11-30 0.04761711
## 2017-12-29 -0.06345725
## 2018-01-31 -4.74678774
## 2018-02-28 0.00000000
## 2018-03-29 0.00000000
## 2018-04-30 -0.34999847
## 2018-05-31 -1.32129270
## 2018-06-29 -1.69491525
## 2018-07-31 -4.89655199
## 2018-08-31 1.52284292
## 2018-09-28 0.00000000
## 2018-10-31 -0.89285714
## 2018-11-30 -0.90090090
## 2018-12-31 0.00000000
## 2019-01-31 0.43636669
## 2019-02-28 -0.43447080
## 2019-03-29 0.43636669
## 2019-04-30 1.26719212
## 2019-05-31 -1.25133530
## 2019-06-28 -0.10861943
## 2019-07-31 0.36245154
## 2019-08-30 -0.32502763
## 2019-09-30 -0.36232022
## 2019-10-31 -0.16363664
## 2019-11-29 -1.67546562
## 2019-12-31 2.24115400
## 2020-01-31 0.30796769
## 2020-02-28 0.32508634
## 2020-03-31 -1.29612496
## 2020-04-30 -0.62009874
## 2020-05-29 0.01834891
## 2020-06-30 -8.23853519
## 2020-07-31 -0.01999265
## 2020-08-31 3.80000305
## 2020-09-30 2.11945750
## 2020-10-30 -5.67924212
## 2020-11-30 3.20063697
## 2020-12-31 3.70226757
## 2021-01-29 2.80373832
## 2021-02-26 -3.63636364
## 2021-03-31 1.88679245
## 2021-04-30 3.01852050
## 2021-05-28 2.01330022
## 2021-06-30 0.44052863
## 2021-07-30 3.50877193
## 2021-08-31 -0.01694631
## 2021-09-30 -3.15307774
## 2021-10-29 2.17048458
## 2021-11-30 2.75826733
## 2021-12-31 -0.81693542
## 2022-01-31 -0.82367064
## 2022-02-25 -2.54237288
## 2022-03-02 -0.24347720
amcl.quarterly.ar <- periodReturn(AMCL[,'AMCL.Adjusted'], period='quarterly', type='arithmetic')
amcl.quarterly.ar*100
## quarterly.returns
## 2014-03-31 -0.01504081
## 2014-06-30 -0.30079253
## 2014-09-30 -0.13577307
## 2014-12-31 0.30212173
## 2015-03-31 0.78312746
## 2015-06-30 0.49312887
## 2015-09-30 0.01487307
## 2015-12-31 -0.93667092
## 2016-03-31 -5.44799250
## 2016-06-30 -0.90476142
## 2016-09-30 0.43248511
## 2016-12-30 6.06060477
## 2017-03-31 -0.10526270
## 2017-06-30 -0.63224171
## 2017-09-29 -0.33328467
## 2017-12-29 -4.25596473
## 2018-03-29 -4.74678774
## 2018-06-29 -3.33333333
## 2018-09-28 -3.44827586
## 2018-12-31 -1.78571429
## 2019-03-29 0.43636669
## 2019-06-28 -0.10861943
## 2019-09-30 -0.32620570
## 2019-12-31 0.36363775
## 2020-03-31 -0.67028791
## 2020-06-30 -8.79081406
## 2020-09-30 5.97880780
## 2020-12-31 0.94339623
## 2021-03-31 0.93457944
## 2021-06-30 5.55555556
## 2021-09-30 0.22807205
## 2021-12-31 4.13093045
## 2022-03-02 -3.58043538
amcl.yearly.ar <- periodReturn(AMCL[,'AMCL.Adjusted'], period='yearly', type='arithmetic')
amcl.yearly.ar*100
## yearly.returns
## 2014-12-31 -0.1503736
## 2015-12-31 0.3463791
## 2016-12-30 -0.1951032
## 2017-12-29 -5.2781930
## 2018-12-31 -12.6845554
## 2019-12-31 0.3636378
## 2020-12-31 -3.0797115
## 2021-12-31 11.1962648
## 2022-03-02 -3.5804354
amcl.monthly.gr <- periodReturn(AMCL[,'AMCL.Adjusted'], period='monthly', type='log')
amcl.monthly.gr*100
## monthly.returns
## 2014-01-31 -0.30120044
## 2014-02-28 0.30120044
## 2014-03-31 -0.01504194
## 2014-04-30 -0.06017891
## 2014-05-30 -0.24106692
## 2014-06-30 0.00000000
## 2014-07-31 0.01508732
## 2014-08-29 -0.07544784
## 2014-09-30 -0.07550480
## 2014-10-31 -0.04532565
## 2014-11-28 0.19627829
## 2014-12-31 0.15071362
## 2015-01-30 0.52572178
## 2015-02-27 0.10481351
## 2015-03-31 0.14954164
## 2015-04-30 0.13440451
## 2015-05-29 0.05967614
## 2015-06-30 0.29783632
## 2015-07-31 0.00000000
## 2015-08-31 0.00000000
## 2015-09-30 0.01487196
## 2015-10-30 -0.34254759
## 2015-11-30 -0.05969395
## 2015-12-31 -0.53884373
## 2016-01-29 -0.57194205
## 2016-02-29 -2.30562494
## 2016-03-31 -2.72444891
## 2016-04-29 -0.03175180
## 2016-05-31 -0.79707102
## 2016-06-30 -0.08005642
## 2016-07-29 -0.69115489
## 2016-08-31 1.10675383
## 2016-09-30 0.01595364
## 2016-10-31 -0.03190375
## 2016-11-30 5.72027662
## 2016-12-30 0.19567591
## 2017-01-31 -0.99744469
## 2017-02-28 0.92222385
## 2017-03-31 -0.03009730
## 2017-04-28 0.10531814
## 2017-05-31 -0.75472056
## 2017-06-30 0.01515360
## 2017-07-31 -0.01515360
## 2017-08-31 0.00000000
## 2017-09-29 -0.31868770
## 2017-10-31 -4.33331386
## 2017-11-30 0.04760578
## 2017-12-29 -0.06347739
## 2018-01-31 -4.86314481
## 2018-02-28 0.00000000
## 2018-03-29 0.00000000
## 2018-04-30 -0.35061240
## 2018-05-31 -1.33009943
## 2018-06-29 -1.70944334
## 2018-07-31 -5.02049604
## 2018-08-31 1.51136406
## 2018-09-28 0.00000000
## 2018-10-31 -0.89686700
## 2018-11-30 -0.90498355
## 2018-12-31 0.00000000
## 2019-01-31 0.43541737
## 2019-02-28 -0.43541737
## 2019-03-29 0.43541737
## 2019-04-30 1.25923043
## 2019-05-31 -1.25923043
## 2019-06-28 -0.10867846
## 2019-07-31 0.36179627
## 2019-08-30 -0.32555699
## 2019-09-30 -0.36297819
## 2019-10-31 -0.16377067
## 2019-11-29 -1.68966032
## 2019-12-31 2.21640918
## 2020-01-31 0.30749444
## 2020-02-28 0.32455908
## 2020-03-31 -1.30459795
## 2020-04-30 -0.62202934
## 2020-05-29 0.01834723
## 2020-06-30 -8.59777498
## 2020-07-31 -0.01999464
## 2020-08-31 3.72958141
## 2020-09-30 2.09730940
## 2020-10-30 -5.84688946
## 2020-11-30 3.15048392
## 2020-12-31 3.63537957
## 2021-01-29 2.76515313
## 2021-02-26 -3.70412717
## 2021-03-31 1.86921330
## 2021-04-30 2.97385967
## 2021-05-28 1.99330131
## 2021-06-30 0.43956115
## 2021-07-30 3.44861761
## 2021-08-31 -0.01694774
## 2021-09-30 -3.20385750
## 2021-10-29 2.14726495
## 2021-11-30 2.72091248
## 2021-12-31 -0.82029063
## 2022-01-31 -0.82708155
## 2022-02-25 -2.57524961
## 2022-03-02 -0.24377409
amcl.quarterly.gr <- periodReturn(AMCL[,'AMCL.Adjusted'], period='quarterly', type='log')
amcl.quarterly.gr*100
## quarterly.returns
## 2014-03-31 -0.01504194
## 2014-06-30 -0.30124582
## 2014-09-30 -0.13586532
## 2014-12-31 0.30166626
## 2015-03-31 0.78007693
## 2015-06-30 0.49191697
## 2015-09-30 0.01487196
## 2015-12-31 -0.94108527
## 2016-03-31 -5.60201590
## 2016-06-30 -0.90887924
## 2016-09-30 0.43155258
## 2016-12-30 5.88404879
## 2017-03-31 -0.10531814
## 2017-06-30 -0.63424882
## 2017-09-29 -0.33384130
## 2017-12-29 -4.34918547
## 2018-03-29 -4.86314481
## 2018-06-29 -3.39015517
## 2018-09-28 -3.50913198
## 2018-12-31 -1.80185055
## 2019-03-29 0.43541737
## 2019-06-28 -0.10867846
## 2019-09-30 -0.32673891
## 2019-12-31 0.36297819
## 2020-03-31 -0.67254443
## 2020-06-30 -9.20145709
## 2020-09-30 5.80689617
## 2020-12-31 0.93897403
## 2021-03-31 0.93023927
## 2021-06-30 5.40672213
## 2021-09-30 0.22781236
## 2021-12-31 4.04788680
## 2022-03-02 -3.64610525
amcl.yearly.gr <- periodReturn(AMCL[,'AMCL.Adjusted'], period='yearly', type='log')
amcl.yearly.gr*100
## yearly.returns
## 2014-12-31 -0.1504868
## 2015-12-31 0.3457806
## 2016-12-30 -0.1952938
## 2017-12-29 -5.4225937
## 2018-12-31 -13.5642825
## 2019-12-31 0.3629782
## 2020-12-31 -3.1281313
## 2021-12-31 10.6126606
## 2022-03-02 -3.6461052
par(mfrow=c(2,1))
plot(amcl.monthly.ar)
plot(amcl.monthly.gr)
plot(amcl.quarterly.ar)
plot(amcl.quarterly.gr)
plot(amcl.yearly.ar)
plot(amcl.yearly.gr)
The difference is so subtle that it can’t be checked with bare eyes.
par(mfrow=c(1,2))
amcl.hist1 <- hist(amcl.monthly.ar, main='Arithmetic Monthly returns', breaks = 30)
amcl.hist2 <- hist(amcl.monthly.gr, main='Geometric Monthly returns', breaks = 30)
Here we can see that both Arithmetic and Geometric returns are kinda similar but arithmetic return having spikes in their return histogram, whether the geometric returns are smoother.
amcl.xts <- Ad(get(amcl))
chartSeries(amcl.xts, main='Chart Series Plot', theme = chartTheme("white"))
amcl.xts %>%
chartSeries(TA='addBBands();
addRSI();
addMACD()',
theme="white" )
Bollinger Bands are a technical analysis tool created by John Bollinger in the 1980s. They are a popular method used by traders and analysts to analyze the volatility and potential price movement of a financial instrument, such as stocks, currencies, or commodities.
Bollinger Bands consist of three lines:
The Middle Band: This is typically a simple moving average (SMA) of the asset’s price over a specified period. The most common period used is 20 days, but traders can adjust this based on their preferences and the timeframe they are analyzing.
The Upper Band: This is calculated by adding a specified number of standard deviations (usually two) to the middle band. Standard deviation is a measure of volatility, so the upper band widens when volatility increases and narrows when volatility decreases.
The Lower Band: Similarly, the lower band is calculated by subtracting the same number of standard deviations from the middle band.
The distance between the upper and lower bands reflects the volatility of the price. When the price is more volatile, the bands widen, and when it’s less volatile, the bands narrow.
Traders use Bollinger Bands in several ways:
Volatility Assessment: Traders observe the width of the bands to determine the level of volatility in the market. Wide bands suggest high volatility, while narrow bands suggest low volatility.
Overbought and Oversold Conditions: When the price touches or exceeds the upper band, it may indicate that the asset is overbought, and a reversal or correction may occur. Conversely, when the price touches or falls below the lower band, it may indicate oversold conditions, and a rebound may be expected.
Trend Identification: Bollinger Bands can help identify trends. In an uptrend, prices tend to stay near the upper band, while in a downtrend, prices tend to hug the lower band.
Trading Signals: Some traders use Bollinger Bands to generate trading signals. For example, when the price crosses above the upper band, it may be a signal to sell, and when it crosses below the lower band, it may be a signal to buy.
It’s important to note that Bollinger Bands are not foolproof and should be used in conjunction with other technical indicators and analysis methods to make informed trading decisions.
RSI stands for Relative Strength Index, which is a popular momentum oscillator used in technical analysis to measure the speed and change of price movements. It was developed by J. Welles Wilder Jr. and introduced in his 1978 book, “New Concepts in Technical Trading Systems.”
RSI is calculated using the following formula:
\[ RSI = 100 - \left( \frac{100}{1 + \frac{\text{Average Gain}}{\text{Average Loss}}} \right) \]
The RSI typically ranges from 0 to 100. Traditionally, RSI values above 70 are considered overbought, suggesting that the asset may be overvalued and due for a correction or reversal. Conversely, RSI values below 30 are considered oversold, indicating that the asset may be undervalued and due for a bounce or reversal.
Here’s a breakdown of how RSI is interpreted:
Overbought and Oversold Conditions: As mentioned, RSI values above 70 indicate potentially overbought conditions, while values below 30 suggest oversold conditions. Traders often look for divergence between price movements and RSI levels to identify potential reversal points.
Divergence: Divergence occurs when the price of the asset moves in the opposite direction of the RSI. For example, if the price of an asset is making new highs but the RSI is failing to make new highs and instead shows lower highs, it may signal weakness in the uptrend and a potential reversal. The same concept applies to downtrends.
Trend Confirmation: RSI can also be used to confirm trends. In a strong uptrend, RSI tends to remain in the overbought territory for extended periods without dipping below 30. In a strong downtrend, RSI tends to stay in the oversold territory for extended periods without rising above 70.
Centerline Crossovers: Some traders also pay attention to the 50 level on the RSI. When the RSI crosses above 50, it may suggest that bullish momentum is increasing, and when it crosses below 50, it may suggest that bearish momentum is increasing.
Divergence with Price: RSI divergence with price movements can provide valuable insights into potential trend reversals or continuations. For example, if the price is making new highs but the RSI fails to confirm these highs, it may signal a weakening trend.
RSI is a versatile tool used by traders in various markets, including stocks, forex, commodities, and cryptocurrencies. However, like any technical indicator, it is not foolproof and should be used in conjunction with other analysis methods to make informed trading decisions.
MACD stands for Moving Average Convergence Divergence, and it is a popular trend-following momentum indicator used in technical analysis. Developed by Gerald Appel in the late 1970s, MACD is widely used by traders and analysts to identify potential trend changes, momentum shifts, and to generate buy or sell signals.
MACD is calculated using the difference between two exponential moving averages (EMAs) of different periods.
The standard MACD formula involves the following steps:
Calculate the Short-term EMA: Typically, a 12-period EMA is calculated for the price data. This EMA is more responsive to recent price movements.
Calculate the Long-term EMA: A 26-period EMA is calculated for the same price data. This EMA represents a longer-term trend.
Calculate the MACD Line: The MACD line is obtained by subtracting the 26-period EMA from the 12-period EMA. The result is a single line that oscillates around zero.
\[ \text{MACD Line} = \text{12-period EMA} - \text{26-period EMA} \]
Calculate the Signal Line: A 9-period EMA, called the “signal line,” is calculated based on the MACD line. This line smoothens out the MACD line and helps identify potential changes in trend direction.
Calculate the MACD Histogram: The MACD histogram represents the difference between the MACD line and the signal line. It helps traders visualize the relationship between the MACD line and the signal line.
The MACD histogram is positive when the MACD line is above the signal line, indicating bullish momentum. Conversely, it is negative when the MACD line is below the signal line, indicating bearish momentum.
Traders use MACD in several ways:
Signal Line Crossovers: When the MACD line crosses above the signal line, it may signal a bullish trend reversal or momentum shift, suggesting a potential buy signal. Conversely, when the MACD line crosses below the signal line, it may indicate a bearish trend reversal or momentum shift, suggesting a potential sell signal.
Divergence: Similar to other oscillators, traders look for divergence between price movements and MACD readings. Divergence can signal potential trend reversals or continuations.
Overbought and Oversold Conditions: While MACD does not have specific overbought or oversold levels like other oscillators, extreme readings or rapid movements in the MACD histogram may suggest that the market is overextended and due for a correction.
MACD is a versatile tool used by traders in various markets, including stocks, forex, commodities, and cryptocurrencies. However, like any technical indicator, it is not foolproof and should be used in conjunction with other analysis methods to make informed trading decisions.