Wednesday, November 02, 2005

System Analyzer and Y2K

I've been working on a heck of a project. I'm trying to create my own System Edge Analyzer using a bit of Python and mostly R. I still have much work ahead but thought I'd give you a preview as to the initial output of the project. And no, the FathersDay Edge is not about trading on Father's Day. I named it after the day I stumbled upon the edge which happened to be Father's Day.

Also, check out Jon Tait's discussion on Profit Factor and his sneak peak of his backtesting project.

System Analyzer - FathersDay Edge



Sector Return Trades WinPct AvgPL AvgWin AvgLoss PFactor Sharpe
1 Overall 20375.77 9510 78 2.14 5.3 -8.91 2.11 0.3
11 pyAerospaceDefense 50.2 15 73 2.6 4.56 -2.81 4.39 65
12 pyAutomotive 267.02 71 63 0.39 5.93 -9.21 1.1 4.33
13 pyBanking 298.85 74 86 3.08 4.67 -7.11 4.03 34.22
14 pyChemicals 235.89 48 85 3.23 5.75 -11.58 2.81 46.14
15 pyComputerHardware 1825.94 432 79 2.5 5.35 -8.18 2.46 11.9
16 pyComputerSoftware 5378.91 1333 79 2.13 5.14 -8.86 2.18 6.09
17 pyConglomerates 0 0





18 pyConsumerDurables 789.88 196 77 1.98 5.27 -8.73 2.02 14.14
19 pyConsumerNonDurables 411.83 112 75 1.62 4.9 -8.23 1.79 14.73
110 pyDiversifiedServices 2194.29 522 77 2.19 5.44 -8.85 2.06 9.52
111 pyDrugs 6024.43 1418 79 2.03 5.38 -10.54 1.92 5.64
112 pyElectronics 4420.77 1123 78 2 5.06 -8.7 2.06 6.25
113 pyEnergy 1109.56 245 80 3 5.69 -7.5 3.03 18.75
114 pyFinancialServices 350.55 97 74 1.99 4.87 -6.29 2.2 19.9
115 pyFoodBeverage 194.33 47 79 2.41 5.25 -8.1 2.44 34.43
116 pyHealthServices 3606.47 863 78 2.23 5.37 -8.82 2.16 7.69
117 pyInsurance 360.69 104 65 0.79 5.3 -7.73 1.27 7.9
118 pyInternet 2702.58 622 79 2.22 5.48 -10.25 2.01 8.88
119 pyLeisure 513.61 125 75 1.81 5.46 -9.28 1.77 16.45
120 pyManufacturing 1344.04 307 80 2.6 5.49 -8.78 2.5 14.44
121 pyMaterialsConstruction 452.44 92 86 3.99 5.73 -6.54 5.38 39.9
122 pyMedia 694.87 174 72 1.53 5.56 -8.74 1.64 11.77
123 pyMetalsMining 396.86 94 78 2.75 5.44 -6.59 2.93 27.5
124 pyRealEstate 82.87 28 64 0.27 4.6 -7.53 1.09 5.4
125 pyRetail 566.23 130 78 2.4 5.61 -8.75 2.27 20
126 pySpecialtyRetail 632.62 145 74 2.56 5.86 -7.07 2.36 21.33
127 pyTelecommunications 3063.99 775 76 1.81 5.19 -8.99 1.83 6.7
128 pyTobacco 64.03 13 100 4.93 4.93

123.25
129 pyTransportation 204.06 55 71 1.63 5.23 -7.14 1.79 20.38
130 pyUtilities 138.81 26 92 5.09 5.78 -3.29 20.2 101.8
131 pyWholesale 845 224 76 1.96 4.94 -7.66 2.04 13.07



Funny, how it has taken many hours/weeks and brain-fried late nights in order to input, process, output into the simple little HTML table above. Reminds me of a story about the Y2K problem.

I was working around the clock for hours, weeks, and months on end in order to get our administrative systems ready for Y2K. For those few who don't remember...the Y2K issue centered around the fact that legacy systems used the 2 digit years instead of the 4 digits. And year calculations and comparisons drive a multitude of systems. So, if you compare the year 05 against 99...you get issues. Capisci?

Anyways, while I was burning the midnight oil getting everything in order...either converting everything to 4 digit years or windowing the problem...I got a call from a friend of mine.

Friend: "Hey, have you heard about this Y2K crap? Everybody is just making this Y2K stuff up, I tell ya. You watch...when January 1, 2000 gets here...nothing will happen."

Me: "You're right, nothing will happen because programmers like me have been working our butts off trying to make sure nothing will happen."

Friend: "Huh?"

Me: "Listen, it works like the George Soros Reflexivity theory. If all the programmers know there's a Y2K problem then the Y2K problem grows less of a problem as more of the problem is understood and worked on by those programmers. So, you are correct, when January 1, 2000 gets here...nothing will happen."

Friend: "Huh? Are you telling me Y2K is or isn't a problem."

Me: "Ah, Forget it. I gotta get back to work."

Friend: "Whatcha working on?"

Me: "The Y2K problem...[hangup]"

Six months later my friend calls me up on January 1, 2000 after I had stayed up all night to ensure our batch systems ran correctly and was still in the process of verifying their results.

Friend: "Hey, Happy New Year! I don't mean to rub it in...but I knew it, I knew it, I knew it! That Y2K was just a bunch of mumbo jumbo! Like I told you before...here it is Jan 1, 2000 and nothing...NADA...happened!"

Me: "Happy New Year yourself. And yes, there was a Y2K problem and we fixed it so nothing happened like I told you before!"

Friend: "Huh? Now, Mike, how can it be a problem if nothing happened!"

Me: "Ah, forget it...go watch your football games...I gotta get back to work"

Friend: "Work? Work? On New Year's Day? What the heck? What they got you working on now?"

Me: "Y2K...[hangup]"

Later Trades,

MT

1 comment:

Mike Taylor said...

Hey Jon,

The edge parameters are not optimized for each sector. I tried doing that this past weekend manually and the results turned out much worse than the original...mainly because I was optimizing on the wrong variables. As you can imagine, I was extremely frustrated wasting all those hours over the weekend on something that made the edge worse!

Now, that I've got the initial working of this software going...I can analyze all the variables of the edge properly...so in the next few weeks I'll begin looking at the sectors one by one.

You are correct, this is a mean reverting system. So, those stats are displaying the perfect world of trading. Real trading the system has been a learning experience because I don't capture all trades the backtester does. Thus, I have to adjust my backtester for those issues to try and capture the more realistic world. For example, in backtesting I was getting wonderful results by closing the position out at the market's open. Real world...not the case. Turned out the selling at the close gave me better fills because more liquidity exists there. I could go on... :)

Yes, I'm using the modified sharpe...actually a trade sharp since it's based on trades and not the daily returns annualized.

I feel you on the sleep part. All this research and programming late at night is tough on the brain! In fact, your comments are pretty funny...because I have been thinking the exact same thing over the past couple of days...I need to get some rest! So, I plan on taking a break from all this in a few days and just chill out. Step away from the computer! :)

Yeah, I post late for sure!!! When I should be getting some sleep or at least watching something I Tivo'd. :) Actually, this reminds me of a great quote regarding our plight. I can't remember all of it so I'll post it in the morning.

Take care and get some rest!

Mike