xxxxxxxxxx
<meta charset="utf-8">
<style>.MathJax_Display {text-align: left !important;}</style>
<body>
<h1>Bitcoin Arbitrage Exercise</h1>
This is my solution to the <a href="https://priceonomics.com/jobs/puzzle/">Bitcoin Arbitrage puzzle</a> posted earlier this year by <a href="https://priceonomics.com">Priceonomics</a>. 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 <a href="https://developer.yahoo.com/yql/">YQL</a> to fetch the latest rates and <a href="https://www.mathjax.org/">MathJax</a> to render the results. <br><br>
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.
<h2>Duality Arbitrage</h2>
Duality arbitrage occurs when the different prices are attached to the same currency pair.
<div id="dual"></div>
<h2>Triangular Arbitrage</h2>
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)
<div id="triangular"></div>
<hr>
(c) 2013 <a href="https://github.com/zjonsson">Ziggy Jonsson</a> - Licence <a href="https://opensource.org/licenses/MIT">MIT</a> - <a href="https://gist.github.com/ZJONSSON/8138007">(source)</a>
<script src="https://code.jquery.com/jquery-1.10.1.min.js"></script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/mathjax.js?config=tex-ams-mml_htmlormml"></script>
<script src="arb.js"></script>
<script src="https://query.yahooapis.com/v1/public/yql?callback=main&format=json&q=select%20*%20from%20json%20where%20url=%22https://fx.priceonomics.com/v1/rates/%22"></script>
</body>
Modified http://code.jquery.com/jquery-1.10.1.min.js to a secure url
Modified http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML to a secure url
Modified http://query.yahooapis.com/v1/public/yql?callback=main&format=json&q=select%20*%20from%20json%20where%20url=%22http://fx.priceonomics.com/v1/rates/%22 to a secure url
https://code.jquery.com/jquery-1.10.1.min.js
https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML
https://query.yahooapis.com/v1/public/yql?callback=main&format=json&q=select%20*%20from%20json%20where%20url=%22https://fx.priceonomics.com/v1/rates/%22