Sunday, April 29, 2012

Programming Shortage

I ran across this article from TechCrunch, which states that there is a software engineer shortage despite favorable characteristics for programmers salaries (low unemployment and potential for huge gains).

As a programmer by trade, I find this articles really annoying. Ignoring for the fact that start-ups are probably in a valuation bubble about to burst (e.g. Instagram is a huge outlier); what they are really saying is that "there is a shortage of talent ... for what I am willing to pay".  According to econ 101, if you need more supply just increase the price.  What these (start-ups I am guessing) really want it some rock star to implement their ideas for peanuts.  However, reality bites them in the butt once they realize they are competing with Google and Facebook salaries, so they complain they "can't find anyone" and should increase "H1-B" visas (i.e. cheap labor).

The real story is that most programmers won't be working at a hot start up or see a big pay-off and the lessons of the early 2000's are still fresh in people's minds.  Moreover, most Americans don't find programming sexy - it is too socially isolating and logically complex despite the cool factor of web/mobile start-ups.  Therefore, the only real way to attract more talent is better salaries and treating software engineers more like lawyers and less like construction workers.

Sunday, April 22, 2012

Fade Opening Gap SPY Trading Strategy

I mentioned in a previous post that fading the opening gap can be very profitable on certain indices and securities.  Here is one of the best examples - the SPY ETF.  Using a very basic strategy of buying or selling in the opposite direction of the opening gap and taking profit at previous close (or closing out at the end of day if the target has not been reached) shows this equity graph (using Yahoo! finance data and compounded returns)

As you can see, this is a very profitable almost every year especially post-2008.  Note there are many ways to improve upon this strategy (to reduce risk mostly) but the basic one works pretty well.  Note that this does not include any trading costs nor slippage which can occur at the open despite SPY being very liquid.  However, let's look at the risk of the strategy.  Here is a graph of the draw-downs from the equity high water mark.

The max draw-down was only 20% and that was in the depths of the 2008 crises which is not bad considering that the SPY dropped +50% during that period.  Post 2008, the draw-downs have barely made it pass 5%.  The Sharpe ratio of this strategy over this thirteen-year time period is about 1.19.

Edit (03/25/2013):  After looking at this further these numbers are mostly bunk based off bad high-lows from historical Yahoo! Finance data.  This strategy is still somewhat viable (you need to be more selective) but not nearly as profitable.

Monday, April 16, 2012

GAZ and ETNs

There has been a lot coverage of the big fall of TVIX an ETN that "supposedly" tracks VIX futures.  GAZ is another ETN one should be wary of.  It is supposed to track natural gas futures, but currently trades at 4.00, but its NAV is 1.89, a premium of 112%!  Here is a 3 month chart of GAZ vs UNG, notice something unusual?

So when dealing with these exotic ETNs be careful.  I personally believe there are opportunities to make money in these for trading purposes but not so much for investing.  Look how someone would have fared if they bought VXX for long-term "hedging purposes", yikes!  Although to be fair, one could reasonably compare this to the premium on an LEAP option that expired worthless.

Monday, April 9, 2012


One thing that isn't intuitive to novices is that shorting is not completely symmetric with being long.  Other than the restrictions and additional costs that occur with shorting a stock, you also suffer from the fact that you do not compound returns when you go short.  What I mean by that is that your position gets shorter when you are winning and longer when you are losing.  As an example, if you shorted a stock at 100 and it went to 10, you would make 90% on your position, however if you bought a stock at 10 and it went to 100 you would make 1000% on your position - not a fair deal.  What's worse is that if the position starts moving against you, you become more at risk.  Ways to overcome this characteristic of shorting is to rebalance your position or use an inverse ETF which implicitly rebalances for you (usually daily) but is usually cheaper due to less transaction costs.

Saturday, April 7, 2012

SPY RSI Trading System

Here is a backtest on a daily mean-reversion trading system inspired by this post.  The rules use a simple countertrend-based system using the RSI and SMA.  The goal is essentially is to buy the dips in an up market and sell the spikes in a bear market.  First, we have a 200-day SMA average as a filter to determine if we are in a bull or bear market.  If the price is above the 200-day SMA we use "bull market rules" and vise-versa.

