Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Algorithm Feedback Request

I've recently developed this algorithm, it appears to be something interesting, but I'm at a bit of a loss as to what to tackle next. The aim is to make the algorithm suitable for a Quantopian capital allocation.

I'm hoping to hear feedback from Quantopian as to what is necessary to move towards this end goal. Right now, it doesn't order using the Optimise API, that's the obvious next move. Other than that it's fairly flexible as to what can be done next.

The strategy is long-short with very limited risk exposure. At the moment it meets all requirements bar leverage and net dollar exposure.

The main drawdowns I can see are:
1. High Turnover (145% when not constraining it using leverage)
2. Consistently under-performed from 2014 to 2018
3. Seems to be a case of the returns being driven by short term jumps followed by long term periods of almost being stationary
4. The algorithm trades mainly small and mid cap stocks

The algorithm has a few things of interest though:
1. Volatility seems to be a flat 6%, no matter what the market does
2. Sharpe Ratio is slowly trending upwards
3. The returns are mostly 'Specific Returns' driven

This algorithm has sound economic background and can be applied to all sorts of stocks with generally positive results.

The algorithm performs from 2003 all the way to the present day with a max drawdown of ~5% under the current code, the backtest won't compile into the Notebook form due to limited memory so I'll share what I can below.

I would really appreciate someone from Quantopian weighing in on this with their opinion.

13 responses

Very impressive! Would you mind running it with the (round_trips=True) option?

@ Joakim Arvidsson

I have tried my best, but it refuses to load in. I started the Notebook running a few minutes after you commented, and now nearly two hours later it still hasn't given me an output.

What I can say is this:
1. The algorithm is long-short so it's not aiming to be profitable in all stocks, merely profitable on average so I'd assume "Percent profitable" is between 40 and 60%
2. The portfolio is rebalanced daily so Average Holding time should be fairly low
3. The Sharpe Ratio of the Portfolio has been consistently rising from 3.0 to 5.0 over the last few months, indicating a sound investment strategy
4. This month alone it has posted a staggering return of 35%
5. Stability is basically 1.

All these figures and the notebook below have been achieved with leverage being set to 1 (aiming for).

I strongly suspect something is amiss, since 145% daily turnover is mighty high and over 2X the already high limit of 65% for the contest (and fund allocation):

Turnover: Contest entries must have a mean daily turnover between 5%-65% measured over a 63-trading-day rolling window. Turnover is defined as amount of capital traded divided by the actual gross book (gross market value). For algorithms that trade once per day, Turnover ranges from 0-200% (200% means the algorithm completely moved its capital from one set of assets to another). Entries are allowed to have as little as 3% rolling mean daily turnover on up to 2% of trading days in the backtest used to check criteria. In addition, entries are allowed to have as much as 80% rolling mean daily turnover on 2% of trading days in the same backtest.

Also, I'd make sure you have tested using the default commission and slippage.

The gross leverage is 0.21, which is 5X smaller than it needs to be (should be ~ 1.0), per the contest rules.

If you run the attached notebook on your backtest, you can get specific feedback on the gaps vis-a-vis the contest/fund allocation. Note, however, I don't know if this notebook is maintained (I found it on https://www.quantopian.com/tutorials/contest#lesson11); it could be out-of-date.

You could also use the notebook here:

https://www.quantopian.com/posts/contest-constraint-check-notebook-with-compact-output

You are trading ~500 stocks, which is a lot. You might consider how to trim it down to a much smaller number. The Optimize API MaximizeAlpha might help.

Here's a code snippet, should you want to try constraining turnover:

https://github.com/quantopian/research_public/blob/master/code_snippets/increasing_max_turnover_snippet

@Grant,

Thank you for your feedback.

The gross leverage is 0.21, which is 5X smaller than it needs to be (should be ~ 1.0), per the contest rules.

I'm thinking of adding in a strategy making up 80% of the portfolio which is essentially a flat line, should get it up to the right level and not add to the turnover too much. What's interesting is that the turnover of positions in the backtester shows up as ~40%, but the turnover in the notebook hits 145%. I assume it's because I'm holding a lot of the portfolio in cash.

I'm almost completely backed into a corner on the 500 stocks front, too few and I'm over exposed to factors, too many and I get killed on Slippage and Commission. 500 stocks seems to be the happy medium.

~40% turnover is still very high

I would suggest feeding your alpha vector into the optimize API with a standard set of constraints and see where you land. You need to get to a gross leverage of 1.0, and probably reduce the turnover and number of stocks in your portfolio, in my opinion.

@QT,

Are you running out of memory? Perhaps try the round_trips=True option on a shorter backtest using less initial capital (1MM perhaps)?

Regarding the number of stocks trading I personally don't think that's too many. If you have a working/predictive model you'd want to place as many independent bets as possible in a universe of stocks where the model works, without like you said being killed by trading costs.

It doesn't order using Optimize API, but are you using Opt API to constrain Risk (to me it appears so, but I've been wrong before ;)). What's the reason why you can't use Opt API for ordering? If it's not working nearly as well when using Opt API then that to me is a possible indication that something 'funny' might be going on.

Other than not using Opt API for ordering and the high turnover, what other Contest requirements, if any, is it not meeting? If you could get it to work within the boundaries of the contest, you'd make a killing there and likely be of interest for an allocation if it continues to perform OOS for >6mo.

@Joakim, @Grant

This is the only Notebook I could run, the current version has made use of @Grant's turnover algorithm and now has a turnover which is too low (~4%). It meets all requirements except QTradableStocksUS, Turnover and Leverage. It now uses Optimize API for ordering.

Profitable trade average of 0.53 is quite impressive! Turnover you should be able to constrain using MaxTurnover in Optimize, right? If you raise the max turnover it might bring up leverage within the bounds as well.

Does it not work as well if you use QTSUS? If your profitable trade average is still over the 50% mark it would still be a good strategy in my view.

Regarding the stocks which are my biggest losers, what is interesting is that these are primarily pharmaceutical companies, I'd assume the major losses are caused by the algorithm picking up stocks which has had a recent fundamentals based change and has picked up the price action as a signal. Is there any way to filter stocks with upcoming announcements?

8/10 of the requirements have been met, bar leverage and QTradableStocksUS.

Hi Quant Trader,

Tucker here - I am a member of the team that handles trading here at Quantopian. Looking at your top holdings, I see a lot of small- and micro-cap names which tend to incur very high transaction costs in real life, especially on the short side. As the other users have pointed out, you should try using the QTradableStocksUS filter, which was created to help you easily filter out stocks that would be unrealistic or undesirable to trade at scale.

Best,
Tucker

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 @Tucker,

If the algorithm could be reformatted for QTradableStocksUS and maintain similar performance, would that be something of interest for you guys on the allocation team?

Thanks,

@ Quant Trader -

I would consider the contest as a stepping stone to an allocation. If you can get one or more algos into the contest, with decent performance, you'll have moved forward.

Also, there is leeway within the QTradableStocksUS (QTU), to create a sub-universe that may still be capable of meeting the overall requirements. For example, out of the QTU, you could try picking the smallest and most volatile stocks, if they are best-suited for your algo.