Saturday, June 22, 2013

Momentum Mo Problems

In which I ask myself if I'd jump off a bridge just because all my friends did.  Wait, what?  All my friends are gone and I'm stuck up here with whatever chased them off a bridge?

The Super Secret Awesomeness Strategy

Fall of 2008 was not a fun time for investors.  Even Buy and Hold believers had their faith questioned as the value of their portfolios dropped by 30-50%.  From out of the shadows came calls for the Super Secret Awesomeness Strategy... able to trade punches with Buy and Hold during good times, yet calmly stand aside when everyone else panics. Why suffer, when you could have results like these:


(As you can guess, that is a very selective date range.)  So this is today's challenger for Buy and Hold's heavyweight belt.  A strategy that had been around for decades, but which gained renewed popularity in the last few years.  In the red squares... the Super Secret Awesomeness Strategy... aka Momentum Investing.

Strength in Numbers

The wisdom of crowds is a curious thing.  In an efficient market setting, it can decide that the price of rice is exactly $500 a metric ton (coincidently the only size available at Costco).  Or, in a low-information setting, it can decide that the best way to exit a burning theater is to climb over the person next to you.  These two acts are actually very similar.  In each case, there are lots of people doing what they think is best.  The difference is information.

Whether it is farmers weighing an ox, voters choosing a politician, or bidders trying to snag something on e-bay, there is some small piece of information contributed by each member of the crowd.  That's not to say it is good information.  It may be egregiously bad information.  But the hope is that it is balanced out by opposite opinions.  You want to sell me a soda for a dollar?  I want to buy one for a nickel.  We haggle and settle on fifty cents.  If that information is public, the next buyer-seller pair can dispense with the haggling, or maybe fine tune the price to fit their specific desires.  This is all pretty obvious, but what I'm trying to get at is the idea that you can piggy-back on what everyone else is doing and get similar results.  Because the price was decided by others, you can choose to ride along and get your Costco rice at a price that is somewhat reasonable.  (Just be careful that you are actually heading to an exit when someone pulls that fire alarm.)

One would hope that the market works this way too.

Oh, and since we are talking finance, I should probably make my disclaimer here: First off, I should reiterate that I am not a financial planner, and you should make your own financial decisions based on what is best for you.  Secondly, I highly recommend pyramid schemes.  They have gotten a bad rap recently, but I can totally get you in on the ground floor.

Anyways, if you let the masses determine the price of an asset, it will save you a lot of time and effort.  Yes, maybe you have a general feeling that the asset will go up... that would be why you are buying it.  (And if that asset is, say, the whole stock market for the next 30 years, you have a strong case for your thesis.)  How much should you pay for it though?  You could talk to random people who own that asset and haggle with each of them, or you can piggy-back on the trillions of trades a day (just for the NYSE) that have already worked out their haggling.  Even if they are each contributing a tiny amount of information, the overall market has a very well-informed price (which you may or may not agree with).

Indicator, I Hardly Know Her!

This brings up the two basic types of market trading you can do.  When people trade an individual stock, they might think, "Company X is very valuable and produces earnings that I would like a piece of.  I value those earnings at $10 or over.  I believe that the price is going up.  I like to end sentences with prepositions following."  They then buy a share if the price (which is determined by the crowds) reaches $10 and hold on to it until the price meets their value of the share.  This is investing based on fundamentals.  The idea is that you found an inefficiency in the market where someone disagrees with you on the fundamental value of something.

But what if we believe the market is actually efficient?  An alternative way to invest in an individual stock is to say, "The stock for Company X has risen recently.  Their chart shows an accelerating stock price that should continue for at least the short term."  They then buy a share at the market rate and hold on to it until the technical indicators tell them to sell.  This alternative is usually a risky (and expensive) play for individual investors due to our non-instantaneous information and the high transaction costs.

Instead of using technical indicators to buy an sell individual stocks, today we are going to look at buying and selling the market.  The idea is that there is a momentum to the market that makes the swings larger than would make sense from just the fundamentals.  In late 2008 the "average company" lost about 50% of its value according to the stock market.  Was that really true?  Did General Electric have half as many factories?  Did Microsoft have half as many Windows users?  Did Lehman Brothers have half as much money as they thought they did?  (Oh, wait.)  Anyways, the quick(-ish) rebound in the broad stock market (as measured by the S&P 500) shows that it was mostly the market's momentum that was bringing down prices.  Smart investors like Warren Buffet saw that and kept plowing money back in to the market because fundamentally everything looked cheap to him (but not to whomever was selling to him).

Taking the Bear by the Horns

