2.25.2010

Of Backtesting

The joys of backtesting. In my last post I described the framework I am utilizing for autotrading. Once the strategy is coded inside the framework, I can choose to run it in live mode, or I can choose to run it thru previous price quotes in order to get a historical perspective on it's performance. This is helpful to reveal bugs more than anything else. People will often "tweak" there strategies in order to gain good backwards testing performance. Unfortunately, this is also how many are scammed with the inevitable forex bots, and pretty graphs showing beautiful equity curves. Suffice to say, tweaking for the past is an exercise in futility, and borders on dangerous. While it is enjoyable to see a strategy perform on an unknown dataset, I have successfully run robots that don't backtest well. The reason of course is that the past is different from the future; which is of course different from today. The only thing that matters is how the robot is performing now, in realtime.

That's not to say backtesting has no place. As I said, it helps to reveal bugs, and can identify or disprove your thesis on the core of the strategy. For example, if I code a trend following system, I would want to backtest it on a dataset containing trends. This will help me to see if my idea on how to idenitfy a trend is correct (and correctly coded). The performance of the robot on this dataset is a secondary indicator, but again is most useful for determining proper code. If a robot wipes the account of otherwise experiences severe drawdown my strategy doesn't call for, it usually means there is a bug somewhere. Typically you can no more always be wrong, than always be right. Either one is a cause for investigation. Or you found the grail. Heh. My money is on a bug!

Of Frameworks

When one considers how to approach trading there are alot of upfront choices to be made. Which market to trade? Shall I trade or have someone or something do it for me? What philosophy or strategy will I employ with trading -- aka what edge am I seeking to profit on? My goal is to use fundamental and technical analysis to determine where edges may lie and attempt to profit from them. Since I am human, I am delegating the grunt execution to a machine, and instead employing my time to analysis. This is otherwise known as autotrading.

While there are many packages of there to support such endeavors, I have written my own framework to accomplish this. In a nutshell, I have separated out the execution layer, data layer and logic layers of a trading program. The execution layer takes care of the communication and physical trade execution at my broker. The data layer is separated out to render feeds of price and other information for use by any particular strategy I am running. Finally the logic layer is separated out into individual strategies running within the framework.

It sounds much more complicated than it really is. But having this proper framework allows me to code strategies easily; and then run them thru backtesting or live mode. I suppose I would be remiss if I didn't also mention I did this all in PERL.

2.18.2010

Look Ma, I called a top!

While working on writing my robots, I decided to start playing with a long term concept of position building with a directional bias. Say that three times fast. Suffice to say my initial position did so well I closed it for a solid 3% gain. Whoops! There goes the long term experiment. Nothing like calling a top, and getting out on the intra-day bottom as well. My robot to trade this strategy is still in the testing phase, so I decided to take the profits off the table for today and let the robot do its job when the time comes.

Of Systems

Creating a trading strategy isn't something to be taken lightly. It's important to remember we're running a business here. For practical purposes, I'm going to codify my thoughts on trading into trading robots. I have several in various stages of development. The concept behind having multiple robots is simply to target and profit from several different trading environments. Running them concurrently should in theory allow me to profit in any environment. Hehe. Any known environment 1.

1. You don't know what you don't know -- hence I cannot trade the unknown. But, if Nassim Taleb has shown anything, I can profit from it.

2.13.2010

Step 3 - Becoming Capitalist

So, we've cleared our time, and discussed our needs. Now we can begin to spend our time as desired. To meet our needs however, we're going to utilize trading. Times have changed, but the art of the buy and sell hasn't. Trading evokes the most basic of human emotion and thought. It pits one versus everyone with direct and real consequences. Like heros, we cheer and admire those that can seemingly do the impossible.

For our purposes I am not going to use "The Stock Market". I won't be messing with Wall St here. At least directly. I am not so naive as to think one can escape the grasps of the elite corporations and those with money. I won't seek to defeat them at there own game. However, working for change and revealing the evils that lie in this upper echelon of society is a worthwhile, and indeed necessary pursuit.

So, what sort of trading shall I be attempting? One can trade anything -- even in modern day it is possible to make a living buying and selling physical goods 1. I will take the luxury of having virtual markets buying and selling paper; or really exchanging bytes between computer systems 2.

Forex. This fringe market, so liquid, secretive, and largely unregulated is where I shall participate. In many ways, this wild west of trading markets suits the personality of the transition. But the freedom given in such an unregulated market is too wonderful to give up 3.

We will take advantage of this freedom in many ways. For one, the retail investor such as ourselves is now allowed to "play" with the big boys. This was not always the case. Neither was the ability to trade instantly. And perhaps the biggest draw is that anyone can play. With as little as a dollar, you can take a position 4. Despite all the traps and costs lined up against you, it is definitely possible to make money in this market.

