I've spent the greater part of the past 2 days fooling around with Python-based back-testers. Specifically, I was playing with the Quantopian Zipline tool and this really powerful library called fastquant. The development work was frustrating as I had to debug the code from other developers while resolving Python versioning issues on my own PC. I am having second thoughts of being my own CTO if I incorporate later this year.
After working for a day, I don't have a full-fledged article for a larger readership from Dr. Wealth, but I can share what I am experimenting with on this blog. One of the questions that repeatedly gets asked by my students is when can they exit their investments. As I focus on dividend yields and retirement planning, I don't have a straight-forward answer as I like to hold onto my investments as long as possible.
But times change.
We're entering the Interactive Brokers era and I have started making margin trades at $2.50 a trade and pay 1.6% for margin financing. Trainers need to react to maintain thought leadership in their respective fields.
( Do you want to be the kind of Visual Basic or .NET instructor in this modern age when open-sourced Python libraries are being churned out at a break-neck pace? )
One possibility of timing an exit is to employ two moving averages. A fast-moving average that mirrors short term price movements and a slow-moving average that mirrors a long term price movement. So for TA specialists, a sell signal occurs when the faster MA moves below the slower MA.
But I've never been comfortable with TA because:
- Who gets to decide on the fast and slow MA parameters?
- What evidence is there to show that setting the parameters can mitigate losses?
Fortunately, I have now developed a tool to run back-tests over a range of fast and slow MAs and I can now display everything on a heatmap.
Here are the MA cross-over results for the Lion Philip SREIT ETF based on three years of trade data.
When interpreting the heatmap, we want to focus on green patches - where the cells are green, the potential for positive returns when using this cross-over strategy exists in historical data.
So by inspecting the heatmap, a good time to sell the Lion Philip SREIT ETF would be when the 10-day moving average dips below the 180-day moving average for the counter.
I don't think this insight is ready for deployment yet because like many TA approaches this smacks a little of data mining - interrogating data sets until you find some trading nugget that can make you money had you invested in the past. You can lose a lot of money in the future if you don't play this right.
If I pursue this path, I would need to test the trading approach on an out-of-sample dataset. I also need to convince myself that green patches don't shift too much across time.
What I did learn today is that different stock counters require different moving average timings and one sure sign of a fixed prescribed MA crossover parameter in an investment course notes ma be enough for me to call bullshit on the guru in question.
No comments:
Post a Comment