Correlation between Crude OIL and Canadian Dollar

According to Wikipedia Canada is providing 43% of US crude oil imports at 2015 marks 98% of all exports. Where those 2% goes, I don’t know 🙂

I’m not a certified financial advisor nor a certified financial analyst and these is not financial advise or expert analyst! Is just expression of my observations!

Knowing these numbers we can say the Canadian Dollar will react to any news related to oil. To be sure and certain about that am going to make a correlation check with Python. As from my experience goes I can tell that USD/CAD always reacts when some surprise happens on weekly DOE Crude Oil Inventories releases.

To prove my statement with the help of YFinance and plotly USD/CAD and Crude OIL data from Sept 01. 2021 will visualise with the help of Python. Use “CAD=X” for USD/CAD and “CL=F” for Crude oil chart.

import yfinance as yf
import plotly.graph_objects as chart

# Get symbol OHLC data
data = yf.download(“CAD=X”, start=”2021-09-01″, end=”2021-09-02″, interval = “1m”)

# For some reason Index reset is a must.
data = data.reset_index()
fig = chart.Figure(data=[chart.Candlestick(x=data[‘Datetime’],
open=data[‘Open’],
high=data[‘High’],
low=data[‘Low’],
close=data[‘Close’])])
fig.show()

Comment

On the left side is USD/CAD chart and on the right Crude oil. Deviation of this week’s report is 4,7M as forecast numbers from analytics where -2,5M and Actual number came out was -7,2M. My personal opinion is that such low deviation is not enough to produce some solid moves in any of the symbols. Personally am more fond when the deviation is over 10M as seen with these numbers move wasn’t great at all. There was room to make a few pips with HFT trading strategy, just for trend trading numbers are too weak.

About the numbers

Those numbers show how much oil is available in storage in the USA. It gives us an overview of US petroleum demand. If the number is more than expected, it implies weaker demand as means bearish for oil. If the increase is less than expected as it was in our case with -7,2M means that the market should go bullish for crude oil. USD/CAD should move in the exact opposite direction.

Correlation

From my experience, OIL-related data are affecting Canadian Dollar when some worse as expected or better than expected macroeconomic data is released. Let’s now download the data set for 24h and see if normal market conditions will gave us some correlation. Can we copy and follow OIL and trade USD/CAD or vice versa?

import yfinance as yf
import numpy as np
import plotly.graph_objects as chart

# Get symbol OHLC data
data2 = yf.download("CL=F", start="2021-09-01", end="2021-09-02", interval = "1m")
data = yf.download("CAD=X", start="2021-09-01", end="2021-09-02", interval = "1m")# these part of the code source is from: https://paulconnollywriter.medium.com/calculate-correlation-between-two-stocks-a737de2cdbd0data = data.pct_change()
data2 = data2.pct_change()


data = data.drop(['Volume'], axis=1)
data2 = data2.drop(['Volume'], axis=1)

correlation = data['Close'].corr(data2['Close'])
print("Correlation is: ", correlation)
correlation2 = data['Open'].corr(data2['Open'])
print("Correlation is: ", correlation2)
correlation3 = data['High'].corr(data2['High'])
print("Correlation is: ", correlation3)
correlation4 = data['Low'].corr(data2['Low'])
print("Correlation is: ", correlation4)

total = np.array([[correlation],[correlation2],[correlation3],[correlation4]])
print(np.mean(total))

#OOP version
import yfinance as yf

class CheckCorrelation:
    # Get symbol OHLC data, with STAR and END period including wanted interval
    def GetData(self, symbol, startTime, endTime, interval):
        data = yf.download(symbol, start=startTime, end=endTime, interval = interval).reset_index()
        return data

    #cut DF at exact wanted rows. Can be modified to cut at exact datetime.
    def ExtractData(self, data, cutFrom, cutTo):
        data = data.iloc[cutFrom:cutTo, :].set_index('Datetime')
        return data

    #clclt pct change and drop unwanted columns with index reset
    def Preprepare(self, data):
        data = data.pct_change()
        data = data.drop(['Volume'], axis=1).dropna().reset_index()
        return data

    #clclt correlation
    def Correlation(self, data1, data2):
        correlation = data1.corr(data2)
        return correlation

The end result is -0,2193 as a negative, weak correlation. Based on the number alone we can say that USD/CAD and crude OIL at normal market conditions aren’t correlated.

Now we can check what kind of result the same algo will give us if we check just exact release time as is in at exact 10:30 (correct time depending on your timezone) and usually has affected 2–15min after release. As for these one goes numbers are weak and am going to check just two minutes so up to 10:32. YFinance doesn’t support tick import so honestly, these number’s even if they show strong correlations are not trustworthy. To get more accurate results please record ticks when data is released for both symbols and then make data analytics for it.

import yfinance as yf
import numpy as np

# Get symbol OHLC data
data2 = yf.download(“CL=F”, start=”2021-09-01″, end=”2021-09-02″, interval = “1m”).reset_index()
data = yf.download(“CAD=X”, start=”2021-09-01″, end=”2021-09-02″, interval = “1m”).reset_index()

data2 = data2.iloc[1259:1262, :].set_index(‘Datetime’)
data = data.iloc[982:985, :].set_index(‘Datetime’)

data = data.pct_change()
data2 = data2.pct_change()

data = data.drop([‘Volume’], axis=1).dropna().reset_index()
data2 = data2.drop([‘Volume’], axis=1).dropna().reset_index()

correlation = data[‘Close’].corr(data2[‘Close’])
print(“Correlation is: “, correlation)
correlation2 = data[‘Open’].corr(data2[‘Open’])
print(“Correlation is: “, correlation2)
correlation3 = data[‘High’].corr(data2[‘High’])
print(“Correlation is: “, correlation3)
correlation4 = data[‘Low’].corr(data2[‘Low’])
print(“Correlation is: “, correlation4)

total = np.array([[correlation],[correlation2],[correlation3],[correlation4]])
print(np.mean(total))

Conclusion

This trading strategy suits my trading style and even if is seen that you can easily trade crude OIL data that is not the case. There are a lot more factors involved as for example: where to get data on time and how to find the perfect broker. Keep in mind, that 95% of people trading in the FX market are losing money. Keep in mind that maybe there is no need to trade the most obvious pair all the time and that there are opportunities with some other symbol that is not so obvious. And probably such thinking can bring you to a much better entry price as would you with the main pair.


WHERE TO CONTACT US
Website : https://forextrade1.co/
Twitter : www.twitter.com/forextrade11
Telegram : telegram.me/ftrade1
Facebook : www.facebook.com/Forextrade01
Instagram : www.instagram.com/forextrade1
YouTube : www.youtube.com/ForexTrade1
Skype : forextrade01@outlook.com
Email ID : info@forextrade1.com
Discord : https://discord.gg/vEk98ZvrHP