1. See "Around the world in 80 trades" book and BBC special as an example of this
2. Many modern exchanges are now simply the transfer and flow of information. Nothing becomes real until it is settled and withdrawn into the "real" world so to speak. In these days of continual rollover, the line between the "real" world and the digital one continues to thin.
3. Don't be naive here. This freedom means those who would take advantage of others, or cheat, etc, etc both can and will. The protections afforded by more regulated markets simply aren't here.
4. This is one of the reasons why Forex is full of brokers catering to the gambling type. Easy access, no upfront costs, and 400:1+ leverage makes it easy to rob from the unsuspecting "investor".

2.08.2010

Really, what is money?

So we've talked about money, attempted a definition, and left ourselves still wondering and asking questions. After all, what is it really? Does it represent stuff, or happiness perhaps? I am going to attempt a broader view of money here. Simply put,

$ = Δt

Money is a derivative of time. "Time is money". Indeed. Defined as such, money then is simply a resource.

What is money?

Given all this talk about meeting needs and becoming a capitalist, I would be remiss if we didn't attempt at least a cursory definition of money.

Money at it's heart is a store of value. In our perfect world, one could suppose it represented a stable store of value. Reality tells us otherwise. In our world today, most would pick up a dollar or euro and consider it money. This is fiat currency - meaning it's value has been declared by some authority. In the case of the dollar or euro, it's been declared by the central government. These bills represents debt. US Dollars are really IOU's - not by the US government, but by you. Promises that you will (or more specifically your children) pay back what has been borrowed. Modern finance revolves around a world of so-called experts, central banks, and government authority. It's really a fragile and thin system based ultimately on trust. You do trust your government don't you? Remember the power is always from the people. Someday, the US Dollar will be worthless. It will go the way of all the fiat currencies have gone before. I don't think I've unearthed any big surprises here for most readers.

Step 2 - Meeting your needs

Ok, so our time is all our own now. Hurray! There is nothing like the feeling of quitting your job. Suddenly you are free to do as you wish, at least for the moment. The world lies before you, and the feelings of youth and invincibility overwhelm you again. Being afraid of commitment had its upsides. Who wants to exchange 30 years of there life for a shelter, aka home? I think I missed the memo on that one. But I'm getting ahead of myself.

I still have needs to be met. My body will need food soon, and water for that matter. It will also need shelter; clothing and a place to sleep. This are but the most basic of needs. And like most Americans I'm paying someone to meet those needs for me. As I enjoy living, I still need a way to meet those needs without being a wage slave.

Meeting them myself is a feasible option. Indeed, my choice is simply the method I chose. I was already meeting my needs. Thus far I have been exchanging my time for money. I then exchanged this money for my needs. Becoming a capitalist would mean I value my time. Exchanging such a valuable resource for what indirectly results in my most basic needs isn't a good return on my assets.

Let us reconsider how to meet those needs. I could chose to exchange my time for food, and shelter directly. This would seem to be a better exchange, although it would still utilize my finite resource of time. The pitfall here is placing myself in a situation not unlike slavery. If I am unable to give my time (aka work), I don't eat. For example, say I pursued this strategy by buying a bit of land and building a garden upon it. That garden will not bring forth a harvest without work. That investment of time needs to be considered.

Indeed, if time was to be valued most I could cease 'working' now; in the sense of the modern day, 9-5 job. Living in a field with a tent and dependent on nature for food would meet all my needs and cost me very little of my time to setup. However, this is not a desirable arrangement 1. Freeing up all of one's time is futile.

1. Ecc. 2:24 There is nothing better for people than to eat and drink, and to find enjoyment in their work.

Step 1 - Quit your job

Quit your job. Really. Without warning, much thought or regard for consequences. I did. I'm becoming a capitalist. Be in control of your time, your money; your life. This will chronicle the journey of transitioning. From trading my finite time and my brainpower for money of dubious and relative value, to spending my time as I see fit.

I suppose some introduction is in order. I am a typical 20's male. Married, but unwilling to commit. Smart, energetic, talented; and burned in by corporate America. I've spent my life till now making the assumed societal choices. I pursued schooling with vigor, noting it had merit and value whereas sports did not. (Seeing some professional player salaries, perhaps I missed the mark on this one) I left high school for college early, a move spurred on by my desire to begin life. My summers were spent working for money. The jobs were chosen of course purely by how much it might pay. College was a disaster that did manage to only last 3.5 years. All said and done, society had birthed another upstanding citizen. No debt, young, fit, and eager to work. It had all the images of an American dream. I got lucky after all. I landed a job square in corporate America working in IT for a fledgling company. In exchange for 5 years of my life, they gave me money. It wasn't a fair trade. So I ended it. Which leads us to step 2.