2018/8/31

Apple stock prices

This presentation uses Apple's stock price - from Jan 03 2007 to Aug 24 2018 - to make the plot.

Besides the close price, I calculated the 30-day and 10-day moving average. Based on the 10-day moving average, I calculated the Bollinger Bands with parameter 2.

## [1] "AAPL"
##            AAPL.Close       Date    ma10     ma30    upper    lower
## 2018-08-24     216.16 2018-08-24 213.696 203.1527 219.7356 207.6564
## 2018-08-27     217.94 2018-08-27 214.603 204.0537 220.1234 209.0826
## 2018-08-28     219.70 2018-08-28 215.598 204.9953 220.8089 210.3871
## 2018-08-29     222.98 2018-08-29 216.872 206.0813 222.4756 211.2684
## 2018-08-30     225.03 2018-08-30 218.043 207.1863 225.0628 211.0232
## 2018-08-31     227.63 2018-08-31 219.048 208.3927 228.2969 209.7991

Bollinger Band

Bollinger Band is kind of like the confidence interval. The middle line of Bollinger Band is a moving average line - in this presentation I used 10-day moving average. The upper/lower line of Bollinger band equals to the middle line plus/minus parameter times the standard deviance of the past 10 days prices (the same time window as middle line, here use 10). The formula is given below.

\[middle = \frac{1}{win}\sum_{i=0}^{win - 1}{Close_{today-i}}\]

\[upper/lower = middle\pm 2 \times std(Close_{today}, \cdots, Close_{today-win+1})\]