To buy the whole market is quite easy.  There are mutual funds that will let you do it for 0.2% of your portfolio/year and exchange traded funds that will do it for 0.05% (plus a trade fee of $5-$10).  We aren't going to concentrate so much on the "how" for this post.  Lets focus instead on the "when".  One of the easiest things to measure in the market is the 12-month simple moving average (SMA).  For our purposes, we can look at the monthly value of the S&P 500 (available since 1950) and average the last 12 months.  These fit nicely into our spreadsheet typing the [in brackets] portion:

(A25:A784) = Date
(B25:B784) = Adjusted Close of the S&P 500
(C36) = 12-month SMA [=AVERAGE(B25:B36)] -> complete the column

To round out our data set for times when we can't have a 12-month SMA, we can just set C25:C35 to = B25:B35.  Any strategy dealing with averages over time will run into end effects like this, so we won't worry about it too much.

The technical indicator in this case is when the current value of the S&P 500 passes above or below the 12-month SMA.  If it passes below, we can expect that momentum is artificially pushing stock prices down (like Fall 2009).  If it passes back above, we can expect that momentum is artificially inflating  the prices.  Because the S&P 500 has grown (at a 7-8%/yr pace), most of the time we will see the positive momentum.  At that point we should be invested in the market.  If the momentum turns negative we should sell and hold as cash (or equivalent).  Similar to the Sell in May question, this is a binary decision, using the month's information to determine whether to be in stocks or cash for that month.  (Interestingly, this limits us to 12 trades a year, making it a somewhat fiscally achievable strategy.)  To model our binary decision:

(D25) = Market rate for that month [=B26/B25]  -> complete column
(E25) = Decision for rate [=if(B25<C25,1,D25)] -> complete column
(F25) = Starting Portfolio Value [=A25]
(F26) = Portfolio Value [=F25*E25]  -> complete column

Wow!  12-Month Momentum is going toe-to-toe with the champ!


I'd have to call this one a tie.  The strategies were neck and neck from 1950 through the mid-80's, but then increased volatility sent false "sell" signals which allowed Buy and Hold to take the lead.  But next, the 12-Month Momentum strategy showed its pugalistic prowess by calmly sitting out the worst of the two bear markets we've had in 2001-2 and 2008-9.  Unfortunately that meant it sat out much of the recovery of '09, for a final lead of 6% over 63 years.  To put that in perspective, it equates to 0.1% per year.  Actually implementing the strategy would have likely cost an unknown amount, but there is a decent chance it would be more than 0.1% per year.  This strategy does leave the portfolio value more stable, though, so if that has value to you it might be worth pursuing it a bit further.

Round Two

So if the 12-Month SMA challenger is so close, maybe a little fine tuning will unseat the champ.  Going in to this analysis, I thought the main drawback to a momentum strategy would be that you spend time (which I previously showed was valuable) out of the market waiting to get back in.  Because the information always lags, and the market on average is growing, you miss some of the "average" returns when the market is turning around.  Lets modify the length of time over which we are averaging to see if we can improve.  One way to do this is go with a longer average, such as a 24-Month SMA.  Another way is to go shorter, such as with a 3-Month SMA.


Ouch!  These two never really get off the ground.  The 24-month SMA portfolio experiences about the same number of transitions to-and-from cash (a little over 1 per year) as the 12-month SMA portfolio, but they are delayed by 1-5 months, so that the portfolio misses just a bit more of the good times and (probably more importantly) feels the downturns for just slightly longer.  This is enough to lose a little over 1% per year compared to the Buy and Hold or 12-month SMA strategies.  The 3-month SMA strategy simply gets too many signals to transition (over 4 per year), which keeps it in cash for an astounding 70 months longer than the 12-month SMA.  That is nearly 6 years of sitting around waiting!  Lest you think that we just haven't refined enough, I went ahead and ran a bunch more timespans:


