Bitcoin Arbitrage Exercise

This is my solution to the Bitcoin Arbitrage puzzle posted earlier this year by Priceonomics. A matrix of continuously-published currency rates is algorithmically skewed and the challenge is to uncover any arbitrage opportunities. Calculations are re-run every time this page is loaded/refreshed, using YQL to fetch the latest rates and MathJax to render the results.

All spot market arbitrage can be decomposed into duality-arbitrage (different prices for the same thing) and triangular-arbitrage (relative prices between three assets not unity). Any higher order arbitrage relationships (i.e. involving more than three assets) are a combination of duality- and triangular-arbs.

Duality Arbitrage

Duality arbitrage occurs when the different prices are attached to the same currency pair.

Triangular Arbitrage

A currency has no absolute value, only relative value against other assets/currencies. Triangular arbitrage occurs when the relative value of a currency towards two different assets does not match the relative value between those assets. For any triangular relationship in this exercise there are 8 combinations of currency pairs to choose from (i.e. the price of EURUSD differs from USDEUR). To avoid double-counting the duality issues identified above, we pick the triangular combination of rates that results in the minimum arbitrage possible (the rest is contaminated by duality-arb)

(c) 2013 Ziggy Jonsson - Licence MIT - (source)