Disclaimer: I am not an investment advisor. When I describe my own trading activities, it is not intended as advice or solicitation of any kind.

20 April 2011

Revamping CS|MACO

NeighborTrader and I have been talking a lot about back-testing lately.  Back-testing is when you take a bunch of historical price data, and push it through a trading strategy to generate buy/sell/close signals as if you were running the strategy at that time.  Then you see how the strategy did, and try to extrapolate how it might do in the future based on those results. Ever hear the phrase: "Past performance is no guarantee of future results"?  Well, the same applies to back-testing, but a little information is better than no information at all.

NeighborTrader back-tested the CiG trade before he ever talked to me about it last fall, and he's been combing through data ever since to find more trades he can run.  I've been meaning to do the same with CS|MACO for quite some time, and I finally did this weekend.  I learned some interesting things, and I found a few changes I want to make.

I grabbed daily historical prices for SPY from January 1993 through March 2011.  I also grabbed the AAII sentiment data for that same period of time.  I wrote myself a little Python script to collate the data together, and then plugged all of that into a spreadsheet that created signals just like my present-day trading spreadsheet.  To this, I added some calculations to figure out the results of the trades, and compare them to simply buying SPY and holding it. 

As designed and outlined in this post, CS|MACO underperformed SPY over the 18-year period from 1993-2011.  Then I abstracted away all of the parameters so I could change them easily, and started playing around.  Next I evaluated various time periods based on the sort of market they covered: I looked for bullish and bearish periods, triangular moves up and down, and sideways choppiness.  I compared CS|MACO against SPY in bottom-to-bottom and top-to-top time periods, as well as a simple 5-year rolling time period throughout the 90s.  Once I had a feel for how CS|MACO behaved in various market scenarios, I started changing the parameters, and learned some things.

The first thing I learned is that the 25/200 moving average crossover component of MACO is far too responsive, and tends to trade into choppy sideways markets, losing money on every reversal.  To catch the really big trends, much bigger moving average periods, and more similarly sized periods, are far better: 200/300 seemed to be a good mix.

The next thing I learned is that the arbitrary 10% collar I have on the CS component is about right, but only for the buy signal.  This outcome was fascinating, and I think it gives insight into individual investor psychology.  If I'm right, it means that the CS buy signal (which is based on below-average levels of bullishness in the survey) is a leading indicator while the CS sell signal (which is based on above-average levels of bullishness in the survey) is a lagging indicator.

