Back to Community
Random Forest Machine Learning Algo

I've been doing a lot with ML recently and ironically have had better success with simpler ML strategies (ie. less features and complex data). This is not an awfully complex algorithm and I thought some of you might be interested in trying something similar yourselves.

This strategy uses the previous 6 month prices of various SPDR Funds as training data to predict the following months price of the fund. Each month, the algorithm evenly invests in all of the SPDR Funds it predicts will report higher prices. Other than that, the only restriction I placed on the algorithm was to allow it to trade only once a month.

This is a black box algorithm that uses a random forest so if you backtest it yourself, you are almost definitely going to get different results. But, I've run over 25 backtests on this algorithm from Jan 03, 2002 to Jan 01, 2017 and the average return over that period seems to be around 270% (thus, the backtest I'm sharing is an average case). The SPY over the same period returns only 155%.

Like all ML algorithms, the more data you give this program the smarter (better predictive power) it gets. Thus, this algorithm performs better in the long run than the short run. For optimized results you'd want to run a 10+ year backtest.

Clone Algorithm
14
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: 596b7f4e2c000c5213e1953f
There was a runtime error.
2 responses

It gets a bit of a head start there because it doesn't start buying until SPY has dipped pretty low (almost -30%!). If you start the benchmark from March 3rd 2003 (roughly where the algo kicks in), SPY also achieves ~250% returns over the same period.

Tried adding things like GLD and TLT, to see if it would improve during crashes...

Clone Algorithm
15
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: 596bdbbe76c1285211a9b819
There was a runtime error.

If you rebalance weekly instead of monthly and pay no commissions (ala Robinhood), you get better stats.

Clone Algorithm
15
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: 596bdf5df08cfe4e2b0d59ca
There was a runtime error.