Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Very simple 2 sharpe algo on XLE components

I never thought such as simple algo could fetch 2 sharpe.

17 responses

Trades daily instead of weekly. Same results.

very nice! -- what does it look like during 2008-2009?

Works from 2011 only for some reason. Maybe components of XLE were different before that? I am not sure why.

Changed title because algo does not short anything. Its a long only strategy hedged with XLE ETF.

Thanks for that. it worked for me from 2007 (XLF is traded from end of 2006), I noticed that you are shorting the energy ETF= XLF as you said to hedge the long individual energy stocks. Whats the rational behind this algo ?

@Joe. I was trying something else and stumbled upon it. Don't have a rational at this point.

Should try this with the symbols of XLE as of 2007, to avoid look-ahead bias.

Agree with Simon. There's potential for survivorship bias here as the code states "Set_symbol_lookup_date('2015-05-01')". You will only be buying those that survived till May 1, 2015.

Can you please explain to me your algorithm? As far as I understand, it's do the following daily:

Compute the 1 day return
Compute the daily mean return
Compute the daily standard deviation of returns
The weights in each security are their normalized Z scores then?

Somewhere, I'm mistaken in my reading of your python code (I'm not very well versed in Zipline), since I get a massive drawdown in 2013.

Thanks for the help.

@Ilya,

Compute the cumulative log returns (not daily returns).
Compute the mean across all stock cumulative log returns.
calculate z score by subtracting mean from each stock's cumulative log return and dividing by standard deviation of cumulative log returns.

So you're saying to compute a running cumulative product from the onset, and not a moving window (EG 5 periods)?

How exactly are you computing your daily returns?

daily_return = prices.pct_change().dropna().values
log_return = np.log1p(daily_return)
cumulative_return = np.cumsum(log_return)

This only seems to work for Energy out of Energy, Financials and Technology sector. I will try to run this for other sectors as well.

I divided the consistency based weighting into two components (Momentum and inverse volatility). The inverse volatility generates some alpha but momentum fails for technology sector. It seems cross-sectional return (finalret) dispersion is an important ingredient for this strategy but the values are not very different across energy and tech sectors. What could be going on?

Weights as Inverse volatility

Thanks for sharing - this looks promising at first, but upon closer inspection, it is just the fact that with QE everyone wins. If you test it between 2007 to 2011, this system has a negative sharp.

@Mohammad
I understand that QE explains the good performance of the algorithm. But I am curious to characterize the performance difference within sectors in the same period. What diagnostic should I calculate/look for? Any insight is much appreciated.

Apologies all but I hardly login to Q anymore. Very busy with my other project. I stumbled upon this algorithm and haven't given it much thought since then. If you find any insights please keep me posted as well.