Poor Man’s ETF Arbitrage in TradeStation

I was coding something in MatLab to test an ETF versus a basket of components as this is impossible to do in TradeStation. I had most of the guts of the code worked out but ran into data problems. Getting data in a format where dates align properly is one of the biggest hassles of systems trading in my opinion. It’s little wonder good data costs big bucks. So when I ran into this problem I decided to find a quicker workaround. The following is a tale:

I thought of the available solutions I had to this issue, TradeStation, WealthLab, Excel. There could be a solution via WealthLab but it wasn’t intuitive at the time, perhaps create a list and cycle through each stock on execution? Tradestation was out because it can only analyze one security at a time (sucks right?) Excel could work? It would be old fashioned strategy testing with a ton of nested conditional statements! Brilliant!

Data? Well if TradeStation is good for something it’s quick and dirty data. Here are the steps I took:

  1. Create a chart with the ETF and all the component stocks. Again you are limited to 50 securities per chart.
  2. Create an index comprising of each stocks value * weighting. The weighting scheme can be anything you choose, regression, beta, ETF weigthing, etc.
  3. Create a conditional statement that monitors short and long positions on the arbitrage, with 1 as long, -1 as short, 0 otherwise.
  4. Output date, time,  index value, ETF value, and positions to a txt file and  open in excel
  5. We need to recreate a trade matrix. We could do this multiple ways but the easiest method I have found is to sort the list by positions. Delete all 0 zero positions and then resort the matrix by date and time.
  6. Include an additional column with conditional statement to output 1 or 0 when the position flips from Long to Short. This is to eliminate prices where the log ratio remains expensive or cheap for multiple bars. In trading you would execute on the first signal anyway most likely.
  7. Resort the list. Eliminate the rows with 0. Resort AGAIN by date and time.
  8. What’s left is the trade matrix. Each row should represent the prices traded on the basket as well as the ETF. It should also be in chronological order so that calculating P&L is simply filling in columns and not searching through rows looking for position changes or writing a VBA macro to do it for you. You can also paste lagged results in an adjacent column to make calculations even easier.
  9. The resulting P&L on each trade should simply be your position*index value – position*ETF value. You can also subtract commission and slippage estimates from the price you trade.
This is what your sheet should look like

This is what your sheet should look like

I tried to recreate the ETF arbitrage trade presented by Ernie Chan over at Quantitative Trading. In his members section he posts current basket and weightings for the XLE based on his co-integration analysis. For this exercise I simply took his results for granted however I switched it up and looked at 5m intraday intervals as opposed to daily. Here are the results:

Results

Results

Issues: I’m human, there could very likely be some mistakes so please comment if you see any. Additionally, the instructions may not be as intutitive to the reader as it is to the writer. Again please post any questions to the comment section. I hope this helps someone!

Advertisements

~ by largecaptrader on July 23, 2009.

5 Responses to “Poor Man’s ETF Arbitrage in TradeStation”

  1. Nice piece. Few questions, if you don’t mind (acknowledging I have not used TradeStation in quite a few years, which may be the root of my misunderstanding): (a) can you clarify your intent with step 2: why you are building a custom index (since standard ETF basket arb assumes the hedge ratios are estimated via cointegrating regression)? (b) what is the “log ratio”, in this context? (c) what data source you use for intraday? Thanks in advance.

  2. […] Comment on Poor Man’s ETF Arbitrage Reader Comment on Poor Man’s ETF Arbitrage: Nice piece. Few questions, if you don’t mind (acknowledging I have not used TradeStation in […]

  3. Hello would you mind sharing which blog platform you’re using?
    I’m looking to start my own blog in the near future but I’m having a tough time making
    a decision between BlogEngine/Wordpress/B2evolution and Drupal.
    The reason I ask is because your design and style seems different
    then most blogs and I’m looking for something completely unique.

    P.S Sorry for getting off-topic but I had to ask!

  4. Excellent post however I was wondering if you could write a litte more on this subject?
    I’d be very grateful if you could elaborate a little bit further.

    Thanks!

  5. This site was… how do you say it? Relevant!!

    Finally I’ve found something which helped me. Thanks!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: