Site Meter The Lawyer Trader: Equity Curve Analysis: Can Prediction Beef Up an Edge?

Monday, June 3, 2013

Equity Curve Analysis: Can Prediction Beef Up an Edge?

I've been doing lots of research lately on trading systems and analysis of trading system results.  Equity curve analysis is not necessarily a new idea, however, it is something that I've not spent much time on until now.  So how does it work and what can it tell you?  Well, I'll share what I've done.  Surely there are some great methods that have been discovered and refined by others, however, I just started from scratch and started tinkering with some math that made sense to me.  Sometimes you can get some good results with doing that..other times you spin your wheels but you generally end up learning something.  The following breakdown is my version of equity curve analysis and I share this not to necessarily say it works and that you should copy it, but to possibly share some ideas that others can build on.

First, I started off with a mechanical day trading system that I created.  The system itself doesn't really matter, I'll just say that it's a fairly decent performing momentum strategy that makes about one trade a day on average.  I took a few years worth of daily returns and plugged them into a spread sheet.  This creates a time series out of the daily returns and the great thing about having this is that you can line it up in a column next to other pieces of data or indicators and look for patterns in what is useful.

Second, I took several other pieces of data like:  1, 3, and 5 period daily ATR (average true range) readings, volume, prior day return, 2 Period RSI and a few other pieces of data, and I lined up the indicator data with the returns.  Then I shifted the return row (moved it down/forward one day) so that the end of day data that I had could be used to try to predict the return of the system for the next day.  This exercise alone was very interesting.  To determine what factors (indicators/data) were useful, I ran regression analysis on the various factors and looked for significant R Squared and P-Value readings to tell me what factors were actually predictive and what factors/indicators were more random and not useful.

Third, after determining a handful of factors that regression analysis said was useful, I normalized the data by taking all of the factors and then divided them by that day's close.  This way, an ATR would be useful whether the instrument being traded was currently traded at $10 a share or $100 a share.  I also took a five period moving average of the data and then divided each factor's data point by it's trailing 5 day average.  This is particularly useful for volume because an instrument might trade an average of 50k shares a day for a while and then bump up to 300K shares a year later.  I wanted to isolate above average and below average conditions relative to the instrument's recent trading history and then compare those reading to values from several years before.

Fourth, I took a neural net program and several years worth of data and trained the neural net with the data..this is straight data mining at this point.  The most important part of it was knowing that I'd likely used relevant factors (b/c of the regression analysis) and I'd used normalized data so the neural net would learn on apples-apples data.  After I had a fairly decent neural net that was trained with a significant amount of good data..it was time to start predicting.

Fifth, I had the neural net predict the system's returns for a couple of years of out of sample data.  One problem with neural net predictions, at least the one that I've been using, is that it's often decent at catching turning points but it's not great at predicting magnitude i.e. how large the move is.  So I took the daily change of the neural net prediction (for example if yesterday's prediction was +1% and today's is +.5%, the reading would actually be a -.5%) and this helps actually gauge whether the system will likely make more or less money tomorrow.  

Sixth, I made the output binary and had the data transformed into 0s and 1s.  A zero merely meant the system would likely lose money and a 1 merely means it will likely make money for the day.  Now it's time to throw in some money management or position size rules based on whether the prediction for the system would likely make money or lose money.  The initial results for the plus day/minus day readings are about 60%..meaning that sixty percent of the time the prediction was correct.  This is not a huge edge but it seems to be a little better than random.

Seventh, I tested a basic money management rule based on the predicted profitability of the following trading day.  If the prediction said that the system would make money the following day, a double sized position was taken on the trades for that day.  And if the prediction was that the system would lose money, a half position was taken for the trades of that day.

And the results please...

It appears that there's some merit to this.  Below is a chart of the returns of the predicted money management system along side the normal system without the money management rules.  Also, there is a line of random money management rules too just to see what a random result would look like.  The random line was developed by having a random 0 or 1 drawn from a random number generator and then applying the money management rule based on the random drawing..kind of a control group.  The fourth line of the graph is the difference between the prediction money management system and the straight returns of the system.  Here's the chart:


As you can see, the prediction money management system outperformed the non money management system by about 80% (the horizontal axis is the cumulative returns, just in a non percentage format..so 1.0 is 100% and 2.6 is actually 260% etc.) over 489 trading days.  Furthermore, the random money management system was actually in the middle of the predicted and straight returns.  Another interesting aspect is that the difference from the predicted money management and the regular returns levels off and stays flat..this could be indicative that the further the neural net gets from the training data, the less accurate it's predictions become.

The results indicate that the predictions on the profitable trading days tend to maximize gains and minimize losses over time.  It's obviously not perfect, but what is in finance and trading.  The prediction seems to add to the edge that this system has and it helps provide a fairly linear equity curve.  The analogy that I've used to explain this concept is that it's like counting cards in black jack.  Keeping up the count doesn't give you a huge edge, but it gives you enough of an edge to tell you when to bet more or less which allows a good black jack player to slowly grind out a profit.  Also, the count doesn't necessarily tell you to play the cards different from basic strategy (ok, it does some but for examples sake we can say it doesn't).  The predicted money management rules tell me nothing about the buy and sell signals from the system, it just says to dial up or dial down the position size..much like the count in black jack.

So where to go from here?  A little more testing wouldn't hurt.  Also, there's some work that can be done with the actual money management rules as well..i.e. something a little more complex than bet half or double for any given day.  I could easily run a solver program to optimize the position strategy, but that type of curve fitting is getting a little ahead of yourself if you're just testing to see if there is an edge to begin with.  Also, I could test the actual buying a selling rules based on the predictions..such as, let trades run longer on profitable days and cut losses quicker on predicted negative days.  I might dabble with some of these extensions, however, the more rules you add to it, the more curve fitting and the less robust the actual system will be.

For now, I have a fairly decent result showing me there's an edge with running and applying this type of analysis.  Hopefully this all made sense and maybe it will spark some ideas for some that are out there testing the same types of concepts.

One last thing to note..the use of a neural net was not particularly important with the example.  For those unfamiliar with them, they are really just another type of forecasting tool.  One could easily come up with something similar using linear regression, polynomial regression, arima, garch..etc.  Any type of forecasting can be used and combinations of these different methods can be used as well.  Just didn't want anyone to think that if you're not knowledgeable about A.I. and neural nets that it's not worth bothering...that is not the case at all.

Take care and good luck with your trading endeavors.

TLT

2 comments:

Blogger said...

Did you know you can shorten your urls with LinkShrink and earn cash from every click on your short urls.

Blogger said...

Find out how THOUSAND of individuals like YOU are earning their LIVING from home and are living their dreams TODAY.
CLICK HERE TO DISCOVER