Introduction
I conducted this small analysis to see how the price of oil (Europe Brent spot price FOB - $ per barrel ) changed in past and how the share price of some major Oil companies changed over the same time period. My intentions were to see if there was any correlation and find any insights. That is what the Data Scientists do, unravel the secrets from the data. Having worked in Oil and gad Industry for long time I had many ideas which I intend to execute eventually with my Data Science tool kit. I believe this is just the beginning.
The Python libraries used are :
Library | Description |
---|---|
Numpy | Library for multidimensional arrays with high level mathematical functions to operate them |
Pandas | Works on top of Numpy, offers a great way to manipulate and analyze data in tabular form |
Matplotlib | Plotting and visualization. |
Seaborn | Works on top of matplotlib to provide a high level interface for attractive plotting and visualization |
Data
The Data has been taken from the following websites :
- Oil price dataset from the U.S Energy Information administration. Webpage
- Share price dataset from Yahoo Finance in a daily frequency. Webpage
The companies considered in the analysis are :
Oil Company | Listing |
---|---|
Shell | RDSB.L |
British Petroleum | BP.L |
Cairn Energy | CNE.L |
Premier Oil | PMO.L |
Statoil | STL.OL |
TOTAL | FP.PA |
ENGIE | ENGI.PA |
Schlumberger | SLB.PA |
REPSOL | REP.MC |
Analysis
The first step of data analysis is always loading the data in proper format in the Jupyter Notebook. I used the pandas library to load the excel and csv files. The Europe Brent Spot Price FOB (Dollars per Barrel) data was available from 1987-05-20 to 2017-06-26.
The trend of Oil price is as shown below :
Next I loaded the csv files for all the companies with their share prices. I chose the adjusted closing share price and not the closing price as the former gives accurate representation of the firm’s equity value beyond just the simple market price. For comparison purpose I also scaled the share prices between 0 and 1 for each company into a separate column, this could be used to analyze the variation beyond just the absolute share price values. Any Null value in the data wherever existed was removed. The following snippet shows the final form of the table I obtained.
To have a broader picture of the relations between Year, Share price and Oil Price I plotted the Pairwise plot for each company.
Shell
British Petroleum
Cairn Energy
Premier Oil
STATOIL
Total
Repsol
ENGIE
Schlumberger
During my tenure in Schlumberger I very distinctly remember watching the oil prices having a free fall second half of 2014 onwards. There are lot of insights we can draw from the above plots but the most distinct that even I am interested in the most comes by looking at the plots between the Oil Price and Adjusted Share price. With the falling oil price the share price of most of the companies also show a major decline. If we notice the top right plot (Row 1 , Column 3) between share prices and oil price, we notice that the lower oil price in 2015 and 2016 has affected all the companies but the impact is probably less on Schlumberger.
Now lets have a look individually at how the share price changed over 5 year time period for each company, I will show this using my favorite violin plots. The thickest portion in a violin corresponds to the region of highest kernel density. The horizontal lines in the violin represents the median, \(25^{th}\) and \(75^{th}\) quantiles. We can clearly see the spread of the Adjusted share price for different years. The median share price has consistently decreased for Premier Oil and ENGI more or less. 2017 seems to be a come back for Shell, BP, CNE Statoil Total and Repsol after having some downfall in 2015 and 2016.
I also plotted the relation between the Oil price and the Share price for all these companies.
When I tried to fit the best fit line I notice that there is a strong positive correlation between oil price and share price for Premier Oil and BP but it was not of value unless seen year wise. I plotted the same relation but this time the best line was fit yearly for each of these companies. This plot gives much better picture. We notice a strong positive correlation between oil price and share price of Schlumberger. That implies increase in oil price accompanied by the increase in share price and also vice versa. This is not necessarily a causal relation.
The above analysis was a short attempt to show how lot of insights can be drawn from appropriate visualizations. Please feel free to get in touch with me for any suggestions.
References:
Inspired by javier bravo’s post: Post link