Monday, May 31, 2010

Estimating the fair price of ETF components

The essence of every arbitrage strategy (in any timeframe) is an estimator of a 'fair price'. Once you got that, the rest is easy: just buy the stocks that are too low relative to the fair value and sell the overpriced ones.
Now the hard part: how do we estimate the fair value? Solutions could be countless: linear regression, neural networks, kalman filter, weight in the index, mean value, ... you name it. And of course the ETF tracker itself.
In the example below I've taken a look at the old time favorite group of stocks : the XLE. The data  plotted is a cumulative return for 1 week history with 15 minutes sampling rate. Notice the fat lines: the blue one is just the mean return of the group and the red one is the return of XLE itself.

It turns out that the returns of XLE are almost identical to the mean of the group! A quick conclusion from this is that the ETF itself is as good estimator as just the mean value!. Another conclusion could be that one does not need a phd-rocket-science-chaos-theory sophistication to  design a descent arbitrage strategy.

Saturday, May 29, 2010

In the last couple of weeks I've been very busy with implementing an intraday arbitrage strategy. The strategy itself is very simple with zero (!!!)  parameters, but the amount of code needed for data and error handling is much more than I've anticipated. Have been coding data handling and conversion for a couple of weeks now with one clear conclusion: I hate programming. So this is how it feels to be the low-level software engineer aka code-monkey ;-).
However, during this process I managed to get Matlab to talk to TWS through their API and written a historic data downloader that could spare some boring work for other people.
The code is based on tutorial written by Max Dama (thanks Max!). You should follow the steps described on his page to install and configure the tws api. After that just fire it up:

hDataIntraday = getHistoryTws(tickers, filename_copy ,period, barsize);

Keep in mind that IB imposes restrictions on data download :  Historical Data Limitations
stocks: [1x20 struct]
ticker: 'AEE'
history: [1x1 struct]
dates: [253x1 double]
open: [253x1 double]
close: [253x1 double]
volume: [253x1 double]

ticker: 'AEP'
history: [1x1 struct]
dates: [253x1 double]
open: [253x1 double]
close: [253x1 double]
volume: [253x1 double]

last_update: '29-May-2010 16:07:21'