Trading engine update

Sucess! As of this evening I have a live version of the new strategy engine running a breakout strategy in demo. Porting the old strategies over and refining the engine will likely continue for several weeks. I'm quite happy with how things turned out, but there is always more to do. I'm sure this will not be the last update to the strategy engine.
For the technical minded, let's just say hashes are really neat data structures, and without them this consolidation would not have been possible. ;-)


Updating the trading framework

It's been some time since I spoke about the engine behind the robots and strategies I trade. I had a wonderful coding marathon last weekend the result of which is many new improvements in the trading framework I am using. Although I solved several issues and cleaned up many things, there remains a piece I haven't quite been able to clean up.

I have the dilemma of writing code that is clean and maintainable, while having client side strategies that are really one-off programs. The server side backend pieces are abstracted away and objectified nicely, but that doesn't help with the client side implementations. Simply stated, I have a template I wish to use for all new strategies. This is easy to do. The trouble comes when I update the template (fixing a bug, adding new cool stuff, etc), the strategies of course don't get this update without me manually merging it across. This is not scalable as the number of strategies grows. The trouble with creating a generic class and having each strategy extend it is that each strategy has unique pieces and I don't believe I can abstract anymore pieces away. This is of course despite the fact each has a common workflow. Creating a generic client class is the answer (unless a programmer out there can shed some light). Regardless this is a wall that is slowing progress on new trading ideas.


Jesse Livermore, speculation, and people

I just finished re-reading Jesse Livermore's auto-biography,Reminiscences of a Stock Operator. What a wonderful read. In this post besides advocating anyone who hasn't yet read the text do so (you can find it FREELY available here: http://www.archive.org/details/ReminiscencesOfAStockOperator), I wanted to highlight a couple quotes from the book on people:

"I absolutely believe that price movement patterns are being repeated. They are recurring patterns that appear over and over, with slight variations. This is because markets are driven by humans and human nature never changes"

"On the other hand there is profit in studying the human factors, the ease with which human beings believe what it pleases them to believe; and how they allow themselves indeed, urge themselves to be influenced by their cupidity or by the dollar-cost of the average man's carelessness. Fear and hope remain the same; therefore the study of the psychology of speculators is as valuable as it ever was. Weapons change, but strategy remains strategy, on the New York Stock exchange as on the battlefield. I think the clearest summing up of the whole thing was expressed by Thomas F. Woodlock when he declared: "The principles of successful stock speculation are based on the supposition that people will continue in the future to make the mistakes that they have made in the past.""

"The message of the tape is the same. That will be perfectly plain to anyone who will take the trouble to think. He will find if he asks himself questions and considers conditions, that the answers will supply themselves directly. But people never take the trouble to ask questions, leave alone seeking answers. The average American is from Missouri everywhere and at all times except when he goes to the brokers' offices and looks at the tape, whether it is stocks or commodities. The one game of all games that really requires study before making a play is the one he goes into without his usual highly intelligent preliminary and precautionary doubts. He will risk half his fortune in the stock market with less reflection than he devotes to the selection of a medium-priced automobile."

On the surface, Livermore traded in a completely different world. Insider trading was rampant, stock manipulation and tip buy/selling was popular, bank runs were common... Hah, see not so different after all? In truth however, humans are the same. The same emotions that drove and controlled the market in Livermore's time do so today. We simply need to accept and understand this. I'll include a few more highlighting the inherent laziness and gullibility of man.

"The average man doesn't wish to be told that it is a bull or bear market. What he desires is to be told specifically which particular stock to buy or sell. He wants to get something for nothing. He does not wish to work. He doesn't even wish to have to think. It is too much bother to have to count the money that he picks up from the ground."

"At first, when I listened to the accounts of old-time deals and devices I used to think that people were more gullible in the 1860's and 70's than in the 1900's. But I was sure to read in the newspapers that very day or the next something about the latest Ponzi or the bust-up of some bucketing broker and about the millions of sucker money gone to join the silent majority of vanished savings."

How true! There is nothing new under the sun1! Re-reading Livermore's observations brings to mind the recent EVE Online ponzi scheme that rather successfully executed it's mission, netting a cool ~50k USD for its creators2.

All said, I will be continuing to study people. In understanding people, I will understand markets.

1. Ecclesiastes 1:9
2. http://www.evenews24.com/2011/08/14/the-1-trillion-isk-ponzi-phaser-inc-speaks/


Gaming and Trading

I have been undertaking further study of people. The analytic mind is constantly amazed at what others will do. Indeed, when time and abstraction from the situation allow, my own actions are utterly confusing for me to understand.

To this end, I got into online gaming. Specifically, online PVP or player versus player gaming. Obviously while exciting to play, playing against a computer has no comparison in dealing with a human opponent. While I did chose a game I enjoyed playing, I also made sure to chose something which required team play. That's right, while the game was PVP, it required playing as a team with 2, 3, or 4 other people you may or may not know. Success came to those who understood how people work, how to be a leader, how to motivate; indeed how to succeed at a common goal when given a random selection of people. Alexander the Great's success can be attributed to his mastery of this skill.

This gaming binge culminated in me running a semi-professional team, entering contests for real money (who knew people would pay to watch this?) and competing with other teams. I must tell you from the start that this ended as one can expect. We had some great early successes, but slowly and surely personalities began to outshine our success. Being human, mistakes are inevitable. As the fearless leader, I ultimately saw the team disband after an especially egregious series of mistakes and loses. It's almost like a bad dream. In just 2 short hours we went from a successful, united team to splintered and disbanded.

So what happened? In short, people. I had lessons yet to be learned on understanding people's actions and taking control. While this spectacular defeat is meaningless in the grand scheme of life, it's lessons are not. I experienced all portions of the emotional spectrum while undertaking play. I have raged, confronted my own disappointment and fears, and accomplished my own goals through what can only be called undying perseverance and study. It must be said I am not a gamer. This PC upon which I type is not a "gaming rig". I didn't have all the best tools, nor the natural skill that would allow me to succeed. But succeed I did. Before I ended the experiment a few weeks ago, I rose to the top 15% of players, the small percentage who can say they have a > 55% winning percentage1.

So what does this have to do with trading? Well, the untold story above is what it cost me. I said I accomplished my goals, but it was a year long struggle. My devotion and study was immense. I had to learn many lessons the hard way, and not unlike trading, had to pay my dues. Digging myself into a hole only made my eventual rise that much more difficult, but it also allowed it to be more rewarding.

Trading is about people. People make markets. To pit your brain and might against another is the greatest thrill in the world. To walk away successful is to know no greater joy. So many lessons have been learned about people, about leadership, and about anticipating other actions. I hope to apply these thoughts into my future strategies and having learned these lessons in a virtual world I trust I can carry at least some of the answers into the real world.

1. It's interesting to note a vast majority of people never rise above a 50% win ratio, many never even coming close. This corresponds extremely well to what we find in trading. It's the top 5% in trading who are truly successful, perhaps 10% more who manage to scrape by with minor success. The overwhelmingly majority hardly break even, with most losing much more than they win.