Back to Community
Top Dog Mean Reverts

Hi all, here is my starting point for the "market making" algo, or relatively high frequency "risk taking" algo (daytrading really, is the best I could do)....it is a tweaked version of the sample mean reversion code available to all of us in the help guide. These are the tweaks I made:

  1. I focused on the extreme 5 day returns, both high and low, the algo buys low, sells high return securities
  2. I focused on the extremely liquid underlyings
  3. I rebalanced every day based on the rolling 5 day returns, not every week

For all who were wondering what I awas trying to do, please read this post: https://www.quantopian.com/posts/market-making-algo

This is daytrading really, not minutely trading, but I have come to realize that minutely trading in a professional manner is impossible to do on the Quantopian platform.

So, the reason I am sharing this backtest is to gather some feeback as to why even this type of trading is not possible to do, since if it were, Quantopian would be doing it with their own money, and would not be asking others to write algos or to invest others' funds....having said this, go ahead and tear this "algo" apart, and tell me where it is not realistic and where it fails to meet professional standards. It will level some expectations for all participants, whether deluded in their quest for free money or not.

Thanks in advance!

PS: This is especially a challenge for Quantopian IT - please take a look at this code and tell us why the realized return is not possible to achieve in real life.

Clone Algorithm
31
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: 578c094cbae47e0f896384cc
There was a runtime error.
17 responses

If I were to critique this algo, I would say 2 things:

  1. It lacks consistency. For example see the attached backtest - it is your algo over a shorter period. Note that instead of an incline, it has a decline.
  2. The drawdowns are too high.

If you look at the backtest... over 70% DD and major losses - this is too high risk for almost all investors.

Clone Algorithm
1
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: 578ea339c3b6800faa07aa76
There was a runtime error.

I am sure you can pick an unprofitable and high DD period in any backtest, so that is fine, but not what I am looking to get to. As counter example, please examine the period between 2002 and 2007 - it resembles results from a Holy Grail HFT algo (but it is NOT). Again, that is not the point.

The main question is why this is not implementable in real life trading, and the answers should be technical, i.e. what Quantopian code does during back testing vs. real life trading and what features are not at professional grade.

Thanks!

I don't think there is anything in this algo that would make it technically untradeable.

I think the only reason most wouldn't use this algo is because of the risk involved, but I don't see any technical problem with it.

Couple issues that I found:

  1. Trades ETFs such as UVXY. Volatility ETFs do not follow mean reversion
  2. This seems to get lucky on some stocks and unlucky on others. It could have easily swung the opposite way overall. For example, it bought WM at $2 and had to sell at $0.16. It bought NCC at $1.87 and sold as high as $3.94
  3. As the leverage indicates, this is having unfilled orders, when in real life they would probably fill at much greater slippage.

Overall I wouldn't trust the backtest.

My thoughts:
- This is high risk, and the fact it appears to make so much is due to luck on some high volatility events
- Does not make money from 2013 to present
- Leverage goes above 1

"1.Trades ETFs such as UVXY. Volatility ETFs do not follow mean reversion"

Sure they do.

"2.This seems to get lucky on some stocks and unlucky on others"

That is the entire purpose, else it would overfit the data.

"3.As the leverage indicates, this is having unfilled orders, when in real life they would probably fill at much greater slippage"

Now you are talkin'. This is due to the technical limitations of the platform. However, in real life you can enter real life order types like "fill or kill" or something like "fill whatever you can today then cancel"

"This is high risk, and the fact it appears to make so much is due to luck on some high volatility events"

Luck on some high vol events? This algo FOCUSES ON HIGH VOL events, by definition.

"Does not make money from 2013 to present"

It does not matter. You can pick a bad run in any backtest. The interesting side note is that mean reversion as a market force is mean reverting itself, so this period is one when momentum rules and not mean reversion. It all depends on how much total money is dedicated to each strategy at a particular time.

"Leverage goes above 1"

This is a good question for Quantopian - if you set the leverage explicitly in the code, as the sample code does, then why is leverage going above 1 at certain points in time? I will rerun it after setting slippage to zero, and see if that fixes it i.e. if the theoretical slippage model is causing this issue.

UVXY is usually in contango which exerts downward pressure on price. If the price of UVXY becomes very low, it does a reverse split to bring the price up again.

This would not be considered 'mean reverting'.

Are you saying this algo traded on BAD UVXY data, unadjusted with for splits? Can you prove it with trade logs? I doubt it, but if you can, then Quantopian should know about it. Thanks anyway!

No, I am simply stating why UVXY is not mean reverting.

Do you know what the algo does, in its current state? If you do, then you will know that the ETF drag is a longER term issue, and the algo is short term (overnight) focused, and that mean reversion does happen in this time frame on leveraged vol ETFs. But who cares about that after all - if the trades on UVXY are indeed possible in real life, then the algo has done what it is supposed to, i.e. capitalize on short term mean reversion of the most volatile securities (check the original post for the parameters I chose). If the UVXY trades are impossible (or impractical) to do, then that is an issue Quantopian should know about, and would indeed render the backtest useless.

The problem with uvxy is that often it will be the top loser and continue to be the top loser.

Your algo might short sell it as a top winner which is a more practical strategy but it also might get in trouble that way.

Had your algo been unlucky and lost 99% of it's money early on I don't think you would have posted it.

"Your algo might short sell it as a top winner which is a more practical strategy but it also might get in trouble that way."

If you examine the logs and use them as basis to say what you said, then OK. But you have not, obviously.

"Had your algo been unlucky and lost 99% of it's money early on I don't think you would have posted it. "

You are right I would not have posted such sorry results. Instead, I would have flipped the logic to go long when short and short when long, and I would have posted that one, and I would have called it Top Dog Momo Player.

Hey "Stevie", here is the "algo" you are looking for - the code is here as well, no need to keep it "secret", if that is at all possible ;)

"Put me in, Coach! I'm ready! I'm ready!"

And here is the "algo" code too - I am only sharing it with "insiders"!!!

Keep bumping your own thread, I'm sure it'll get funnier.

I added stop-losses to the algo to try and bring the max drawdown down a bit. It seems to have worked, but after Mar 2009, this algo basically stops working.

Does anybody have thoughts about why this might be? Did mean-reversion stop working due to some kind of quant saturation after that? Something else?

Clone Algorithm
10
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: 57a95882af95790ffc17f661
There was a runtime error.

Same code, from 2009 - 2016.

Clone Algorithm
10
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: 57a96832d0e2cf0ff90186e6
There was a runtime error.

Can somebody from the community or from Quantopian look at my stop-loss code (either of the 2 backtests above) and give me a sanity check? (Lines 151-159)

Is it placing a stop-loss order? The latest backtest I did lost all of the capital and I'm trying to figure out what went wrong.

Clone Algorithm
10
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: 57aa4606af51c20ffa73f418
There was a runtime error.