Bear in mind, this all just my viewpoint: I think we as humans tend to invest our emotions as well as our money, and we are very slow to accept that we are in a losing position and get out of it.  On the other hand, we are much quicker to jump into a new position if we think there is opportunity there.  The vast majority of us do not short-sell anything (my father thinks it's un-American and somehow Satanic), and so statistically, investors tend to become bullish faster, and become bearish much slower.

To handle this lopsided behavior, I changed things so that I could control the bullish/bearish thresholds independently.  Then I tried turning one and then the other off by setting them so wide that the indicator could never reach them (+/- 100% certainly works).  I discovered that turning CS off entirely made things worse: MACO, by itself, is not a winning strategy.  Actually, let me be clear: it does have positive returns, but it does not beat SPY itself.  Turning on only the buy (bearish investors) signal had the most positive effect. 

So, how about the results?  In rolling 5-year periods, CS|MACO was profitable in just about all of them - can't say that for SPY, not by a long shot.  When it beat SPY, it beat it badly; when SPY beat it, it wasn't nearly as big a difference.  The best part is that CS|MACO tended to diverge up from SPY in down markets, and pace it fairly well in up markets.  It really only lost ground in prolonged sideways chop markets.  And by prolonged I mean like longer than a year of nothing but sideways chop - that's pretty rare.

A big danger of back-testing is sample bias, also known as curve-fitting or false optimization. This is where you optimize your strategy against all the data you have, and assume that tomorrow will just like your data sample.  In a perfect world, we would like to use a sample of, say, 1995-2000 to train our strategy, and then make sure it still works from 2000-2011 before committing real money to it.  This is called split-sample testing.  However, I feel that the behavior of the markets and the attitudes and psychology of the individual investors have changed somewhat over the last 18 years.  For me to find a strategy that works well in the 90s, and expect it to continue working in 2012 and beyond, is naive.  So I have to flirt with that sample bias problem, but I try to watch for it and be aware that it is always there without falling into it.

Below is a graph that compares SPY to CS|MACO for the whole 1993-2011 period.  SPY is the red line, and CS|MACO is the blue line.  Notice how when SPY suffers, CS|MACO profits.  This makes it a very viable strategy for running alongside a standard retirement account holding index funds.  And for me, that's just perfect.

(click for the original size)

09 April 2011

April 2011 Ski Trip: Monday

John and Phil arrived a day later than planned, so Monday was their first day of skiing.  Rick was also supposed to join us on Monday, but unfortunately his mother was in the hospital; I hear she's doing much better now, for which we're all very thankful.

Having agreed to meet up with Andy at Solitude, I convinced John and Phil that it was the best choice for skiing.  Sunday night, we headed over to Lift House and Phil and I rented some powder skis - John stuck with his all-mountains.  We both got Volkl Bridge rentals, which are a little wider in the tip and tail than my AC3 Unlimiteds, but a lot wider in the body.  They also have what are known as "rocker" tips, which means that the scoop is wider and both ends of the ski are tapered.  This tends to give them more flotation in powder than a standard all-mountain ski.

This was a pretty minor change for me, and I found the skis easy to adjust to within a couple of turns.  Phil, however, was coming from Salomon X-Screams.  These are much older, straighter skis with far less side-cut.  John and I have been needling him to get new shaped skis for a long time, but Phil has claimed it doesn't matter... while being amazed at how much better a skier I became after buying my AC3 Unlimiteds.

In January, I beat Phil up pretty badly, skiing him right into the ground at Alta.  He vowed to get into shape over the winter and to get his revenge on me in April, and on Monday he succeeded.  He was hell-on-skis on these powder skis, and after a single run he looked at me and said, "you've been cheating!"  Ha!  Using technology to improve my abilities isn't cheating, Phil, it's progress.

We met up with Andy about 9:30, and he took us on two massive hikes on the left side of Honeycomb Canyon.  We were walking uphill, through powder, in skis, at 9500' elevation, for 45 minutes straight, twice.  Phil the triathlete had no trouble keeping up, but Mark the Xbox player was suffering pretty badly.  But the payoff was worth it, because when we finally pointed our skis downhill, we had nothing but pure unbroken powder in front of us.

In the video below, notice the difference between the tree run at the beginning and the powder run at the end.  The tree run is jerky and bouncy as I ski over other people's ski tracks.  The powder run, even though I'm intersecting Andy's tracks on every turn, is far smoother.  This is the difference between a good run and an awesome run.  If you've never powder-skied before, it can be a frustrating experience.  Every fall will wear you out, and every turn is a lot of work.  Until you have a run like this one... then you're hooked forever.


08 April 2011

April 2011 Ski Trip: Sunday

Last Saturday evening I headed out to Salt Lake City for my semi-annual ski trip.  This was going to be a pretty small group: just John, Phil, Rick (the owner of the house), and myself.  As it turned out, it was smaller than I expected.

As we taxied from the runway to the terminal at SLC, I turned on my phone and discovered two missed calls and a voicemail from Phil and John.  It seemed they had missed their flight, having gotten into a lively discussion about something or another, and not noticed that the gate had been changed on them.  Since that was the last flight from Detroit to Salt Lake, there was simply no way they would be coming in that night.  Rick wasn't due to arrive until the next day anyway.

I wandered over to the car rental counter, and asked for a 24-hour rental of the cheapest car they had.  Alamo gave me a fairly reasonable rate on a Chevy Malibu, and soon I was on my way to the house.  It was raining like crazy in the Salt Lake valley, which usually means snow up in the canyon.  I had heard forecasts of up to 12 inches of snow overnight, so I was excited for the next day of skiing, and sad for the other guys that they would miss out.

The house is in Sandy, which is a south-east suburb of Salt Lake, and in the foothills at the mouth of Little Cottonwood Canyon.  By the time I reached the house, the rain was mixed with snow.  I wearily unloaded my gear and climbed into bed, a long day complete.  The next morning, I found myself wishing I had thought to put the car in the garage.


After cleaning off the car and getting ready for a banner day at Alta, I jumped on the internet to see just how much snow they had really gotten.  Sure enough, 12" overnight, and another 4-6" expected throughout the day.  The canyon was closed for avalanche prevention, due to open 8:30, but requiring chains, snow tires, or 4-wheel drive.  I have no idea if my Malibu had snow tires or not, but I was certain it didn't have chains or 4WD.  The Dept of Transportation website didn't list any such restriction, though, so I figured I'd see what the signs said.

I left about 30 minutes after the website reported the road open for business, giving traffic time to die down.  The house is about 3 miles from the mouth of Little Cottonwood Canyon, and then another 7-8 miles up the canyon to Alta.  As I exited the subdivision and turned onto the main road, I immediately entered stop-and-go traffic: all skiers, all headed into Little Cottonwood, all hoping to get fresh tracks at Alta.  And they were all driving 4-wheel-drive vehicles.

When Alta's busy, Solitude is a great alternative.  I headed over to Big Cottonwood Canyon and had no traffic issues at all.  I zipped up the first couple miles of the 11-mile canyon at speed, behind a pick-up truck that I figured was also headed to Solitude.  Suddenly, on an innocuous-looking straight section of road, he fish-tailed.  We both immediately slowed way down, and sure enough there was black ice under the snow.  The remaining 8 miles were a hair-raising experience, as I felt unsafe going any faster than 20 mph.  Other cars ahead were having trouble as well, and soon we were a line of ice-skaters inching forward up the steep switchbacks.  There is one double-hairpin turn in this canyon, and I sat on it for about 5-10 minutes waiting for a small SUV several cars up to repeatedly try and fail to move forward, only to eventually get himself rotated around downhill and head for home.  If I felt I could do that without going into the ditch (and, in this canyon, the ditch is sometimes 50 feet deep), I might have done the same.  Whenever I took my foot off the brake and prepared to accelerate from 0 mph, it was a fight to make the car go forward instead of whichever way was straight downhill.  Not a great feeling.

I did eventually make it to Solitude, however, and soon I was booted up and headed to the lift.  On my first ride, I got to chatting with the other single skier on the chair with me; we both preferred to ski with others, and decided to ski together for a bit.  It was clear from his favorite-run stories that he was a better skier than me, so I made him promise to ski off if I slowed him down - for his part, he assured me I wouldn't slow him down.  Polite white lie - I slowed him down.

We skied together all morning, enjoying the fresh snow and bemoaning all the closed areas.  Ski resorts in the Rockies are a delicate balance: too little snow and they aren't as much fun; too much snow and they have to close vast acreages of mountainside while they make sure it's safe from avalanches.  One of my favorite areas in Solitude is Honeycomb Canyon, a black-diamond and double-black-diamond area accessible via Summit chair and on the other side of the ridge that forms the main Solitude groom area.  This entire area was closed on Sunday for avalanche control.

I had a lot of trouble with my shaped all-mountain skis in the heavy powder, and was pretty jealous of Andy's tongue-depressor fat-boy skis.  He was able to get up on top of the snow and stay there, as if he was surfing on a wave.  Around lunch time, Andy said he had some things to take care of in the valley and headed out.  Before he did, however, we exchanged phone numbers and determined to meet up for more skiing the next day.  I was sure Rick, Phil, and John would like him, and more is always more fun than fewer skiers.

Here's a video with a few clips from Sunday.  Unfortunately I spent a long time finding just the right soundtrack for it (Arrested for Driving While Blind, by ZZ Top), only to have stupid YouTube mute it for copyright reasons.  So at the last minute, I swapped the track out with one of their "approved" tracks.  For the record, they all suck just as bad as the one I chose.



02 April 2011

Happy 1978

In my ongoing year-a-month project, April is 1978.  Things are really starting to happen now, and this was a great year.  Sadly I haven't heard three of the five on the list yet, because Amazon is unable to ship for free at the speed of light.  Bummer.

Judas Priest: Stained Class
Rainbow: Long Live Rock 'n' Roll
Black Sabbath: Never Say Die!
Ted Nugent: Weekend Warriors
ZZ Top: Tejas - actually 1977, leftover for free shipping reasons from last month

Due to shipping issues mentioned above, I've only listened to Stained Class and LLRnR.  But both albums really rock.  I only discovered Ronnie James Dio around the time that he died, so hearing some of his great early work now is kind of bittersweet.  I can't wait until Ozzie goes off on his solo career and Sabbath-Dio are born.

The other pleasant surprise is Judas Priest.  Like most rock radio station listeners, I had only heard their top couple of hits: Breakin' the Law and Living After Midnight.  Unfortunately, judging them on these songs is kind of like thinking you know Pink Floyd after hearing Another Brick in the Wall.  Some of their early stuff in the late 70s exhibits pre-groove-metal traits, and is some of the best coding music I've come across since Disturbed.  I challenge anyone who enjoys metal to listen to Stained Class all the way through on a good set of headphones, without tapping their foot at some point.  I often find myself typing to the guitar riffs, which is fast indeed.  Maybe I should expense the album to my employer...

All the new stuff from the last few months is synchronized onto the Android, my noise-cancelling headphones are packed, and I'm headed to Utah in a few hours.  The plane is gonna rock.

EDIT: Tejas and Weekend Warriors showed up with the mail, just in time.  I haven't listened to them yet, but they are syncing to the Android right now for the trip.

01 April 2011

The Smallest Beginning

Round about the turn of the year or so, I shared a little snippet of some stuff I was doing in Flash.  I was trying to learn a new programming language prior to launching on a pretty ambitious project.  Over the next couple of weeks, I suffered some programming setbacks, including losing track of where I had done a couple days' work, and some frustrating language issues that I had trouble resolving.  Worse, my order for several Xbox games came in, and I discovered Minecraft.

This past week, I consciously tore myself out of some of my worst time-wasting behaviors and starting noodling around again.  The result is here.  Yes, it's silly and basically non-functional.  But it's a start.