Gaming Stock Analysis With Python: Returns and Technical Indicators

A comparative analysis on EA, Take Two, and Activision

Sumantra Banerjee
Geek Culture
10 min readAug 30, 2021

--

Source: Unsplash

DISCLAIMER: This piece is not financial advice, only for educational and analysis purposes.

Special thanks to Jose Portilla and his course on Udemy “Python for Financial Analysis and Algorithmic Trading,” which I highly recommend for anyone interested in finance and data science regardless of skill level with Python.

Along with other sectors of tech, gaming stocks are heavily affected by new product launches, conferences, etc. With more people staying inside as a result of the COVID-19 pandemic, the gaming industry has been one of the winners during the global lockdown, growing 12% to $139.9 in revenue in 2020. But how have traditional gaming giants’ stocks performed? And how do they stack up against each other? Let’s take a look:

For this analysis, I chose Electronic Arts (EA), Take Two Interactive (TTWO), and Activision Blizzard (ATVI), three of the largest game developers and gaming stocks by market cap. Companies like Microsoft and Sony are also leading players in the industry, but I decided against them in order to keep the comparison strictly between developers, rather than console providers.

EA is likely the biggest name out of the three developers with popular franchises such as FIFA, Madden NFL, Need for Speed, and The Sims. Take Two developed the best selling console game, Grand Theft Auto V, along with other successful franchises like Red Dead Redemption and NBA 2K. Lastly, Activision Blizzard, the most valuable of the three and the largest developer by market cap, is responsible for the widely popular Call of Duty and World of Warcraft.

Our objective: To analyze the performance of these three stocks through comparing their price trends, returns, correlation, and some popular technical indicators. We will import and use three popular Python libraries for data analysis (numpy, pandas, and matplotlib) as well as yfinance to load stock data from Yahoo Finance.

Loading Stock Data into Python:

We will import the libraries and load EA stock data from January 2010 to August 2021 with the following code:

#Importing libraries
import yfinance as yf
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
#Loading EA's stock data into Python from Yahoo Finance
ticker= "EA"
EA_df = yf.download(ticker, start="2010-01-01", end="2021-08-01")
EA_df
Output for EA_df

We will then do the same for Take Two and Activision. I have denoted their dataframes as TT_df and AT_df respectively.

Price and Volume Analysis:

Now, let’s plot the stock prices together to compare their movements and growth. For all indicators, I use the adjusted close as it takes corporate actions (such as dividends and stock splits), into account, thus representing historical data more accurately than the close price. To plot the prices, we use:

#Plotting price movement over our selected time period
EA_df['Adj Close'].plot(label='EA',figsize=(16,8),title='Prices')
TT_df['Adj Close'].plot(label='TTWO')
AT_df['Adj Close'].plot(label='ATVI')
plt.legend();
Price movement for the three stocks

As we can see, EA started the decade as the most valuable stock, but Take Two eventually caught up with it in 2018 and definitively eclipsed it in 2020. Activision, on the other hand, lagged behind the other two for the better part of the decade, especially after 2017.

However, we should also look at other metrics, such as volume and market cap, for a more powerful comparison of the stocks, as analysts use volume to gauge stocks’ strength and demand, while market cap tells us how much one would spend to buy all the shares of the company, giving us a clearer picture of the company’s valuation. Moreover, stock splits (of which Activision has had six, Take Two one, and EA zero) also reduce the price of stocks while keeping the market cap unchanged. Let’s look at the volume traded for the stocks:

#Plotting volume traded
EA_df['Volume'].plot(label='EA',figsize=(16,8),title='Volume Traded')
TT_df['Volume'].plot(label='TTWO')
AT_df['Volume'].plot(label='ATVI')
plt.legend();
Volume traded for EA, TTWO, and ATVI

Despite its lower price, Activison’s volume dwarfed that of EA and Take Two for most of the timeframe, with a massive jump around August 2015, likely due to the company’s strong Q2 results that year and the stock’s addition to the S&P 500 index, leading the stock to hit a then-all time high.

However, higher volume does not necessarily mean Activision is a more valuable company than EA. For a better idea of valuation, we can multiply the stock price by the volume to get the total money traded. This is not exactly the market cap, but allows us to see the true money inflows into the stocks. To do this, we use the following code:

