Informatica Economică vol.22, no. 2/2018 35 DOI: 10.12948/issn14531305/22.2.2018.04 Arbitrage Trading Systems for Cryptocurrencies. Design Principles and Server Architecture Cristian PĂUNA The Bucharest University of Economic Studies, Romania cristian.pauna@ie.ase.ro When dot.com has become a quaint idea, when electronic shops have lost the mass attention, while classical and margin trading has become obsolete, something new is coming: cryptocur- rencies. Hundreds of virtual coins have been invented for a single reason: the profit. The high price volatility of these new markets and the fact that the virtual coins price is not regulated by a central bank or a single exchange, gives us opportunities for arbitrage trading. The existence of important price differences makes possible the profit when an automated system buy cheaper and sell more expensive in the same time. This paper will present the general principles under- pinning the implementation of arbitrage trading software for virtual coins market. The very large number of cryptocurrencies and exchanges fundamentally change the server architecture of the trading software. The distributed price data in hundreds of sources and the technical differences of each of these data providers make all the things difficult to be implemented in a single application. The low-latency order calculation needed for the fast delivery before a sig- nificant price change, in the presence of thousands of price quotes coming from hundreds of distributed servers makes everything special. Keywords: Cryptocurrency (CRYC), Arbitrage trading (ART), Algorithmic trading (AT), High Frequency Trading (HFT), Automated trading software (ATS) Introduction Bitcoin (BTC), Litecoin (LTH), Ethereum (ETH), Ripple (RIP), thousands of virtual coins already exists. The Bitcoin “introduced in 2009”, “caught the interest of the main- stream media in 2012” [1]. After that, an un- defined number of virtual coins were in- vented. All these coins are named virtual just because they exist only in the electronic rep- resentation. They are also called cryptocurren- cies because they are designed to work as a currency like a medium of value exchange and the “cryptography is used to secure financial transactions” [2], to control the creation of new units, to verify the transfer of funds and to set the owner for each unit. The reason involving real money to buy this kind of virtual assets is of course the profit. The virtual coins value is fluctuating on the free markets as any asset, powered by specu- lative and marketing actions and sustained at least hypothetical by some economical pro- cesses involved in the background of each crypto coin. However, even it is a free market, the virtual coin market has its own character- istics, especially when it is about the volatility and “the flexibility in the supply schedule” [3]. We are not so far away the days when Bitcoin almost touched 20.000 USD in a relative short period of time starting from couple of bucks and after that plunged back to 7.000 - 8.000 USD in an even shorter interval. This kind of movements makes the investment in crypto- currencies an attractive one today. However, the high price volatility makes this investment to be a very risky one, drawdowns of more than 61.8% being very easily assimilated with a gambling game. For all that, keeping the money into a virtual currency hoping the value will increase after a while can be a prof- itable idea, but it is not the only one. All these assets are operating independently of a central bank or a central exchange. Without a central price regulator the quotes can be different from an exchange to another. That means we can find cases when and where we can buy cheap and sell more expensive the same thing in the same moment of time. This will be called an arbitrage trade. The unbal- anced price of the same asset in two different places will give us an instant profit. 1 36 Informatica Economică vol.22, no. 2/2018 DOI: 10.12948/issn14531305/22.2.2018.04 The question is how to find these opportuni- ties and how can we profit from all of these in the real time. The theory is easy, just find two exchanges with different quotes for the same equity, buy where the equity is cheaper and sell where it is more expensive. The problems start when we will consider the facts that there are hundreds of crypto pairs, hundreds of thousands of combination of these coins and hundreds of exchanges where you can buy and sell all of these assets. That means a human being cannot compare all these prices in order to find the best trade op- portunities, to build the orders and to send them to those exchanges before the price is changed. Only a computer can to manage all of these actions. This paper will present how an arbitrage trad- ing system for cryptocurrencies can be built, will reveal the main principles and practices and will also present some results in order to open or to grow the interest for this kind of software systems. 2 Arbitrage trading As we already presented, the arbitrage trading means to buy cheap and to sell more expen- sive the same equity in the same moment of time in two places where the quote prices are different. The arbitrage trading is not a new idea. It was used since years to trade shares. “Stocks are matched into pairs with minimum distance between normalized historical prices” [4] and arbitrage trading strategies can be used with any stock exchange in order to make profit. Usual, the classical arbitrage trade is involv- ing the same volume of equity in the both trades. For each trade (i), the profit (P i ) is equal with the difference between the sell price (sell i ) and the buy price (buy i ) multiplied by the volume traded (V i ). For this simple trade idea, the trading software must compare continuously the quotes from different exchanges and find the highest price differences. But the classical arbitrage trading is not the only one trading opportunity which can be found in the cryptocurrency markets. The virtual coins are traded in pairs. The price of a pair, for example BTCETH if we will consider Bitcoin and Ethereum, means how much ETH we need to sell in order to buy a specified unit of BTC. When an exchange ask you a specified price to buy BTCETH and an- other exchange offers you a higher price for the same pair, a classical arbitrage trade can be executed and the profit will result from the price difference. But sometimes the depend- ency between two coins is not expressed in the same way in all exchanges. There are cases when an exchange will quote the price for BTCETH and another exchange will quote the price for ETHBTC. The virtual coins involved are the same but the price in built in the re- versed way. For this case, to find an arbitrage trade the software must compare the price from the first exchange with the reversed price into the second. Now we are talking about a reversed arbitrage trade. In this case the profit will be: The execution of the trades is usual simple. A trading order means to buy or sell the speci- fied pair at a specified price with an estab- lished volume. Of course an order can be exe- cuted by the exchange only if there are enough coin units to sell in that exchange in order to buy the ordered volume from the first coin. This validation must to be done by the trading software before to send the orders to the ex- changes, based on the real-time capital data provided by each exchange. An arbitrage trade means at least two orders in two differ- ent exchanges. Another type of arbitrage trades is involving more pairs. Sometimes the product of two, three or more pair quotes is imbalanced be- tween two exchanges or even in the same ex- change. For understanding, letʼs consider the next inequalities: BTCETH*ETHLTC