The bull-market rules are buy at the close if the 4-day RSI is below 35 and close the position if it is above 55.  The bear-market rules are that you go short if the 4-day RSI is above 80 and close the position if it is below 50.  I included transaction costs of 0.01% per trade to make it slightly more realistic.  The data set is from 01/02/2001 to 04/05/2012.

It is interesting to note that most of the over-performance is post-2008.  This is likely because the system managed to avoid a big losses during the crises.  Some additional stats: Sharpe ratio of 1.036 and max drawdown of 9.89%, so it would not be unreasonable to lever this up a bit if one wanted to be slightly more aggressive.  The downside of this strategy is that I picked some slightly optimized in-sample parameters which probably makes the performance over-optimistic.  Second, this strategy seems to do well in choppy markets, which could be abating in the near-term.

Friday, April 6, 2012

Seasonal VIX/VXX

I have come across on multiple market blogs (here is one example on MarketSci) that the VIX displays seasonality by weekday.  Basically, it does what one expects: best average returns on Monday and worst average return on Friday (although the effect is shrinking apparently).  This makes sense because everyone saves up their bad news for the weekend and often during the summer people are gone on Friday,so it is very quiet.  However, the VIX is not directly tradable.  I wondered if the same effect applies to VIX futures - specifically the VXX ETN which tracks the daily movement of the front and second month VIX future contracts.  Here is the results of a very brief analysis of averaging the daily return of the VXX (close to close) by weekday over the life of the ETN (1/30/10 - 04/05/12).

Note that we actually see the opposite effect.  The best day is on Thursday close to Friday close, and the worst day is Friday close to Monday close.  There are a couple caveats with this. First, VXX has only been trading since the start of 2009, the top of the largest VIX spike on record.  We really need more data from future contracts to be more certain of this effect (and it also explains partly why we see a lot of negative returns here).  Second, we really should break down the analysis by bear and bull market because I can imagine that we would the original seasonality during bear market periods.

That being said, it is clear that shorting VXX on Friday appeared to be good on average during the last two years.  My speculation is that during this period people were expecting bad news to be released so they bought up VIX futures into the close on Friday as a hedge, when that didn't pan out (or wasn't as bad as expected) people unwound their positions.


I mentioned in an earlier post that UNG suffers from heavy losses from the steep contango in the natural gas futures market in addition to falling gas prices.  This is because UNG invests in the front month contract and then "rolls" (sells the front month, buys the next month) once it reaches a certain date.  This process leads to losses if the fund in continually investing in a premium and selling once the premium vanishes.

UBS release a series of ETNs (note that you are taking on counterparty risk with an ETN) that actually tracks only the contango of said futures (OILZ and GASZ), so instead of taking a position on the movement of natural gas or oil, you can invest directly in the decay due to contango.  However, if the futures term structure ever moves into backwardization, these will perform poorly - so don't go too crazy.  Here is the performance of GASZ so far - fairly impressive and uncorrelated with the stock market.

Disclosure: short UNG, long GASZ

Thursday, April 5, 2012


In behavioral economics, one of the "anomalies" from the efficient market hypothesis is the accrual anomaly.  This  anomaly states that companies with high accruals underperform companies with low accruals (so one could outperform the market by building a portfolio of long low accruals stocks and short high accruals stocks).  Accruals are broadly defined as the amount of earnings of a company that is due to accounting manifestation (e.g. accounts receivable) versus actual cash flow.  The underperformance comes when the earnings are inevitably written down during a restatement leading to a 10-12% loss on average.

Groupon is a company that books revenue on every coupon sold immediately before redemption of said coupon by the customer.  Guess what happened (a few days ago) when the company found out that the rate of redemption was lower than expected?  A classic example of this anomaly in action.

Fade the Gap

"Fading the opening gap" strategy has been a pretty effective strategy on certain indices.  Today is a classic example of why this effective.  Notice how it had to reach the previous close before it found direction.

The only issue I have with this strategy is getting filled at the open.  I can imagine that there is a lot of slippage at that point.