• Facebook

©2019 by datascienceinvestor

Stock in focus: AAPL

Updated: Jan 13

Apple (Symbol: AAPL) has been one of the investors' favourite stocks which gather much attention among the investing community, primarily due to its astonishing growth over the past few years and the fact that it's one of the most valuable companies in the world.

I believes the stock needs no more further introduction, and let's cut to the chase.

How has it performed in the past year?

Pretty sweet, isn't it? There's hardly any big drops in the price this year and the price has been increasing nicely over the whole duration of a year.

How does it compare against the major US indices then?

Generally, AAPL share has been moving quite in tandem with the major US indices. Here are the r coefficients of the respective trend lines.

AAPL- 0.932

DJIA- 0.833

NASDAQ- 0.860

S&P500- 0.892

The plot for AAPL has the highest r coefficient, which also signifies that AAPL share increases more than the major US indices over the past year. If you have invest purely in AAPL share for the past year, you have already beaten the US market.

All hail AAPL!


Now, one important factor in trading stocks is also to take note of the various technical indicators. One of the commonly used indicators has been the Simple Moving Average (SMA). Using Simple Moving Average, we are able to better tell how the price trend has been like. For eg, if SMA50 (50-day Simple Moving Average) rises above SMA200 (200-day Simple Moving Average), a golden sign arises which represents a bullish signal. Similarly, if SMA50 drops below SMA200, a death cross arises which represents a bearish sign. The more such crossovers happen, the more volatile the prices are deem to be.

I personally prefer to use SMA20 and SMA50 as there is less "lag" to the actual price chart since it is shorter term in nature, and would like to see how does the crossover chart look like in comparison to the price chart.

You can see that there are three instances where the SMA20 crosses the SMA50. The first occurs in Feb 2019 where SMA20 rises above SMA50 (bullish sign). One occurs some time before Jun 2019 where the SMA20 drops below SMA50 (bearish sign). The last occurs some time near Jul 2019 where the SMA20 rises above SMA50. There aren't many such instances in the past year, hence AAPL hasn't been exactly too volatile over the past year.

However, the SMA20 and SMA50 lines had been quite close to each other since Aug 2019. Any abrupt drop in price will suddenly result in the SMA20 dropping below SMA50 which might signify a bearish momentum.

What happens if you buy AAPL on 24 Dec 2018, sell it when SMA 20 drops below SMA50 and only reinvest again when the SMA20 rises above SMA50 again? Would you have made a bigger profit? Let's take a look.

If you were to buy AAPL on 24 Dec 2018 and hold it till now with an initial capital of 1000USD, your 1000USD will have turned into 1934USD.

If you were to adopt the method as described above to rely on these bullish/bearish signal, your 1000USD will have turned into 1634USD instead. In this case, buy and hold is a better strategy. However, we have only used SMA20 and SMA50 in this case with a very short time horizon of 1 year. Results might potentially be different if you use other SMA values or extend the time horizon.

Sentiment Analysis is another area where data science has been applied to finance to better understand if people sentiments has any effect on stock prices. In this case, I will attempt to try to assign a quantitative value to people sentiments on Apple to see if there is a direct correlation between people sentiments and AAPL stock price.

In this case, I extracted AAPL sentiment data from Sentdex which pulls data from a variety of sources such as Reuters, Yahoo Finance, Bloomberg, Forbes etc and assigns a value to the general sentiment on a particular topic.

Here is the scale, ranging from a value of -3 (strongly negative) to 6 (strongly positive)

6 - Strongest positive sentiment

5 - Extremely strong, positive, sentiment

4 - Very strong, positive, sentiment

3 - Strong, positive sentiment

2 - Substantially positive sentiment

1 - Barely positive sentiment

0 - Neutral sentiment

-1 - Sentiment trending into negatives

-2 - Weak negative sentiment

-3 - Strongest negative sentiment.

To ensure higher accuracy in the data value, I use the Simple Moving Average of the sentiment value across a period of 5 days instead.

Here is how it looks like (as an example)

I extracted the sentiment value over a duration of 1 year, and cross examine it against AAPL stock price in a scatter plot. Here is how it looks like.

The r coefficient for the trend line is 0.452, which suggests there is a certain correlation (though not extremely strong) between people sentiments and AAPL share price. To certain extent, AAPL price do increase when there is positive sentiments on Apple in the various news/media channel. This warrants a closer look into bettering this analysis method and I will probably seek to explore that in a separate post.

AAPL has a good ride this year with its' price hitting record high almost everyday. For cautious investors, there is no harm to start taking profits. Of course, you might have a second opinion about it. But just make sure you are not the last one to leave the party.


Psst.. If you like what you read, please scroll down and subscribe for regular updates!