Showing posts with label trade and quote. Show all posts
Showing posts with label trade and quote. Show all posts

Wednesday, January 25, 2012

Recording TAQ Data via Interactive Broker's API & Teaser of Ericsson Arbitrage Study

On October 28, reader "RKB" asked how I have been able to pull my data into Excel.  First, I would like to apologize to RKB for taking forever to answer his question. 

I have a program developed by a friend of mine, written in Java, that allows me to record time and sales for individual and groups of securities.  The program then dumps this data into a CSV file that I open with Excel.  All the manipulations in Excel I handle after the the price data has been cleaned and formatted into my formulas.

Hi-Res here
The software we developed is on the left with an IB Trader Workstation window open on the right showing some of the currencies available through IB's IDEAL PRO.  As you can see I have several open connections to a variety of currencies and several NYMEX natural gas futures contracts.

The program records bid, ask, bid size, ask size, last trade, last size, high, low, and close for equities, options, futures, future options, currencies, and combinations.  I cannot emphasize enough the importance of synchronized group recordings.  The weakness of using minute or even second by second quotes for arbitrage strudies is the nature of high-frequency arbitrage trading today makes these quotes obsolete.  You can record 2 seconds worth of data that consists of 100+ quote changes.

The last trade is never what's important.  The most important aspects of multiple-leg structures is the live bid, ask, and depth of market.  Liquidity risk has killed too many titans.

Here is the raw data for a study on triangular arbitrage. For those interested, this software is for sale.

Hi-Res here
It should be noted that IB is not the perfect platform to operate in today's market.  They are limited to pricing updates at a rate of 100ms when many of today's trades occur in the 10-20ms range.  This obstacle has limited my ability to study certain HFT strategies at higher granularities than I can record.

And a teaser for an upcoming post on ADR arbitrage across Ericsson shares...


 

Saturday, June 25, 2011

Triangular Arbitrage using high-frequency TAQ data on USD/HKD, AUD/USD, and AUD/HKD

Please note before reading: the watermarks (if you can call them that) on each picture in this post were from the original URL and authorship (a pseudonym) of this blog.  They have not been taken from another source and reposted - they are original works of this blog and this author.

Triangular arbitrage can be defined as the "price of a second currency expressed in terms of a third or an exchange rate calculated from two other rates." For instance, one can imply the synthetic AUD/HKD rate if one has the live USD/HKD and AUD/USD exchange rates.  The arbitrage relationship is inherent between the synthetic AUD/HKD traded against the live, executable AUD/HKD.

Fenn, Howison, McDonald, Williams, and Johnson (2009) note that "Triangular arbitrage represents one of the simplest arbitrage opportunities. However, there is, to our knowledge, no truly rigorous and robust study of triangular arbitrage in the finance literature.  We believe the main reason for this to be the lack of availability of datasets with prices which are sufficiently high-frequency and which are also executable."

Asynchronous data is a problem when trying to study any arbitrage relationship.  Be it stock to stock, stock to future, future to future, physical to cash, or speaking ubiquitously, any arbitrage relationship.  Studies using end-of-period (days, minutes, seconds) data recordings suffer from this issue whereby one variable may be said to have "this" price at the last known recorded interval, while the second variable similarly has "this" price at the last known recorded interval.  The problem arises because the two recorded prices, while they may be the last known price, cannot reliably be used due to their differences in time period.  This problem can only be eliminated using synchronized data in the most granular form available.

The Data.

The following data set was collected using a proprietary program developed by my IT team.  The software is connected to the interbank foreign exchange market via a direct access API.  In this case, the time and sales for the three pairs were recorded simultaneously and synchronously: any time a single variable changed, the entire data set was recorded as a whole.  The high frequency and synchronicity of the recording alleviates the problem that Fenn et al. (2009) discovered in their research of TriArb.

Below is the spread between the synthetic AUD/HKD and the live AUD/HKD.  As you can see, the arbitrage is remarkably consistent and very robust.  "Although some opportunities appear to exist for in excess of 100s," writes Fenn et al. (2009) in their study, "for both currency groups 95% last for 5 seconds of less and 60% for 1 second of less."

   (Click to enlarge)

There is a significant loss of liquidity beginning around 11:00 AM CST as evidenced by the increase in bid/ask spread of the three pairs, most notably the AUD/HKD.  The increase in bid/ask spread becomes evident in the construction of the synthetic/real arbitrage as referenced previously.

Bid/Ask Spreads
USD/HKD : Blue
AUD/USD : Red
AUD/HKD : Green
(Click to enlarge)

Trading the Opportunity.

At 1:33:55 AM on January 24, 2011, a small break occurs in the AUD/HKD synthetic and live relationship.  The break from parity is caused by an increase in the bid of the live AUD/USD from 0.98945 to 0.9897, an increase of .00052.  This bid-up caused an increase in the bid price of the synthetic AUD/HKD to 7.7154, while the live AUD/HKD rate was then offered at 7.7143, an arbitrage difference of .0011 AUD/HKD.

(Click to enlarge)

Notice: This break lasted only a single second.  While the opportunity undoubtedly lasted much less than a full second, the beta software version we were using to collect this data was not recording at the millisecond level, a problem that has since been eliminated.

The short duration of this break is an obvious barrier to entry.  Fenn et. al. (2009) cite "wider use of electronic trading platforms and trading algorithms" from 2003 to 2005 as the main cause of the opportunity's brevity.  They go on to note that, "From 2003-2005, the proportion of opportunities lasting less than 1 second increased from 40% to 62% for the JPY transactions and from 41% to 64% for the CHF transactions and the proportion of opportunities lasting in excess of 5 seconds halved for both sets of transactions."

Further Reading
Collective Dynamics of Small-World Networks
Hedging Currency Risk in International Investment and Trade
High Frequency Trading and the New-Market Makers