You made it! The last blog of the series is finally here. You’ve either been interested in what I’m writing about or you find the pragmatic Plotly and Facebook Prophet code useful or both. In this blog, we are going to continue to use Facebook Prophet to analyze oil price forecasts but this time we are going to forecast two years into the future and compare to forecasts generated using fundamental analysis provided by the EIA. Finally, for those of you who enjoyed the pragmatic code, I will be using Facebook Prophet contained within a function that can be re-used for multiple forecasts rather than hard coding each forecast individually.

We have discussed a lot of what goes into oil prices in the last two blogs and to recap in short is that the price of oil is ultimately determined by supply and demand but what creates supply and demand is complicated. We have also talked about Black Swan events and how these unpredictable events wreak havoc on forecasts. Let’s first look at the EIA forecast since it provides a nice backdrop to help us understand the Facebook Prophet forecast.

Source: https://www.eia.gov/outlooks/steo/#:~:text=U.S.%20crude%20oil%20production%20in,million%20b%2Fd%20in%202022.

We see from the EIA forecast that we are looking at $60 dollar oil and as of today’s writing the spot price of WTI is $66. Now let’s summarize a few key points that EIA has shared on their website since the points made highlight how volatile oil prices can be.

  1. The short-term outlook is still heavily dependent on economic recovery from the COVID-19 pandemic.
  2. On May 7th, 2021, the Colonial Pipeline was temporarily shut due to a cyber-attack leading to an artificial supply shortage (this was not factored into the latest forecast).
  3. This Spring/Summer U.S. consumption of gasoline will average 9 million b/d up from 1.2 million b/d last year but still down 0.6 million b/d from 2019.

Taking these points into consideration we can see that we have a mix of causes that are both unexpected like the Colonial Pipeline cyber-attack and more easily understood events like the recovery from the COVID-19 pandemic contributing to oil demand in the short term. In short, we see that short-term forecasts are complex enough and that long-term forecasts are even more so. So, we have completed a review of a short-term forecast based on fundamental analysis, how does one from a forecasting algorithm look? Let’s find out!

As promised, below is the function I used to forecast oil prices for two years on monthly data from 2000–2019. I reused a lot of the code from the Databricks website (https://pages.databricks.com/rs/094-YMS-629/images/Fine-Grained-Time-Series-Forecasting.html?_ga=2.12170676.109939019.1619973544-1474539669.1619216165).

#function for forecastsdef forecast_oil(history_pd):# instantiate the model, configure the parameters
model = Prophet(
changepoint_prior_scale=0.8,
interval_width=0.95,
growth='linear',
daily_seasonality=False,
weekly_seasonality=True,
yearly_seasonality=True,
)
# fit the model
model.fit(history_pd)
# configure predictions
future_pd = model.make_future_dataframe(
periods=12,
freq='m',
include_history=False
)
# make predictions
results_pd = model.predict(future_pd)
# return predictions
return results_pd
#Call function on Brent and WTI data frames #BRENT forecast
BRENT_forecast = forecast_oil(BRENT)
#WTI forecast
WTI_forecast = forecast_oil(WTI)

As a quick reminder, the data frames that are used in the forecast are those that were prepped in the same fashion and you can find that code in the earlier blog. Now let’s look at the results.

#plot forecast
fig = go.Figure()
# Add traces
fig.add_trace(go.Scatter(x=BRENT_forecast['ds'], y=BRENT_forecast['yhat'],
mode='lines+markers',
name='WTI Forecast',
marker_color='MediumAquaMarine'

))
fig.add_trace(go.Scatter(x=WTI_forecast['ds'], y=WTI_forecast['yhat'],
mode='lines+markers',
name='BRENT Forecast',
marker_color='DarkOrange'

))
fig.update_layout(
title='Forecast(FB Prophet) Benchmark Crude Oil Prices (2021-2022)',
xaxis_title="Date",
yaxis_title="Price/Barrel(USD)",
legend_title="Forecast")
fig.show()
Oil price forecast for WTI and Brent using Facebook Prophet

At a high level we can see that based on this model, prices will remain volatile into the future but stay within $20 of today’s price ($66). Now, let’s compare to the EIA forecast.

#comparing prophet forecast to EIA forecastfig = go.Figure()# Add traces
fig.add_trace(go.Scatter(x=WTI_forecast['ds'], y=WTI_forecast['yhat'],
mode='lines+markers',
name='WTI Forecast',
marker_color='MediumAquaMarine'

))
fig.add_trace(go.Scatter(x=BRENT_forecast['ds'], y=BRENT_forecast['yhat'],
mode='lines+markers',
name='BRENT Forecast',
marker_color='DarkOrange'
))
fig.add_trace(go.Scatter(x=eia_forecast['Date'], y=eia_forecast['EIA Forecast (BRENT)'],
mode='lines+markers',
name='EIA Forecast(BRENT)',
marker_color='DimGrey'
))
fig.add_trace(go.Scatter(x=eia_forecast['Date'], y=eia_forecast['EIA Forecast(WTI)'],
mode='lines+markers',
name='EIA Forecast(WTI)',
marker_color='IndianRed'
))
fig.update_layout(
title='Forecast(FB Prophet) Vs. EIA Forecast (2019-2021)',
xaxis_title="Date",
yaxis_title="Price/Barrel(USD)",
legend_title="Forecast",
)
fig.show()
EIA forecast compared to Facebook Prophet forecast

Now comparing the two forecasts in depth would take several blogs but what we can see is that in general, the two forecasts show a gradual decline in oil prices over the next two years. If one was only looking at the Prophet model, the prices would seem incredibly volatile over the next two years compared to the EIA model. There is a noticeable “crash” in oil prices forecasted for early next year based on the Prophet model but the EIA forecast but how reliable is that information?

Two main takeaways from this comparison are that based on these forecasts there will be a gradual decrease in oil prices over the next few years. If you’ve been following this blog series from the beginning you’ll see that this is what we were looking for from the beginning. But are these prices due to a continuing lack of demand due to the increase in renewables? is it due to an ongoing pandemic that depresses prices? or is it due to increased production from oil producers around the world? None of these questions can be answered with any real confidence. If our analysis in the last several blogs shows anything in the short-term it’s that the outlook for fossil fuels remains extremely volatile dependent on predictable and unpredictable events. Finally, there is a key lesson here on relying on forecasts for any decision. Both forecasts using fundamental analysis and complex algorithms to make forecasts have their issues. Investopedia goes into depth on just how these issues can affect the reliability of forecasts here:https://www.investopedia.com/articles/trading/11/black-swan-events-investing.asp. Finally, since this is a blog focused on forecasting, there is hope for the future as it looks like the bright minds at Stanford are developing ways to predict Black Swan events that could make financial forecasts more reliable in the future. You can find out more here: https://www.sciencetimes.com/articles/26588/20200723/stanford-researchers-predict-black-swan.htm.

--

--