It looks like 12-months is the optimal timeframe to average over in creating your indicator, and it just barely yields more than the market average.  Actually, if you add up all the months the 12-month SMA tells you to sit out the market, you end up on the sidelines for over 18 years (of the 63 years I'm looking at).  It's remarkable to me that this strategy compounds at all, and it is a testament to the yield you get during the time you are invested... a whopping 10.7%!

Technical Knockout

One final thought for today's post.  It isn't really fair to compare the SMA Technical Indicator Portfolio to the Buy and Hold Portfolio.  We've played around with the length of averaging, but imagine an extremely long SMA (simple moving average).  As the length of averaging time gets longer, we'd get fewer and fewer signals to switch between stocks and cash.  Because that would expose our portfolio to more growth in the market, the dip in yield we saw reverses itself and eventually you get no signals to move to cash.



So, actually, an alternative way to think of Buy and Hold Portfolio is that it is a Technical Indicator Portfolio whose indicator has never triggered a sell signal.

-----

Update!!!

It's Log, It's Log, It's Better Than Bad, It's Good!

As noted by Jared in the comments, showing exponential growth on a linear axis makes for tough comparisons between lines.  I promise I wasn't trying to deceive (well, maybe just a little).  Here is what the Buy & Hold, 12-Month SMA, 24-Month SMA and 3-Month SMA look like in log.



-----

Didn't answer your question?  Feel free to let me know in the comments and I'll include your ideas when I post more on this in the coming weeks.   If you want to get email notifications when new posts go up, send an email to subscribe+overly-complicated-excel@googlegroups.com to subscribe to the mailing list. 

Friday, June 14, 2013

They See Me Rollin'

In which they do a cost-benefit analysis of hatin'.


The Wheels on the Bus

Temperament matters a lot.  Case in point: a few weeks ago, while riding home from work, the traffic suddenly slowed down and from behind us I hear a loud "thwunk."  My bus had just been rear ended.  Everyone was fine, except for the tiny car whose front just crumpled.  Even its driver seemed ok (or at least aware enough to discretely slide her phone away).  It was a funny story (made much better in person because I could properly pronounce "thwunk" for you), but as I was sitting there on the bus for an hour I heard two distinct conversations.  One type started, "Dude, this is crazy.  Has this ever happened to you?", while the other type stared, "Dude, I'm never riding the bus again.  It's not worth it."  I know, only in Portland would everybody on the bus start their conversation with "Dude", but what it got me thinking about was how do we know if the bus is "worth it".

When my wife and I moved to our current apartment, we didn't think about the fact that she would be driving to work and I would be taking the bus.  It was just intuitive.  That said, her work is closer.  She's also more environmentally conscious than I am and the ticket price for her bus route is less than for my route.  All of that seems like it would switch our roles.  So that is today's goal.  Lets add up real costs to see why it makes sense for me to ride the bus and not her.

A Non-Ideal Gas Law

On the surface, it seems like this should be simple.  Does the gas to get there cost more than the cost of the ticket?  For her a round trip looks like this:


And for me:

So as a first pass it looks like it wouldn't make sense for either of us.  Of course, this is the simple case.  Since we know gas isn't the only expense that goes into the car, lets overly complicate it.

Four Car-dinal Virtues

The way I see it there are fixed costs of owning a car, and there are per-mile costs.  Fixed costs include the actual purchase, the license and registration, as well as the insurance.  These don't scale with how much you drive.  (Within reason, of course.  The difference between 10k miles and 12k miles per year is zero.  There is still a difference between 10k miles and 0 miles or 30k miles.)  Instead, these costs scale with how pricey a car you have and how good of a driver you are.  On average these costs end up being ~$16 a day (almost $6000 a year!).  Maybe I'll tackle this another day, but for the current post lets say that we are keeping the car, just deciding if it makes sense to use it for a certain trip.

The flip side of this is the per-mile costs. By my count you could group these into four categories.  Lets find the {inputs} we will need for each cost.  The first one, gas, we already mentioned.  It will only depend on {car's MPG}, {cost of gas}, and {miles traveled}.  The second cost is what to do with your car once you reach your destination, as there is often an associated parking fee.  This is pretty straightforward, so we'll just spread the {parking fee} over the whole round-trip.  The third cost is wear and tear on the car.    As a back of the envelope calculation I'm guessing for every 30k miles you need about $500 of tune up, $500 of brake pads and tires, and ten $50 oil changes.  This works out to $0.05 a mile, which is a figure I've seen repeated on several auto maintenance sites (backing out gas prices).  So again we just need {miles traveled}.  Finally, the fourth cost I'll throw in is carbon offset credits.  The market has determined a price of $0.011 per mile for offsetting the carbon emissions from your car.  This isn't quite fair as they must be assuming you have an average car (23 mpg).  Instead, you can convert that price (just multiplying it by 23 mpg) to get $0.25 per gallon of gas you consume.  Again we need {miles} and {mpg}.  All of these things could be split between multiple {passengers} if you carpool.

We can do the same cost analysis for the bus.  They only have two costs, and the first one is easy: the {ticket cost}.  Once again, we'll go for round trip.  They also have a carbon offset, and this one is a bit more tricky.  Buses get lousy gas milage (about 5.5 mpg once you convert from diesel to regular), but spread it out over many {passengers}.  My commuter bus routinely fills up its 45 seats, but some routes are nearly empty.  By using the {bus mpg} and {miles traveled} then dividing by {people riding} we get gallons of gas used per passenger, which can get us to our carbon offset credit price.  What happens when we add these things up?

For My Wife's Commute:
And Mine:

 So now the bus seems to make sense for both of us.  Still not the intuitive result, though.

As an Aside: Taking a Test-Drive Around Portlandia

Before I go any further, one cool thing you can do with this model is look at when it makes sense to take the bus on smaller trips.  Other than parking, the price to make a trip by car scales linearly with the number of miles you go.  The Portland bus system is a fixed price of $2.50 for 2 hours or $5 all day.  So if you know your cost of parking, you could choose your best method of transport based on the following cost curves (assuming one person in the car and average 23 mpg).


Is your trip less than 10 miles with free parking?  Take your car.  Are you going downtown where the parking is a $5 minimum?  Take the bus.  Are you visiting someone 5 (round trip) miles away where the parking is $2?  Take a bus if you plan to stay a short time, but a car if you would need the all-day pass.  Based on my own Portland bus experience, I'm guessing the buses travel at a rate of 15 mph in the city, which means you could just as easily scale the axis by a factor of 2 and call it the "number of one-way minutes traveled," which may be easier to visualize.

This chart also explores the idea of a free-ride zone and tiered pricing, in that it doesn't really make sense to pay for a bus ride less than 20 minutes unless there is a parking fee, while an hour and a half ride might be worth $10 to someone.  Downtown parking is in the $5 range, so Portland's recent move to a single price structure has little impact on their overall downtown bus usage.  Oh, and as an aside to this aside, look at how awesome the mpg can be when you get a full bus... it's in the 300 mpg range!

Time is Money

Getting back to my earlier question, why is it that my wife's commute makes no sense by bus.  The answer really comes down to the fact that there is no direct route.  While it certainly is annoying to spend 20 minutes and $6.30 in driving expenses to get to work, this is dwarfed by the 90 minutes it would take by bus.  We need a way to put a value on this time.

One way we can do this is to think about our "real" wage.  This is the value that you put on your time.  By implicit agreement, if you work for money you have agreed that a certain amount of money is worth at least a specific amount of your time (if not more).   If you make $40k a year, your per hour wage is just under $20 an hour for a 40 h workweek.  But if you commute to work, think about work off the clock, or spend any money on clothes/computers/vuvuzelas for work, you don't really make $20/h.  Maybe it is more like $15/h. This is your value of time.  Do you really love your job?  Would you do it for less money?  Maybe your time value is more like $5/h.

If your time value is $10/h and you spend time not being productive, it costs you $10/h.  This may be fine if you are spending time playing with your kids, reading a book, or watching an episode of dancing with the stars.  You agree that the lost time is worth $10, otherwise you would work and earn yourself $10.  This is obviously simplified, and because your work/life balance is not a free market you could end up mowing the lawn for an hour (for no pay) when you would rather read a book.  Ideally you'd pay someone less than $10 to mow the lawn for you.

So, why is this important again?  Well, imagine your time value is still $10/h.  If your choices are to drive 30 min (and lose $5 of productive time) or ride the bus for 90 min (and lose $15 of productive time), that money needs to go into the car/bus equation.  This can be mediated somewhat by being productive on the bus (or in the car).   If you do some work on the bus, you might be able to be at work for less time.  If you read a book on the bus, that is "productive" time that you don't do at home and still doesn't count against you.  The way you "lose" the money is to sit around doing nothing or doing something you don't want to do.  You wouldn't pay $10 to do that.  Lets apply this to our model.  I haven't shown you how I defined everything, so lets do that now (typing the items [in brackets]).

Oh, and you can follow my work here.

You Details
Time value (per hour) = C5

Car Details
Car route (miles) = C8
Car trip time (min) = C9
Productivity in car (min) = C10
Price of gas ($) = C11  (Currently $3.77 near me)
Mpg = C12     (Average for cars is 23, but we'll allow any value)
Gas used = C13  [=C8/C12]
Parking = C14
Total people = C15   (1, unless you are carpooling)
Cost of gas per person = C16   [=C13*C12/C15]
Cost of parking per person = C17   [=C14/C15]
Cost of wear & tear = C18   [=0.05*C8/C15]
Cost of lost productivity = C19   [=(C9-C10)/(C5/60)]
Cost of carbon offset = C20   [=0.25*C13/C15]
Cost of driving = C21   [=SUM(C16:C20)]


Bus Details
Bus route (miles) = F11
Bus trip time (min) = F12
Productivity on bus (min) = F13
Mpg (equivalence of diesel) = F14 = 5.5
Gas used = F15  [=F11/F14]
Total people = F16   (10 = low use, 20 = moderate use, 45 = seat capacity, 60 can fit with standing)
Effective mpg = F17   [=F11/(F15/F16)]
Cost of (round-trip) ticket = F18
Cost of lost productivity = F19   [=(F12-F13)/(C5/60)]
Cost of carbon offset = F20   [=0.25*F15/F16]
Cost of bus = F21   [=SUM(F18-F20)]

And lets throw one more in:
Walking details
Time = F5
Productivity while walking = F6
Cost of walking = Cost of lost productivity = F8 = [(F5-F6)/(C5/60)]


Running the Model... Or Driving it... Or Taking It On The Bus, I Guess

Now, when you plug in my wife's commute, it seems much more obvious that driving is the economically favored option.


Which is different than for my commute:


Her conditions could equilibrate if she valued her time less (somewhere around $5 would work).  Alternatively, she could make use of more of the time on the bus.  But that is tough!  I already make the assumption that she could work two hours, and with two bus changes each way sleep isn't an option either.  My route is simpler, with one bus change, meaning I can work or read for 90 of my 130 minutes.

Obviously productivity can change a lot with minor input changes.  Does the bus evade traffic?  Do I enjoy driving enough to count it as productive time worth $15/h?  (In short, no.)  Some of this productivity can be conceptualized if you look at walking to work (noted top right but not added to the graph).  It would take me about 7 hours to walk the round-trip.  With a bike I could do it in 3.  I like walking and biking, but only for perhaps the first hour, so after that it is non-productive time.  Am I willing to pay the extra money to get some of that time back?  If you are using this model as a tool for your own circumstances, (and I recommend you try it), keep in mind that some things are flexible (like your love of walking... in the Portland rain) and some things are fixed (like a monthly or yearly bus pass that saves you money).

Interestingly, you can also go backwards in the analysis.  If you know that you like your bus commute at least as much as the drive, you can back-calculate from your lost productivity calculation how much you value your time.  Maybe you realize that you value time at less than $5/h.  It might make you think twice about paying someone $10 to mow your lawn for an hour.

Taking The Long View (past Longview)

One final note.  My wife and I love going to Seattle for the weekend to visit friends and family.  In the past I often thought of it as a low cost outing.  Yeah, the price of gas is a pain, but the total cost isn't much if you have low cost fun like board-games and "hanging out."  When I first started building the model, though, I started having second thoughts.  ("It really costs that much just for my commute?" etc.)  Here is what the trip looks like when compared with a greyhound bus.


It's actually not that bad.  Split between the two of us, the cost of the car is less than $33 round trip (compared to ~$41 for the bus) before lost productivity.  And with two of us in the car, I'd say I get at least two hours of conversation, reading, and other fun activities that I'd count as productive time.  That doesn't hold if it were just one of us going up though.


What can I say... at least I didn't have to walk!




Sunday, June 9, 2013

Data Day

In which I update some old posts with new numbers and thoughts.

The Unemployment Line

This was my first real post, and I sorta cheated by thinking about (and modeling it offline) for a few months before starting the blog.  The central argument was that if you modeled the unemployment rate from it's peak (Oct '09) until the present (at the time, Nov '12) you created a remarkably linear fit.  At the time of the blog post, I could add four more months of data which not only fell along the line, but improved the fit.  Since that post, two more numbers have come out, and at first glance the model missed twice.


The April number was modeled to be 7.6, but actually came out better (7.5).  The May number was modeled to be 7.5, but actually came out worse (7.6).  The political pundits jumped on both numbers to show that their favorite program was working, or the opponent's obstructionism was hurting the economy.  Smarter pundits pointed to the number of jobs created or U6 unemployment number changing in the opposite direction to make counterpoint cases.  What I pulled from these numbers was that the "linear model" is now even better than before.  Adding in these data bring the R-squared up past 0.965, meaning the fit is better.


The added data (dark red) still follow our linear trend.  The change in U3 (light red) is still right around -0.6% per month, even in the months that have less than 12-month averaging (open squares).  And the predictions I made earlier are still legitimate.  (Well, as legitimate as they were ever going to be.)  The rounding to one decimal means that all the focus on one data point is silly.  That said, do not be surprised if the June number is 7.5.

Sell in May and Go Away?

Not too much data to add to this one.  The S&P started May at 1597 and ended it at 1631 (giving a yield of 2.1%).  This is larger than an average month, and didn't make those Sell in May proponents happy.  They are now (jokingly?) advocating "Sell in June".

Anyways, sorry for such a short post.  Next week we will get back to the interactive models.