Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Kinda shocked. Does any algo make money?

I looked at some of the best algos here and when I backtest, they start losing money at some point. Is there any single algorithm that folks here are trading with that is consistently making profits? I mean are algos one more way that we are tricking ourselves that we can make profit in trading (Just like all other trading myths)

Sa

12 responses

People are trading algos, yes, but perhaps would rather not share them. If you have expectations of an algo with a Sharpe of 3 that never loses money, you might need to adjust your expectations, but that's not to say it's not out there.

An "algo" is merely a set of instructions which these days are usually used to run computers. In Trading terms any rule based recipe which can be described in code is an algo.

Rule based stock indices are algorithms. Over time, historically, they have tended to increase in value as growing companies replace those that have gone ex growth.

I'm sure that is not the answer you wanted. Some indices are rule based some have an element of discretion.

Not many people seem to appreciate that. Or the fact that there is no such thing as buy and hold of the market itself.

Thanks Simon. I backtested for 2015 YTD some of the best algos presented here and to my surprise nothing really performs consistently good. I am definitely not expecting them to never have a loss. I am looking for something like an increasing up-trend line and none that I backtested gave it. Please correct me if I am wrong

http://wiki.quantapolis.com/index.php?title=Algorithms

sa poth,
Try this by Jamie Lunn

Despite it is:

not hedged (contest required to be hedged ),
long only (contest required to be long and short any time ),
high concentration (there no requirement but referee may consider it discretionary)

It has
Low beta,
Positive Year to day return,
Low draw down
Low volatility.
Outperformed SPY by 5% this year and by 40% for 8 years.
Looks very stable in backtest on full market cycle (8 years)
And it is traded on real IB account.

Wow Vladimir. I loved this algo. Thank you for sharing this. I always test for these cases

  • 2015 YTD to see performance in recent times
  • 2008 Crash test
    • Test during 2013,2014 when market kept going up

This algo passed all tests with very minimal drawdown. The logic is too so simple. Is this the best algo on quant so far? I will open an IB account to trade with this. Please let me know if I need to make any changes to the code before I do live trade. Thanks again

sa poth,

All credits should go to author of the code Jamie Lunn.

Many of the best performing hedge funds rely on a very different sort of algo than you will find here. Most of us are limited to using algos which trade on probability; high performance is usually obtained by leverage. For reference see CTAs like Mulvaney or David Druz.

The "easy" money in the hedge fund world is made by insiders. Those who trade on inside information or who use their clout to gain some sort of advantage. HFT effectively works by exploiting inside information on order flow and being able to deal faster than mere mortals. Hedge funds with enough clout will be allocated large slugs of profitable IPOs they will flip for a premium at the open. They will also be in receipt very often of information regarding deal and order flow denied to the rest of us.

Systematic trading often attracts people looking to find the end of the rainbow. The rainbow's usually hides dirty little secrets which are eventually outlawed. Prior to 1985 inside information was perfectly legal in the UK. NM Rothschild used it to benefit after Wellington's victory at Waterloo thanks to his private communication network.

You won't find the rainbow's end here. Just and honest approach by most people to find a slight probalistic twist to better conventional investment modes.

Hello Sa,
I think it is important to share algos so we might encourage someone else to explore new areas. So I’d like to add my thoughts in response to your question to give you a different perspective. Granted I’ll approach this more from a fundamental analysis point of view since that has not been explored fully yet. The books “Stocks for the Long Run” and a “Random Walk Down Wall Street” are good starting areas for any investor in my opinion.

Although I have only been a Quantopian member for about a month now, I’ve explored many of the shared algorithms and I came to a similar conclusion as you did. I ask myself: what problem does this algo try to solve?. Usually they compromise a balance between profits and risk. Typically, when trying to reduce risk you will reduce profits. If we could borrow an infinit amount of money, then we would opt for an algo with the least amount of risk with a tiny profit. Yet as demonstrated by this graph: http://www.vox.com/personal-finance/2014/7/22/5877329/less-than-a-quarter-of-americans-get-the-most-important-investment found in “Stocks for the Long Run”, stocks provide the most profit. However most people take the middle ground and still purchase some bonds because they have an aversion to risk (i.e. a large draw down).

The other aspect that must be considered is your investment timeframe. It is easier to make money when the market is trending (it either goes up or down) vs when it is not (moving sideways). A strategy that works well in a downtrend (eg 07-09) may not work well when the market is in an uptrend (eg 04-06) or when the market is moving sideways (eg Feb to July of this year). A strategy that works well for a short time period is called over fitted because it is not robust enough to generate profits over a long period of time.

Having said all this, I suggest you give fundamental analysis a look. All stocks represent companies. These companies either generate cash flow that exceed expenses which they can use to either grow the business to generate more cash flow (hopefully buying back shares or paying dividends to shareholders) or they operate at a loss and someday close. Fundamental Analysis revolves around finding the metric that best predicts future cash flow growth. All algos rely on past information to predict future movement. Just like some try to profit from a bounce after a stock has dropped (think potential energy in a compressed spring) others try to identify a company`s revenue trend from its balance sheet and income statement.

The algo that I have shared is a simple one based on what was shared in the Help & API Docs with a few personal modifications and some other shared lines of code. This algo invests monthly in companies with the lowest Price to Earnings ratio. This is a work in progress. Quadrupling the SPY is a good start. 3 areas I wish to improve are: a) reduce the massive drawdowns, b) explore other fundamental metrics such as ROA, ROE, PtoFCF, PtoB, LTDER, PtoCF, etc. that may generate better returns and c) to hedge by shorting stocks that have poor fundamentals. I`m glad Jamie Lunn has shared his code because I think it may help in addressing problem a). If someone has suggestions, please let me know. I also hope that if another Quantopian has an interesting algo that explores a new area that they will share it as well.

You'll want to rein in the negative cash that starts in 2011 down to -524k (and a hint of it in 2009).

Thank you for pointing that out garyha. I suppose it makes sense considering I allow for some buffer when I submit market orders knowing I won't always hit the current bid/ask. I guess up until this point I had never thought about accounting for that in an algo. I thought adding a simple "0.8*" before the weight in order_target_percent would solve the problem, however this was not the case in my trial runs tonight. Leaving 20% in cash and still having a negative cash balance at the end of the run seems a little odd, so I'll need to dig deeper to find a better solution.

Yep. So uncomment your record cash line and then as a start, consider below or more pinpoint within a for loop as get_open_orders(stock) instead, track_orders() can be useful if things stall, google that, maybe unfilled orders involved. Ideally you might be able to increase that .8:

def rebalance(context, data):  
    if get_open_orders(): return  

I implemented the cash line which helped me identify that the main cause for the -cash was that there were de-listed stocks. I added some code to remove them if they post their end_date. I had to add 'GLBC' to the flagged_stocks because it was trade halted and again affecting the -cash. After searching the forums for solutions to this issue, I realized there was nothing I could add that would resolve the issue easily. I don't mind having a stock get de-listed or halted, I just wish there was an easy code fix to just absorb the loss within available cash after another stock is sold. I don't think I'm the only one who avoids minute level backtests because of impatience and this still has an effect on my coding for now. (I deleted the previous post to upload a different backtest that now has a variable min volume based on the size of the portfolio).