Friday, October 28, 2005

Hunting In Packs, or Robots and Ethics

"If everyone out there has a trading robot, won't that affect the market?", is the sort of question we find follows on from, "Are you barking mad? Who would let a bit of software loose with their cash? Look what happened in 1987", etc.

The world appears to fit into two distinct camps on this last question. Those who feel that an airplane flies better and more reliably when on autopilot. And those who don't. Mostly this latter group is composed of pilots. I suspect that professional and serious amateur traders fall into the pilot category. Most of my unfortunate friends (and fellow travellers on trains and planes) who have asked me what my latest inventing adventure is, have much less of a problem with the idea.

Which leads nicely back to the first question because there are many more passengers than there are pilots out there. What happens when every man and his best friend's dog have robots of their own? The universe of traded stocks is not so large that chasing the latest hot move isn't going to be affected by every robot under the sun jumping on it. This issue became a problem early on in our discussions and work with making a robot.

My glib answer was the robots needed a sense of ethics about eating. Only eat when hungry. There are plenty of opportunities to graze lightly without hunting down every last quarry flushed out of the bush. Let some pass by, eat too much and the crop will suffer. We only need look at the Atlantic Cod fish stock levels to understand this.

Our back testing data indicated that for a significant size of robot population it was not unreasonable for them to gang-up and hunt as a single pack of a given size. But if the overall pack size could be kept lower then so much the better. Numbers suggest that for trading a limited stock pool (the robot constantly monitors the trading pattern of a number of stock) and if each robot was only trading capital of the average online portfolio amount, a pack size of 25,000 robots is acceptable.

In the short term we will be artificially limiting the pack size to 2,500 live robots while we test the effects of implementing alternative pack hunting strategies.

An only eat when hungry analogy is not as "barking mad" as you might first think. It means you eliminate the effect of excessive greed from the equation. Conversely, enabling every robot to work towards maximising its gain at every conceivable opportunity has the effect of quickly reducing gain for everyone, so it is ultimately self defeating.

We also know the trading characteristics of taking lots of small profits and can use this to help the robot adjust its behaviour in line with its growth and risk targets. If moral behaviour is the visible effect of an ethical set of values, the robot now has the tools for making additional judgements about its trading decisions in an ethical manner.

Barefoot Trading, Some Questions

In the past year I have discovered that the world of stock trading is full of 'methods'. Bewilderingly so. "Hardly surprising" do I hear you say, "given people have been trading since the dawn of time." What chance has a new method in this churning sea? In fact I found myself asking, is there even such a thing as a new method? Surely the basics are, well, just that, basic. Buy low, sell high. Isn't everything else merely a variant of this simple idea?

While talking with people far more experienced and knowledgeable about the world of finance than I am the same question keeps on popping up. Why is your method better or more reliable than the Leveraged Scalp Chopping technique? Or whatever the latest method might be. Usually I don't have the slightest idea. Either with knowing what a Leveraged Scalp Chopping technique is or how it might even be comparable. Which just goes to show that ignorance really is bliss, until someone tries to enlighten you.

Once the panic dies down I get back to basics. This is done by reminding myself that all we set out to do with the robot was create a means for the average Joe or Jane to make a reasonable return on a part of their capital. Moonshots are not part of the plan.

The goal was not to set out to beat the pants off every investment technique, stock, bond or whatever financial instrument some brain on legs has dreamed up for producing squillions of dollars out of thin air. Our goal in creating a stock trading robot is to help people like us reliably gain some of the benefits of trading.

All we set out to do was buy low then sell a little later slightly higher, repeating this process as often as practical to work the magic of compounding. You probably understand that it took us quite a long time to be able to say it this succinctly, since simple things are always hard to grasp. Complexity is tantalizing and amazing camouflage. But once we got the idea we started looking for this as an underlying premise in the 'methods' on offer. And of course we found it. Everywhere. Mostly it is implicit in the benefits created by following the method. But there it was. Brilliant!

Long before Newton got hit on the head by an apple, everyone knew that if you fell down it hurt. And that if you jumped off a cliff, you didn't go up, you went down - and the farther 'down' was the more it hurt when you finally got there. This implicit knowledge only becomes useful when you can put it to work. Now we knew about gravity as a concept who else had uncovered its workings. What had they to say about compounding in trading?

Compounding has been around as long as usury has been frowned upon by religion. Which probably means this is a very long time indeed. So I went back to the books again and of course searched the Net for more about its wonderful magic. Everyone agrees its magic. Also, everyone is unanimous it should be invoked at every possible opportunity. Unless of course you are the borrower. For the moment lets stick with the creation aspect, since if we have enough income the other aspect of compounding as a borrower need never bother us!

My search was now narrowed down. How did compounding and trading work together?

Follow on questions boiled along. What characteristics does a trading strategy taking small gains and experiencing small losses have? Was it regarded as a risky strategy? Did it give good, bad or indifferent results? If so, what conditions led to each type of result? Is there an underlying theory to guide the unwary?

