Back to Community
Oil Wednesdays (+110% ytd)

Hello, everybody. I just discovered Quantopian recently. I'm still taking baby steps wrapping my head around Python, Quantopian, and the stock market -- all really new to me.

I read this in the news this morning on Bloomberg: "On Wednesdays -- when the Energy Information Administration releases its latest data for U.S. production and inventories -- oil prices take a tumble."

I thought I would write up a quick algo that exploits this pattern. This actually has the best stats of any algo I've tried so far! (Well, only if you limit it to 2017.) So obviously don't take it too seriously. It's not Q Open material or anything, but maybe somebody out there can make (or lose) a ton of money with it.

(Update: I just realized that due to a mistake this runs on Thursdays instead of Wednesdays, which turn out to not perform as strongly. Ooops!)

Clone Algorithm
27
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 594da1907897594d3f6ac6dc
There was a runtime error.
6 responses

Welcome and great to test something like this. If you want to explore this further go to the reason why (the causality) and uncover in notebooks or ide the data stream you need (prob a combo of inventories, online rigs and COT) make the position sizing algo based (optimise) and develop first on leverage 1.0 to be able to compare performance. As you are working with oil try to use futures instead : CL. Try to develop in one timeframe and test it in another to prevent loo ahead bias.

....WTF

Good find!

just so people understand that this doesnt work long term

Clone Algorithm
3
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 594dd3303537ea51482d45b4
There was a runtime error.

So this very dumb algo works on the premise that the Wednesday announcement will hurt oil prices,due to over-production, lack of demand, and new technology making shale oil still affordable to drill despite the above. It's very dependent on oil economics, which I don't know anything about.

I used 3x leverage because it seemed realistic -- that's the limit for the Q open, and also because you can accomplish the same with a 3x etf and no leverage. To be fair, shorting oil 3x the entire ytd would have lead to higher returns, but with higher volatility and your cash tied up the whole time.

It'll be fun to see what happens out of sample -- I've got it in paper trading now.

I figured I'd take another look at this since nearly 6 months have elapsed. Since then the price of oil has had a big recovery, so I would have expected this strategy to have fallen apart. However, surprisingly, it looks like holding an intraday leveraged short position in oil & gas explorers on Thursdays as a hedge to a normal long position in the S&P500 has continued to perform out-of-sample. I still wouldn't blindly trade this strategy, but I see these results as a starting point for research to discover the systemic cause. My hunch is that the data needed isn't easily accessible from within Quantopian, so the research/algo would need to be executed elsewhere. Also, obviously since it's only in the short position less than 1/5th of the time, the strategy is still exposed to a huge amount of tail risk despite the 0 beta.

Clone Algorithm
3
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 5a4d7c85ff00393fbc0f7295
There was a runtime error.

Here's the Robinhood-friendly variation.

Clone Algorithm
8
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 5a4d8470db0e13433986fcdb
There was a runtime error.