#Calculating and plotting total money traded for each stock
EA_df['Total Traded'] = EA_df['Adj Close']*EA_df['Volume']
TT_df['Total Traded'] = TT_df['Adj Close']*TT_df['Volume']
AT_df['Total Traded'] = AT_df['Adj Close']*AT_df['Volume']
EA_df['Total Traded'].plot(label='EA',figsize=(16,8), title = 'Total Money Traded')
TT_df['Total Traded'].plot(label='TTWO')
AT_df['Total Traded'].plot(label='ATVI')
plt.legend()
plt.ylabel('Total Traded')
Total money traded for the three stocks

Activision again has a higher total volume traded for most of the timeframe, but each of the companies have seen key jumps, especially EA in early 2019. On February 8 of that year, EA’s stock price rose more than 11%, after it announced that battle royale game Apex Legends hit over 10 million in its first 72 hours. Activision ends the time period with the most money traded, and is the most valuable company by market capitalization at the time of writing.

Technical Indicators:

Technical analysis helps traders identify the right time to enter and exit a trade. The most popular technical indicator is perhaps the Simple Moving Average (SMA), which is the average of prices over a certain period of time. The SMA, which smoothens price fluctuations, is often plotted with the price to check for potential changes in price trends. Two time periods commonly used are the 50-day SMA and the 200-day SMA to capture both the intermediate and long trend. To calculate and plot the SMA, we can use pandas’ rolling mean like so:

#Calculating and plotting moving averages
EA_df['MA50'] = EA_df['Adj Close'].rolling(50).mean()
EA_df['MA200'] = EA_df['Adj Close'].rolling(200).mean()
EA_df[['Adj Close','MA50','MA200']].plot(figsize=(16,8), title = 'EA Moving Averages')
50-day and 200-day moving averages for the three companies

The 50-day SMA crossing below the 200-day SMA indicates a potential sell-off, and thus, dips in stock prices. On the other hand, the 50-day SMA rising above the 200-day SMA suggests a rally in stock prices, and both trading patterns are largely reflected in the performance of all three stocks’ indicators. However, while Activision’s 50-day SMA has been above its 200-day SMA since late 2019, recently the stock has notably dipped due to an ongoing sexual harassment lawsuit filed this July, jeopardizing its brand and sponsorships for games and esports tournaments.

Another widely popular technical indicator is the Moving Average Convergence Divergence (MACD), which is calculated by subtracting the 26-period (long-term) exponential moving average (EMA) from the 12-period (short-term) EMA. EMA is similar to SMA but gives more weight to recent price data. Often, a “signal line,” or the 9-period EMA, is plotted with the MACD, with the MACD crossing above the signal line indicates bullish momentum (“bullish crossover”), whereas the MACD falling below the signal line would mean a bearish signal (“bearish crossover”).

A simple way to utilize MACD in Python is through pandas-ta, a pandas package with many over 100 technical indicators. For simplicity, let’s look at MACDs for the last three months. We use the following code to import the library and plot the MACD along with the signal line (12_26_9 corresponds to the short-term, long-term, and signal line periods, whereas MACDs refers to the signal line itself):

#Importing pandas_ta and loading MACD data into our dataframe
import pandas_ta as pta
EA_macd = pta.macd(EA_df['Adj Close'])['MACD_12_26_9'].tail(63) #Number of trading days between May 1 and August 1 is 63
EA_signal = pta.macd(EA_df['Adj Close'])['MACDs_12_26_9'].tail(63)
pta.macd(EA_df['Adj Close'])
#Plotting EA's MACD and signal line
EA_macd.plot(label='EA MACD',figsize=(16,8), title = 'EA MACD')
EA_signal.plot(label = 'Signal Line')
plt.legend()
MACDs plotted against signal lines for the three stocks

Interestingly, all three stocks started the time period with a downtrend followed by a bullish crossover, and all three saw a bearish crossover around June 15, which marked the end of E3, the largest annual gaming exhibition. Take Two’s stock particularly took a hit, dropping 7% over the next week after the company presented a panel on diversity and inclusion while refraining from announcing any upcoming games. EA and Take Two ended July on an uptrend, with EA ending Q2 strongly by announcing that sports franchises Madden and FIFA’s Ultimate Teams saw increases in bookings, and Take Two reporting better than expected Q2 earnings, with recurrent consumer spending increasing 15% year-over-year. Activision’s MACD, however, continued to plummet after news of the lawsuit surfaced.

