Back

Bubble Algorithm Using CAPE Ratio, MACD, and RSI

The aim is to capitalize in turbulent markets, aiming to buy stocks at the bottom of troughs and sell at the top of peaks. See how it worked on the S&P since the turn of the millennium. Please let me know if you guys have suggestions
Update Backtest








Pretty incredible performance @TimCo. Can you describe further what is the CAPE ratio? I think that might be using leverage since default leverage for equities is 2x. You might want to adjust it to SetHoldings 0.5, or manually set the leverage to 1 after adding the symbols as below: Securities["SPY"].SetLeverage(1m); at the very bottom of the Initialize() method.

Its still 2x S&P performance without the leverage and sharpe ratio is 4x better :) (S&P500 15 year sharpe performance - http://performance.morningstar.com/funds/cef/ratings-risk.action?t=SPY)
0

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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


CAPE is Cyclically Adjusted Price-Earnings ratio, one of excellent methods to determine fundamentally abnormal prices (for longer term traders). Great job, @TimCo! Just as I know, Shiller's data is reviewed after some time, sometimes 3+ months, so these results may be biased, let me check.

0

@TimCo, there would be delay of 1 month as for today Shiller's list shows January CAPE (estimate).
0

This graph looks amazing. @Jared Would you be able to also add CAPE as an monthly indicator?
0

@EdwardTse @TadasTalaikis @JaredBroad Thanks for the reviews guys, good to see the reaction. Go ahead and check out the stock plot for the S&P to see the buy and sell points! Its pretty smart. And Jared I will definitely look into that! More to come with this one guys
0

Amazing performance!
0

So it is Feb 23 and I just checked that Feb's CAPE data is out. I am not sure when in between Feb 9 and Feb 23 the data was released.
0

Looks like it was added on February 12th on yCharts - http://ycharts.com/indicators/pe10

Last Value: 27.49
Latest Period: Feb 2015
Updated: Feb 12, 2015, 7:01 PM EST

It hit 43 in 1999! http://www.multpl.com/shiller-pe
0

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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


@TimCo says the data was sourced from here: http://www.econ.yale.edu/~shiller/data.htm
0

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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


I liked this model and its "advertised" results. However, I have tried to backtest this model but can't absolutely reproduce any results. Any reason why I am unable to backtest it accordingly?
0


@Jared - I, too, had the same issue as @Mauro when attempting to run the algo. Any ideas?

0

@ Daniel and @Mauro - The reason no trades are placed is because the algo is using minute resolution and trying to apply its logic at the day's open with Time.Hour == 9 && Time.Minute == 30. However, it looks like the earliest tick of the day always comes in as 9:31. Not sure if 9:30 or 9:31 is correct, but apparently it's changed since the time of this post.

Since the minute resolution didn't seem necessary and performance was slow, I tried to convert it to a daily resolution.

So I changed the following
AddData("CAPE", Resolution.Daily);
AddSecurity(SecurityType.Equity, stock, Resolution.Daily);
And removed
Time.Hour == 9 && Time.Minute == 30

This appears to work, however I think I'm running into some async issues now that's causing duplicate trades.
Securities[stock].Holdings.Quantity is not reporting properly after a SetHoldings or Liquidate.
Do I need to throw a thread.sleep in somewhere to give Holdings time to update?
I'm new to the quantconnect platform and this is my first algo to poke with a stick, so any help would be appreciated.

0


When you make a call to SetHoldings what it does it submit a MarketOrder. If the market's are closed (as is the case with daily data which fires at midnight), then we'll convert the MarketOrder into a MarketOnOpenOrder. So you holdings aren't updated immediately because we'll need to wait for the market to re-open to process the fill.

0

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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Nice diagnostics @Jeff; you're correct the time behavior has changed since the post. Now the times are "end times" - the data is synchronized to the most forward moment which for minute bars is 9.31am after market open.

0

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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Update Backtest





0

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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Loading...

This discussion is closed