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

Shorting

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.

GASZ

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

Groupon

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.

Friday, March 30, 2012

Mega Millions Lottery


The Mega Millions lottery is being drawn tonight for a record(?) 500-600 million.  Most people say that playing the lottery is a tax on the stupid.  But ignoring the life-changing effects of winning which could cause utility changes in excess of the dollar amount, the expectation is not always negative. By the numbers, you have a 1 in 175,711,536 chance of picking the winning numbers tonight.  Without taking taxes into effect, your expected return if you played today (assuming 540 M jackpot) is (1/175,711,536)*539,999,999 + (175,711,535/175,711,536)*-1 = 2.0732.  Actually favorable odds, although the actual after-tax, lump-sum option is considerable lower.  Regardless, I will still buy my (one) ticket - you never know.

UPDATE: the winner actually had to share the prize with several others, so I guess you would need to factor that into your calculation on these big prizes.

Spell Checker

Has anyone else noticed how awful Microsoft Word's spellchecker is?  Maybe I have more trouble with it than most people because my spelling is atrocious.  However, I remember back in the day (mid 90's) when spellchecker was considered to be the achievement of mankind.  These days, I often have to type my misspelled, gibberish-like words into Google just to spell-check it properly.  Funny how much more effective a search engine is at spell checking - too bad there wasn't a plugin available that would just do that for me automatically.

Systematic Forex Strategy

Spot forex has always been an alluring asset class to me - high leverage, symmetric short/longs, high liquidity, 24 hour trading ... However, in the back of mind I have always been a bit scared of trading forex to the bucket-shop like nature of the brokers.  I think those concerns are less pressing today with the more respectable and regulated brokers (IB, MB Trading, Oanda, ...).

That being said from my analyses, it is hard to come up trading strategies in forex on shorter-time frames that persist which is what tempts most traders.  So lately I have been looking at longer-term, daily strategies.  Here is one that is both simple and effective over the past two years - mean reversion in the USD/CAD.  I like to have a backstory to go along with my strategy and the theory is that the US and Canada have economies that are on similar paths and are married to one another through trade therefore, their currency should not get too far out of whack in normal times.  As usual, this relationship would probably break down in a crises (regime switch) so proper risk-management is needed beyond these simple rules.

Here is equity graph from a simple Bollinger Band trading strategy where one goes short at the top band and long the lower band starting in 2010.  The parameters are daily 12 MA, 2.2 std deviations, 1 lot per trade (spread of 2 pips) and take profit of 120 pips (a bit optimized).  Note that there is no stop-loss in this example.  Some results from this strategy: win/loss ratio of 0.84 and max equity drawdown of 28.7%.


One final thing I like about this strategy is that since it is contrarian, you can do the entire strategy using limit orders.  If you are using MB Trading, you get paid a small rebate for this which would lower your transaction costs slightly (also MB Trading has "real" limit orders since it is ECN, so you can guarantee that you would get filled at your price or better, which makes this back-test more realistic).

Thursday, March 29, 2012

UNG

UNG is an (infamous) ETF that tracks natural gas futures.  Unfortunately for UNG, natural gas has been in one of the biggest bear market since 2008.  Moreover, UNG invests in the front-month future contract that continuously needs to be rolled to the next month.  If the futures are in a state of "contango" this will eat into the returns on the ETF.  Here is the chart of UNG which shows a recent break out to new lows.



Commodities tend to be trending assets, so this could be a good time to reenter your short.  Contango for natural gas futures appears to be high and fundamentals appear to be awful according to this WSJ article due to horizontal fracking.  Despite this supply it is very difficult to transport natural gas outside of the US unlike crude oil.  Basically, UNG is a falling knife from what I can tell.  Although as usual with trading - caveat emptor.

Disclosure: Short UNG

Trading as a Career

I took a class on entrepreneurship, and I think that stats are like 2/3 of all start-ups eventually fail.  At first, that sounds like an awful proposition except if one plans to become a trader.  Most statistics I have read peg trader (retail) failure rates at around 90%.  I always wondered how that could be - you would expect 50% of traders to succeed merely my chance right?

Ignoring all the hundreds of other reasons why most retail traders fail, lets look at the distribution of pure luck on portfolio returns.  In this simplified world, traders either gain or loss 50% of their portfolio every day (this isn't meant to be realistic but just to show a point - think of leveraged ETFs).  After 10 days, here is the cumulative distribution of returns of 1000 traders.


The interesting thing to note is that over 80% of the traders have a portfolio less than their starting capital (1). A small amount have tripled their portfolio while a small minority have made a killing (>20).  This very contrived example shows through the nature of geometric returns the odds are very against you.  So if you think becoming a trader will lead to quick riches, you might want to re-evaluate your plan.

Wednesday, March 28, 2012

New Blog

Let's see if this blog lasts.  Contrary to the name, the blog is mostly about markets, programming and whatever piques my interests.

As a side note, I surprised about how many sub-domains under blogger are already taken.  I was just typing random characters and about 50% were taken even if they were gibberish.  Funny how artificially scarce resources become valuable.