Monday, January 24, 2011

Nearest neighbour classification

I've been following trading the odds blog  for some time now. It surprised me how well  Frank was able to predict the short-term movement of the S&P500. At first I was quite sceptical about the predictability of the directional stock movement, but had to admit now that there is some sense to it.
Previously I've been playing around with some techniques from pattern recognition field, especially the 'nearest neigbours' approach. Just as one could get an impression of somebody by meeting his friends, the same can be said about stocks. By finding some 'examples' most related to an 'new' situation, a statistical picture could be made of the things to come.
To provide a simple illustration, I've taken the intraday SPY and TICK data for 2010. Some traders are using the first hour of trading to decide what kind of strategy they need to implement for that situation. But is the first hour of trading representative for the rest of the day? It turns out it is. Take a look at the chart below.
Here I've classified the intraday SPY data based on the first hour of the TICK reading. For this I've used the mean and standard deviation of the 30-sec TICK-NYSE data.  Green lines in the chart represent ten days with minimal mean and minimal std of the TICK in the first hour (closest to [0,0]). Blue lines are days with large positive mean of the tick and  low std ([max, 0]).  It turns out that days with large positive bias int the first hour of trading have a quite strong negative bias for the rest of the day, who would have thought?
Predicting the market regime for the rest of the trading day is not very profitable by itself, but can be very well used for choosing the right strategy.

Saturday, January 15, 2011

XVIX performance

In a reaction to my previous post about the VXX-VXZ combo, a kind reader has pointed me to the newly launched  UBS XVIX  etn.  From the first look it does not seem to be that liquid, so its ability to track the VXZ-0.5VXX is somewhat questionalble. 
I've decided to take a quick look at the fist month of its existance to check if it is really performing as advertised.

In the graph I've plotte the cumulative change in VIX (index), VXZ, VXX, XVIX and a synthetic VXZ-0.5VXX pair.  It seems that XVIX performing exactly as promised, providing performance very close to the underlying pair, without the cost of rebalancing. 

The following plot shows cumulative tracking error:
An interesting observation is that it does have some occasional tracking errors, of about ~0.3%, providing some arbitrage opportunities.

Monday, January 10, 2011

What if S&P 500 lost 50% on a single day?

Most of us know that there are leveraged ETFs, providing up to 3x daily exposure, in decimal percent. Usually these etfs  perform just as advertised, but imagine a situation where the index looses a very large portion (~50%). Such an event unlikely, but is not impossible if you think about the 'fat tails' and ~20% loss on black monday in 1987.
Now imagine you are unfortunate enough to own one of the 3X leveraged etfs on while S&P looses 50% of its value. will 3x exposure result in a 150% loss??? Ok, you probably will face a margin call before that, but I'm having a hard time trying to imagine what would happen to the leveraged etf price on such a day.
What do you think?

Wednesday, January 5, 2011

Yahoo quote downloader

Here is a simple function to get current yahoo data for a bunch of symbols : get_yahoo_quote.m
It downloads quotes from yahoo (take a look here at what is possible) and returns them in a struct.

example usage:
quote = get_yahoo_quote({'SPY','IWM'})     


           symbol: 'SPY'
             desc: 'SPDR S&P 500'
        lastTrade: [127.5695]
    lastTradeTime: '3:30pm'
     dividendDate: 'Dec 17'
             open: [126.58]
        lastClose: [126.98]

           symbol: 'IWM'
             desc: 'iShares Russell 2'
        lastTrade: [79.26]
    lastTradeTime: '3:30pm'
     dividendDate: 'Dec 22'
             open: [78.4]
        lastClose: [78.422]