Back to Community
Cross-Market Correlations.

Knowing how future contracts and equities moved in the past could give us an indication on how they will move in the future. In this notebook, we find the correlation coefficient for all future contracts with respect to assets in the Q500 universe. The coefficients can be used to develop long-short factors, for pairs trading, or even for risk analysis. The data in this notebook could serve as a framework for future-equity long short or pairs trading strategies.

Note that doing a broad analysis like this can be good for suggesting candidates for further research, but is very prone to multiple comparisons bias. The results have a higher change of being meaningless than you would otherwise expect. In order to use this notebook correctly, you should use it to test and existing theory about a cross-market relationship, or use it to suggest candidates which are then verified via a strong economic hypothesis and out of sample testing.

You can read more about futures and pairs trading here :
- https://www.quantopian.com/lectures/introduction-to-pairs-trading
- https://www.quantopian.com/tutorials/futures-getting-started

Loading notebook preview...
Notebook previews are currently unavailable.
Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

8 responses

Nice! Please can I suggest a link to Bonferroni correction, and multiple comparisons bias, here:

https://www.quantopian.com/posts/quantopian-lecture-series-p-hacking-and-multiple-comparisons-bias

I particular, the Holm-Bonferroni method may be useful in basket trading:

https://en.wikipedia.org/wiki/Holm%E2%80%93Bonferroni_method

Great links, thanks for pointing them out!

I came across this paper: which compares the different methods for multiple comparisons bias.
Personally I think Bonferroni is too conservative.

Hi Christopher, Peter, Dan, as well as Ernesto,

I'm sort of a "new kid on the block", with a background and some perspectives rather different from most people here. In addition to my former "day job" in O&G E&P (if you don't know what that means or how it might be relevant, please feel welcome to check out my 3 posts on Joao's thread entitled "Trading algo: how to interpret results", I have also been trading for about 30 years. I looked at this issue of stock-commodity relationships some years back and decided, as Christopher has, that it was definitely likely to be fruitful for further research, but I didn't have the tools available to explore it further at that time. I would like to pick it up again here, if there is sufficient interest.

Here are some things I found in my previous informal research:

1) Many companies, and their fortunes and stock prices, have very clear relationships with the prices of commodities which those companies either produce (and hence represent a profit centre for them) or consume, and hence represent a COB (cost of business) to them. In the latter case, think for example of any of the airlines and CL futures because jet fuel is a refined hydrocarbon product derived from crude oil . In the former case, think for example of ABX & GC futures or of FCX & HG futures, or XOM & CL & NatGas futures. An interesting one is ADM. Are soybeans / bean meal / bean oil predominantly a cost or a source of profit for that company? Actually I'm not sure which predominates, but those commodities and that stock are certainly related.

2) In some cases the relationships are either less clear or possibly even spurious. See Max & Delaney's Lecture 16 on p-Hacking & multiple comparison bias. Actually, from a practical perspective though, this is usually less of a problem than it might appear to a statistician, and even a quick look at the company's annual report on its website will usually be enough to provide reasonable insight into whether the relationship is real or not.

3) There are some relationships which may be real and strong but are not necessarily obvious. In particular, ALL international commodities that have their prices denominated in USD are related because of that link via their base currency. This leads to some interesting and non-obvious relationships between commodities, such as for example between wheat & silver. Its not a spurious relationship, it is a real one and it's because if the value of the USD goes down relative to a basket of international currencies (think DX futures), then clearly both wheat & silver (as well as other commodities) prices are correspondingly driven up in dollar terms.

4) One possible exception to this is Natural Gas, which is denominated in USD but (and this is something which may not be obvious to people outside the oil & gas industry) Nat Gas is generally NOT an international commodity, for reasons as explained on the "Trading algo: how to interpret results" thread.

Talk more later if you are interested.

Cheers, best wishes,
Tony.

Hey Tony,

Great analysis, fundamental analysis of companies as a way to suggest relationships of validate those you found is a great practice. One question is always, "The relationship is strong, but is it tradeable?" There can be a strong relationship between two things that isn't tradeable in any conventional way. Especially if it's well known or obvious, common ways to trade it like mean reversion on the spread (pairs trading) may not be profitable after market impact. This is often the case with illiquid equities, which have lots of signal because they're not tradeable, but because they're not tradeable nobody can get in there to arbitrage it away.

Overall the process of actually building a model based on the underlying economics factors is a great approach. Another approach is to de-trend your data based on those factors and look at what behavior is left over. This behavior may be more tradeable.

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

Hi Delaney,

Thanks for your comments. Rather than filtering based on either stock price or market cap, usually a filter based on minimum daily liquidity solves the problem of illiquid / untradeable stocks, irrespective of whether very cheap or very expensive.

I agree that both approaches you mention are viable, and I will enjoy re-commencing some explorations.

Yup, that's one of the filters we use in our tradeable universe. https://www.quantopian.com/posts/the-q500us-and-q1500us

Ah! yes of course I should have guessed that you would.
I'm still just too new here to have got around to reading & digesting everything yet.
Thanks Delaney