Thanks very much for sharing this. Agree that it's super helpful / education for me to see coding and how people are using this. Your code solved one of my questions about creating large universes of ETF's and then checking to see if they existed at the time or not, so that I can run max. length backtests. And all the code is very simple and clean to me (as a novice programmer). Thanks!
I like the linear regression for trend analysis also. I've seen that on other Quantopian systems, but hadn't seen that much on other platforms I was on. I would suggest that you use limit or vwap orders on the entries. Even with large ETF's, can have very volatility intraminute pricing (and sometimes huge movements) that can lose you a lot of money without that. A single bad trade could really hurt. But, that will depend on 'time decay' of the pattern.
I am curious if you have studied the 'signal decay' (how important is it to get really rapid fills for returns). If so, how do returns 'fall off' with only checking signals once every 3 hours, once a day, once a week, once a month. If the fall off is large, what causes it? Is it the entries being delayed or the stop loss amounts?
I am also curious about Universe bias (although the universe feels fair). How much optimization has gone into the selection of these ETF's? Have you run any backtests / studies on various universes that are non-correlated with one another, but tend to 'exhibit trend behaviors' to see if it's a general pattern. The 'ideal' would be to have Universe ETF's selected 'mechanically' based on the degree to which they have trended over the past X period. So, I would think about a much larger Universe of ETF's to start. I did run some tests with a lot more emerging stock market indices in the mix, and the performance was much worse (large DD since 7/2011 or so). In theory these markets should work well (China, Brazil, Russia, Taiwan, etc). So, that would be concerning.
(Some of the indices I mixed in:)
'FXI', # My addition below here
'EWW', # Mexico
'EWY', # South Korea
I am also curious about any stop-loss testing that you did. Your current rule is pretty cool. I don't get it 100%, but see that it's generally the slope of the regression line modified in some way by time period. How sensitive are the results to various stop loss amounts and formulas? I would likely look at a 'constraint' for the maximum stop loss. Have you looked at 'volatility based stops' based on the volatility of the position itself and/or of the overall market? I have sometimes found these effective in the past. Have you also just looked at flat 'percentage based' stop losses that are applied equally to all positions? Curious what you found.
And how sensitive is the system to slippage assumptions and or various rebalance periods?
There are some markets that I have heard CTA's say trend more and exhibit more trend like behaviors (i.e. Asian markets and energies), and it might be interesting to test on groups of just them as well - however most CTA's trade a lot of different strat's.
It will also be very cool to combine this with more position and risk management logic - i.e. a 'constraint based' risk management at the position, total asset class and 'market exposure' levels.
These could be done, for example, with an algo that matches the 'slope based' position sizing logical with some volatility (risk) constraints per position (so after the initial 'linear regression based position sizing is selected it is put into 'risk budget' analyzer and re-adjusted - so that it stays within any position size and asset class level constraints). As well as potentially constrained 'beta' for the long and short sides each week or whatever (so there is a max. long and short beta component).
Most of the pieces for building this exist on the site.
But it's gonna take me a few weeks to build it. But thanks a LOT for sharing.
If I get time (won't be till early next week), I will check and report back on some of this. I am also curious about 'general effectiveness' of the signal versus it only being effective on this basket. Anyway, those are just some initial thoughts.