Back to Community
Fundamental Mean Reversion Algorithm

Hi All,

Can anyone give me some ideas about how I could achieve positive returns and possible beat the market using a mean reversion strategy similar to this? I threw this together rather quickly, but essentially, I want to use fundamental data (such as a p/e ratio) as a metric to measure when to go long and when to short. So for example, take a set number of assets with the highest p/e ratios and short them while simultaneously going long on assets with low p/e ratios. Again, this isn't the best strategy out there but I am a bit perplexed as to which fundamental ratios I should use as well as how to implement it to achieve my desired result. I would appreciate it if anyone would be willing to collaborate on this with me.

Thanks,

Rohit

Clone Algorithm
20
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: 58c20b74fa29245e507e1829
There was a runtime error.
16 responses

Here's what I have been able to come up with regarding a long-short strategy based on fundamentals.

The strategy is not fully beta neutral. Making it so crashes the returns, unfortunately.

I would gladly collaborate on developing something that would be potentially Q-fund worthy.

It would be great if you could recast the algo into one using Pipeline. I have never mastered the tool.

Clone Algorithm
20
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: 58aafc3cffcafd5df206b31a
There was a runtime error.

In case you are actually interested in trading something like this, I can contribute a long-only version with an added simple market-condition filter, which switches to bonds when times are bad.

Clone Algorithm
148
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: 58a711e8c3f31361d384b6a0
There was a runtime error.

Looks very nice Tim. For preference I would prefer to use shorter dated bonds. An interesting idea would be to trade the chosen Googenheim equal weighted 500 on a fundamental basis rather than individual stocks. Something I keep meaning to look at more closely. Especially as regards ML algos. Use fundamental data from the individual stocks to predict movement in the index itself. Personally I couldn't be bothered to trade a multiplicity of individual stocks but then I trade manually so perhaps that is not so surprising!

Thanks Anthony, your idea of using the fundamentals to switch between an index and a bond is a very interesting one. Here's a first (rather miserable) implementation. It sums up the fundamental scores of the individual stocks to form a score for the RSP. It then compares this value to the one from the previous month.

Clone Algorithm
4
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: 58c27d5f6fd91d62916ad0bc
There was a runtime error.

Here's a version of the long-only algo that uses 7-10y bonds (IEF). Is that what you had in mind, Anthony, or something with an even shorter maturity?

Clone Algorithm
148
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: 58c27f64f10348623c63c9e0
There was a runtime error.

Tim
IEF is fine but for my money I would be using probably 1 to 3 year. Over a few hundred years there is comparatively little difference in cagr over the yield curve so I wouldn't bother with the volatility of long dated securities.

But it's a nice algo and obviously the fundamental analysis implicit in it makes sense.

I am torn at the moment. I am half tempted to produce algos for Q, Numerai and the rest of the gang and half tempted to say WTF.

As well as my own trading and research of course.

Who cares if I disagree with their analysis of markets - give the punters what they have asked for!

For me Quantopian is all I know, I am afraid. I have only been doing this for a couple of years and never with real money, I must admit. But as a physicist, I find this sort of modelling fascinating. Because physics is essentially model building and here we have a small, well defined (financial) universe with its own (undiscovered) rules (laws) and lost of data ....

The shorter the maturity of the bonds, the lower the volatility of the results of the algo, it seems, just as you have predicted, Anthony. However, at least in the short term the return seems to diminish as well. I The use of SHY (1-3y) result in a behaviour close to staying in cash during market downturns, it appears.

Clone Algorithm
148
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: 58c298941cb56b623c9f1379
There was a runtime error.

Anthony, allow me a question, please.

Since you prefer to use ETFs in order to trade in a small number of instruments, rather than in individual stocks, do you mostly do some sort of tactical asset allocation with them, then?

Hi Tim,

I really liked the first backtest you posted and I would be interested in collaborating with you on something like that. What is the best way to reach you?

Tim
Yes indeed simple asset allocation strategies. A classic example would be the old 60/40 stock bond split with period rebalancing but adding in a momentum element. For instance if stock momentum has been positive over the last month allocate 60/40 on the rebalance, if not then 100% bonds for the following period. In backtesting it usually gives similar performance to the 60/40 spilt with lower vol and DD.

However, at least in the short term the return seems to diminish as well.

Over the long term very little performance on bonds is from price movement and over the cycles that will net out to close to zero. The vast majority of the return is from coupon. People argue that markets change and that back testing over short periods is valid but you won't see what I have just described unless you go into deep history.

Trouble is the HF industry and indeed the active fund management industry is so fixated on the short term. Their ridiculously short term track records are pointless. You really need to look at deep history and even then it might not have much predictive value. But better than a few years back to 2002.

Very short term history is much more applicable to HFT an intra day stuff where indeed markets have changed dramatically. Over the long, long term I don't believe much matters except economic growth for investment success.

But as a physicist, I find this sort of modelling fascinating. Because physics is essentially model building and here we have a small, well defined (financial) universe with its own (undiscovered) rules (laws) and lost of data ....

Wish I had been a physicist. But I imagine as a physicist you will be asking yourself some very deep questions as to predictability. I am deeply fascinated by the topic in all senses. Science, in my mind, is probably the only human pursuit worth the bother. The answer to the question "why" .... or at least "how"...

Thank you for your insightful thoughts, Anthony.

Do you think that in additon to profiting from the economic growth, one may nevertheless be able also to avoid major market downturns, either by insight, based on fundamental data, or by using some sort of technical analysis, such as the popular 200-day MA -- or is this just an illusion?

Hi Rohit,

I think the easiest way to communicate is by using the Q messaging system.

I'll create a copy if the algorithm and give you collaborator access to it.

Do you think that in addition to profiting from the economic growth, one may nevertheless be able also to avoid major market downturns, either by insight, based on fundamental data, or by using some sort of technical analysis, such as the popular 200-day MA -- or is this just an illusion?

According to my backtests such simple methods have indeed worked since 1709 in the UK and at least since 1870 in the US. Based on monthly or quarterly re-balancing and a simple 30 day momentum lookback.

I would expect it to continue to work (if one can be bothered). But many would argue against that.