3-Way Arbitrage is not Working on Binance

I’d like to contribute a proof of this statement to the community of traders.

It is written in Rust, because I am not satisfied with the performance of my jupyter notebook. (It is straightforward how it works. You don’t need any Rust knowledge.)

You don’t need to read this post, if you have no experience with the command line and programming at all, so the major takeaway is, that 3-way arbitrage is not working on the Binance trading platform.

What is 3-Way Arbitrage?

The number 3 stands for the three currencies involved you will be trading on.

You take the advantage of slight differences in the market prices between the trading pairs of these currencies.

For instance, you might have a decent amount of EUR in your portfolio and like to buy BTC. With the trade being made, you will sell your BTC in favor for DAI, but you are not holding it and will swap it immediatly after its aquiry to EUR again. After your actions, you’re holding only EUR and no BTC or DAI in your portfolio. If the markets are in your favour, you will gain a profit and increase your Euros amount.

How will you know, if the strategy with these 3 currencies is profitable beforehand, so you can act upon your insights?

You will need the price the three trading pairs markets and a formula to calculate your profit. The formula is:

1 EUR * priceBTCEUR / priceDAIBTC * priceEURDAI = profit

If the profit is above 1 EUR you will gain, if below you will loose.

Further reading: capex.com/de/akademie/crypto-arbitrage

Why is it not working on Binance?

Any valid combination of 3 trading pairs to fulfill the cycle is not possible on Binance.

Here is the Proof.

We will test all combinations of market triples to show, if a cycle is possible.

First of all, you need two datasets. One is the amount of traded currencies and the other are all trading pairs (or to say markets) on binance.

You can get these by accessing the exchange info from the public binance api.

(I will not explain the meaning for the commands. It is up to you to research them, if you like to learn how you can use them.)

wget https://api.binance.com/api/v3/exchangeInfo

It is in json format and you will need the json query programm (jq) to extract the relevant data out of it. (stedolan.github.io/jq/)

jq '.symbols[].symbol' exchangeInfo | sed 's/"//g' | sort > symbols
jq '.symbols[].baseAsset' exchangeInfo | sed 's/"//g' | sort | uniq > bases
jq '.symbols[].quoteAsset' exchangeInfo | sed 's/"//g' | sort | uniq > quotes

# to see the contents of the exchageInfo file
jq . exchangeInfo | less

I don’t get into the details of the Rust program, now, because that would be too much unnecessary explanations in this article. I provide you with my git repo here: github.com/i-think-rapido/arbitrage-triples.

The program is very simple in structure. It is straightforward how it works. You don’t need any Rust knowledge.

Basically, it loads the datasets from the text files and performs a nested loop over all permutations of possible currencies. With these currencies it builds the trading pairs and checks if its combination is available in the symbols dataset. If yes, it spits out the valid currencies.

But, don’t be confused, if you get some results with the downloaded data. These are false positives, because the query at api.binance.com/api/v3/exchangeInfo downloads all available information. You need to be carefull, because there are also old, not supported ones in it. You have to amend the query from above.

jq '.symbols[] | select(.status = "TRADING") | .symbol' exchangeInfo | sed 's/"//g' | sort > symbols

Try it out. With this data you won’t get a program output.

One more hint

When you compile and run the example program, you can do it by cargo run or by cargo run --release. The later will improve the speed tremendously, because it has to loop around 150M checks.


Actually, I’m speculating, if binance is deliberately not providing enough markets to perform 3-way arbitrage. Could possibly be. If this strategy would be exploited, it would be a huge impact on the transaction amount on this platform’s api, which would overwhelm and break it.

Source : bsc.medium

Leave a Reply

Your email address will not be published. Required fields are marked *