May 6, 2016

Is This Algo For Real?

I received the following short and direct question by email: "Is that algo for real? 40,000%?" It was referring to chart #11 in my last article: A Quest for Stock Profits – Part II

My reply was rather direct too:

Yes, and the trading procedures used are perfectly legitimate operations. They all survived within their coded limitations. There were no errors in the code, mathematical, logical or otherwise. No gimmick or deception. Just plain Python programming.

 

For me, the real question would have been: would you trade like that?

Personally, I would make some modifications to this strategy before even considering it. It is not my preferred strategy. It is wasteful of capital resources, has too many switcheroos, it is shackled to constant parameters, and makes as time progresses bigger and bigger bets. My way of saying it should be better controlled. Those are all subjective points of view. However, they can all be addressed and fixed.

Nonetheless, my latest iteration did show that it was more than just productive. Even in its current crude state, it is showing that it can be done.

Some might think that the charts I've posted in the cited article are not for real. They should give them a second look. They might not like them or find them interesting, but basically, it is not my problem.

Regardless, I am not the designer of this program as I have said before. Most of it (≈ 99.8%) is someone else's code. Prior modifications brought to it had made it quite a different program than its original version (see chart #1). And it is on the modified version that I added my own. So, to those who have previously improved on the strategy's design, thank you.

The received email question kind of implied as if something was wrong or some wrongdoing was at play when all you have is a program. The prior program version is still available on the Quantopian forum. It is in plain sight for anyone to analyze, clone, modify and execute.

A Quantopian forum member in a recent post describing his own program modifications came to the conclusion that: "... it's a mighty fine example of curve fitting." I disagree on that. Sorting 700 stocks by capitalization and return is not what I would call curve-fitted. It is just a simple stock selection process, and not that original either. It has been around for ages.

My only contention on this trading strategy would be on the validity of the price data itself. I have no reason to doubt the integrity of the price database provided by Quantopian. If the stock price data as provided was not reliable, then everyone's every simulation would be in doubt.

You have these simulation conditions. The price data is guarded and protected by Quantopian. A program is executed somewhere in the cloud on their servers using their data and their Python interface. Program code can be shared by those wishing to do so. It is the only thing that is shared: the code. And it is executed on Quantopian machines.

Having cloned someone else's program, it will give the same answers if executed. If you change the code, stock selection methods, program parameters, trading procedures, or simulation intervals, it is sufficient to have a different answer. It also changes the strategy's trading behavior.

But, whatever, it remains a program that is executed on someone else's machines under their setup and conditions. All you can do is supply code or variations thereof. And, code is code, it only executes if it has no programming bugs.

I saw some potential in the modified program, was able to extract it, and also demonstrate that it was there (see above-cited article). You could go from a do-nothing scenario as first presented (chart #1) with no long term alpha generation whatsoever to progressively not only instill some alpha in this program but also have it grow from within. I made it respond better to its inherent mathematical makeup.

Spoiler alert: my modifications to the program pertain to partly enhancing the submartingale properties of the strategy. In essence, letting the program, at times, if it can, increase its share holdings on some of its advancing stock positions. And since the selected group of stocks candidates as depicted in chart #5 (reproduced below) of Part I of the article are above zero in CAGR terms, they are expressing a positive expectancy for the taken group of positions.

 #5  The Strategy's Filters
The Strategy's Filters

(click to enlarge)

For such a statistical swarm to be productive, a basic requirement would be, on average, an upward market drift. It is what you have most of the time when the strategy is taking positions. Chart #5 will not let you buy without this positive expectancy. All I did was exploit part of these submartingale properties. And, the simulations I did, not only showed that these properties were there, but also that you could, in fact, exploit them.

A submartingale's expectation has for mathematical expression: E[P(t+1)|(P(1),...,P(t)] ≥ P(t). And if you look back at the cited (chart #5), you will observe that all price series having their CAGR above zero satisfied the condition. It would also imply that any positive return sorting scheme could have done a similar job.

Was the one chosen better than another? I do not know. I have only worked with this one. It might be better, or it might be worse than other alternatives. This would have to be tested.

So, where does the outperformance come from? From gaming the strategy itself, of course. Exploiting its submartingale properties by enhancing its betting procedures. This had for result: making big bets on big price moves while making small bets on smaller ones. This should come as no surprise, at least, it did not to me.

This does not make the underlying trading procedures predictive. That was clearly demonstrated by the original trading strategy itself (see chart #1 in Part I of this two-part series).

It is how you modified the program to follow your rules that made a difference. And, based on the various tests performed, it made quite a difference.

See the performance progression in the series of charts in those two articles. Look up charts #2, #3, #6, #7, #8, #9, and #10). All achievable by gaming the strategy. It makes the range of outcomes so huge that chart #1 appears insignificant by comparison. It would also appear that gaming the system might be a lot more productive than trying to optimize by finding the local maxima of a strategy parameter. It does raise the question: what should be part of optimization procedures? And what can you do to improve performance?

It is not by doing the same thing as everybody else that you will get different results.

 

Related Articles:

A Quest for Stock Profits – Part I

A Quest for Stock Profits – Part II


Created... April 9,  2017 © Guy R. Fleury. All rights reserved.  

Alpha Project