Returns Analysis:

Of course, to see which stock has been the best investment over the time period, we want to look at returns. The formula for calculating returns is:

Formula for calculating returns (Source: The Motley Fool)

First, we look at daily returns, which measure the percentage change of a stock’s price from one day to the next. To do this, we can use pandas’ pct_change like so:

#Calculating daily return
EA_df['Returns'] = EA_df['Adj Close'].pct_change(1)
EA_df
Output for EA_df (now with a “Returns” column)

To compare the stocks’ daily returns, we can use a kernel density plot to show the returns’ distributions, which we will implement with the following code:

#Kernel density plot/estimation to compare returns
EA_df['Returns'].plot(kind='kde',label='EA',figsize=(12,6), title = 'Daily Returns KDE')
TT_df['Returns'].plot(kind='kde',label='Take Two')
AT_df['Returns'].plot(kind='kde',label='Activision')
plt.legend()
Daily Returns Kernel Density Plot

Activision has both the highest peak and the most narrow distribution, meaning it has the highest mean and least volatile of the three stocks’ returns, while EA has the widest distribution and most volatile return. Thus, Activision seems to be the most attractive stock when looking at daily returns.

However, we also want to look at cumulative returns, the total change of a stock’s price over the entire time period, to come to more of a big-picture conclusion. We can use numpy’s cumprod like so, before plotting the returns:

#Cumulative return calculations
EA_df['Cumulative Return'] = (1 + EA_df['Returns']).cumprod()
EA_df.head()
EA_df now with a “Cumulative Return” column
Cumulative returns plot for the three stocks

Here, Take Two has had the highest cumulative return for the past four years, overtaking its two competitors around early 2017, while Activision eclipsed EA in late 2020. How come Activision, despite being the most valuable of the three, hasn’t yielded the highest returns? Take Two has seen great financial growth, with its revenue growing 72% and operating margin growing 351% from 2017 to 2020, while Activision’s revenue and operating margin growing only 16% and 107% in the same time period. Furthermore, Take Two has increased research and development (R&D) spending by 165% from 2017 to 2021, leading to a whopping free cash flow per share increase of 676%, whereas Activision increased R&D spending by 63%, and saw a similar amount in free cash flow per share increase at 69%. With Take Two investing in new talent at a higher rate, it has yielded better value for shareholders through higher revenue growth as well as higher growth for the amount of cash it has at its disposal.

Now that we have calculated returns, we can look at correlations to see if one stock’s returns are affected by others. One way to do this would be a correlation matrix:

#Creating a dataframe for our correlation matrix
cumulative_df = pd.concat([EA_df['Cumulative Return'], TT_df['Cumulative Return'], AT_df['Cumulative Return']], axis = 1)
cumulative_df.columns = ['EA Cum Return', 'Take Two Cum Return', 'Activision Cum Return']
#Calculating correlations between cumulative returns
corrMatrix = cumulative_df.corr()
corrMatrix.style.background_gradient(cmap = 'coolwarm')
Correlation matrix for cumulative returns

All three stocks’ returns have strong relationships with each other, with correlations of over 0.9. Interestingly, EA and Activision have the strongest relationship, which may be due to the two companies performing similarly in terms of sales growth in the early 2010s.

Closing Thoughts:

Despite Activision being the most valuable (having the highest market cap) out of the three companies, Take Two has yielded the highest returns for investors, likely due to its strong financial growth. In recent months, all three companies saw dips after E3 2021, while Activision’s price continued plummeting due to the sexual harassment lawsuit filed in July. Furthermore, EA and Activision have the strongest correlation in terms of returns, possibly due to similar sales performances in the early 2010s.

Thus, Python is a powerful tool for stock price analysis and comparisons. I encourage you to utilize its libraries for your own analysis while checking news sources for potential reasons behind price trends, and in general, to stay up to date with the industry. Please check out these sources I found helpful in writing this article:

  1. Jose Portilla’s course on Udemy: Python For Financial Analysis and Algorithmic Trading
  2. Vincent Tatan’s In 12 Minutes: Stock Analysis with Pandas and Scikit-Learn in Towards Data Science
  3. Luke Posey’s Implementing MACD in Python
  4. pandas-ta Library Documentation

Thank you!

--

--

Sumantra Banerjee
Geek Culture

Student @ NYU Stern | Economics | Financial Markets | Cryptocurrency.