I could find no answers to these questions. Probably I just didn't look into or stumble across the right place. So my next step was to do what we were taught in kindergarten. Make a model of the toy you want Santa to bring. Someone might just take the hint. On the other hand you also might also enjoy yourself and move along a little and stop annoying the grown-ups.

By this stage we were getting the results in from our first back testing runs. Our research robot, lovingly called Labrat because we regularly dissected it and used its re-incarnations over-and-over, was starting to show the sort of 'interesting' results scientists swoon over. This usually means an interesting pattern ermerges from the noise, hopefully a significant pattern.

While Labrat toiled away at the merciless number crunching the gods of avarice have assigned to him, I fell to modeling in a back-to-basics way physicists love and their wives throw up their hands in despair at. Compared to most performance modeling I have done this really was very basic. Try as I could to make it more complex the more the model told me it wasn't needed. And there in the model's data was the same patterns we were seeing in the backtesting. Eureka!

Once you have a model of a process you have the means of automating it.

Time now to switch analogies. Leave behind Newton, apples and gravity. Bring on airplanes and autopilots and the heady smell of Jet A-1 aviation kerosene on the morning breeze.

The interesting thing about autopilots is they give you the comfortable illusion of keeping your plane on course for Chicago, or wherever you are heading. In uncomfortable reality 90% of the time they only really know what is happening when the plane wanders off-course. If you have the picture of aircraft zig-zagging their way across the skies its not too far short of the truth. Each zig and subsequent zag, is tiny. Feedback keeps it on a track but correction can only be applied when the plane moves away from the desired heading for Chicago. Small adjustments create the illusion of the plane flying in a straight line. The magic in this is the model used to keep control. In the early days of flying pilots would lean out of their cockpit window and using glimpses of the ground adjust their headings by dead reckoning. These planes really did fly zig-zags. The pilot closed the feedback loop. The control model resided in the pilot's expertise. Today they drink coffee and chat up flight attendants! The plane appears to fly itself. Can we do the same for trading?

We labeled the trading strategy we evolved The Barefoot Trader because it had similarities with the back to basics approach of the Barefoot Doctors in the Far East. These practioners relied upon a basic set of proven medical tools, potions and expertise to dispense sound health care to large numbers of people. It turned out to be a very successful model which meant the overall strategy worked because it was built upon workable foundations. The sophisticated medical techniques are still available for the situations they address. In action the strategy ensured regular people have day-to-day benefits from a sound basic philosophy. This felt like a good plan to follow.

Our robot now has its simple model to guide its trading behavior and it can be used to implement a number of trading products. Theory and backtesting match. Live testing is underway and the results I have seen so far from Henry (we have moved on from rats to cats, naming the robots after the numerous felines in our lives) look good-to-go too. He is looking at the NASDAQ in the USA and the FOOTSIE in London and over the next year we will gather the live test results to compare alongside the lab evidence.

So, getting back to that first question: Is there room for another method out there? I believe so. Not so much because it is a better method than any other at selecting stock but because it exhibits a positive trading behavior. It can keep itself on track, know when its gone off track and adjust its behavior to get back on track once again. And finally, and maybe more importantly you don't need to become a pilot to fly this beastie. It runs on autopilot. Just buy a ticket and fly.

Saturday, October 22, 2005

"So! What is a Robot?", He Asked.

I think of a robot as something that does a job for me with minimal input and direction. It just gets on with a job I can or could do, creating an outcome for me that is in some way desirable - and hopefully a lot better than I can achieve. The small vacuum cleaners that scuttle about houses picking up crumbs and working their way around the floors are a good example. This type of robot does a physical job. My interest lies in the type of robot that can do an intellectual task for me. Hence the evolution of the share trading robot.

Some might argue that its not really a robot because it has no reach into the physical world, no actuators to pick up and move things or sensors to perceive what is happening. This view of robots is dominated by the course robotics has taken in the mechanical handling world. There is a whole other aspect to robotics concerned with goals and decision making. In this world the processing and evaluation of data within the context of the robot's reason for existing is a whole separate field.

Converting raw data into meaningful information, then evaluating information within the context of a body of expertise in order to achieve an appropriate goal is where I currently sit. Our share trading robot has been designed as a platform for working with decision making and tackles some of the many issues involved with creating practical answers that work in the real world for real people.

I call our software a robot because it does most of its work on its own, it has a simple task to perform, goals to work towards, some liaison tasks and a means of measuring its own performance. Compare this with a typical PC software application. Mostly they are what is know in the trade as event driven. A 'user' sits in front of the computer and drives the application through a series of actions. Its the user's consciousness that is in control, co-ordinating events to reach a goal. Apart from the times the machine is busy doing processing the significant goal of the activity is controlled from outside the code. With a robot the goal lies embedded within the code. This is about as clear as I can be at the moment about why I call our software a robot. In operation the user rarely interracts with the software, in fact once it is set-up the robot's owner (a term I use for what is in effect the 'user' of the program) is able to benefit from the robot's autonomous behaviour.

For the trading robot this means the owner sees an increase in their net worth as a consequence of its activity - with very little input into the process. It goes around picking up crumbs of profit so it can compound large gains.