Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Using weather as a trading signal

A paper, "Good Day Sunshine: Stock Returns and the Weather", correlates the sunniness of days with changes in stock price. The theory is that sun boosts people's mood and good mood improves people's outlook on the market. The paper concludes that "sunshine is highly significantly correlated with daily stock returns. After controlling for sunshine, other weather conditions such as rain and snow are unrelated to returns." I thought this was interesting, so I tried to reproduce the results.

Although the paper looks at many different locations, I just looked at New York City. I obtained weather forecasts for the upcoming day from a Twitter feed to try to minimize look-ahead bias. Once I had my data, I organized it into a .csv so I could use it in my algorithm. The algorithm itself is simple: if the upcoming day is going to be sunny or mostly sunny, it goes long. Otherwise, it goes short. It always buys or sells the most shares possible given the current cash or positions.

This strategy works well using the S&P 500, particularly relative to the benchmark around 08-09. I'm curious to see if there is any noticeable pattern in the securities that do better or worse in this strategy, as maybe traders of certain stocks are more or less affected by sun.

If you're interested in using different weather history, you can see here. With an algorithm that uses data from a source like that, though, you have to make sure the time shift is correct such that the right weather affects the right day of trading. Similarly, note that there would a slight bias since you would be using the actual, not the forecasted, weather conditions.

Feel free to copy the algorithm by clicking Clone below. You can try different stocks against NYC weather, or you can add different weather sources you find.

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.

7 responses

Hi Gus,

I tweaked your algorithm to buy/sell randomly, instead of using the historical weather. The weather may be a useful indicator, but for your example, perhaps it's just a random binary input that happens to result in avoiding the 2008-2009 downturn.

Grant

Hi Grant,
I'm just basing this off of the paper. That was much more extensive than this, and found weather and the market to be highly correlated. It is unlikely that the supposed correlation was a result of randomness for the large sample that the authors used. Whether my test succeeded or not based on luck is impossible to say, and one could say that about many backtests. All I'm saying is that I can reproduce the results, which seems interesting.

Gus

Hello Gus,

In tinkering around, I've found that the 2008-09 downturn can result in what looks like a winner algorithm. I'm wondering if the effect may be at play in your algorithm, since it appears that your return tracks the market once the crisis subsides.

Grant

Yeah, these short backtests of daily data can easily fit to avoid the financial crisis. Part of the joy of backtesting!

Renaissance determined this with NYC, Greenich, and where they are located as their test areas. They released the info because after transaction costs it did not show enough of a gain. It is talked about in "More Money Than God".

In general I find that comparing overall returns across with a bench mark any time period can be misleading. So is looking at just 1,3,5 and 10 year returns.

I prefer to compare "trailing" 6 month or 1 year returns for the entire backtesting period and its relative performance to the benchmark.
Also I am interested in classifying these periods into down and up periods and understand how consistently the model beats the benchmark in down periods(looses less than the benchmark) and how consistently it meets or beats the benchmark in up years.

I am talking about up/down periods separately because in general in quant models find beating an upmarket is quite different from avoiding/protecting a down market.

I would love to see some of these numbers in the backtest summary.

Sarvi

Another paper for those that are interested. I doubt it's randomness.

http://www.sciencedirect.com/science/article/pii/S0378426607003949