Skip to content

PaulEmileChantrel/arbitrage-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Arbitrage bot

In this project, we create an arbitrage bot.

Version 1

For the first version, we download OHLCV minutes data for BTC/USDT, ETH/USDT and ETH/BTC on Binance.

Then, we go through the data and only make a transaction when we can buy BTC/USDT, then buy ETH/USDT, and then sell ETH/UDST and be profitable with fees or when we can buy ETH/USDT, sell ETH/BTC and sell BTC/USDT and be profitable with fees.

We are able to go from $1,000,000 to $3,208,288 with the data going from Feb. 9, 2018 to Dec. 7 2022.

This algorythm is good but arbitrage does not work like this in real life. We have to take into account the spread between the bid and ask side.

Version 2.1

For the second version, we downlaod the orderbook data using Binance websockts. Then we make a transaction only when it is profitable using the spread between bid and ask. Since we only have 1 price for ask and bid, we also make the approximation that there is an unlimited quantity.

When we put a fee, there is no transaction that makes profitable trad over all the data acquired.

If we lower the fee to 0, we have the following result for data acquired during 3 minutes:

This results are still not representative of reality for 2 main reasons : 1) 0% fee might not be realistic and 2) we havn't look for the quantity for each bid and ask.

Version 2.2

Now, if we take into account the bid and ask quantity, we have much less performance. We only generate 0.076% over the period (instead of 90% for the V2.1):

Version 3

On the third version, we also get the book data with a depth of 20 for both bids and asks. Every time we make a trade, we update our data to reflect the change in supply.

With 0 fees we have the following graph :

And with 0.1% fee per trades, we have the following one :

Version 4

Merge the data collect and the trade part.

We don't save the data anymore, we just keep the last current known state of the order book.

Version 5

Deploy live with real trade (i.e. v4 with real trade capacity).

Fully working but we can't get any trade with 0.075% fees.

Version 6

Taker order added. For example, keep track of ETHBTC and ETHUSDT and put a limit order on BTCUSDT ready to be arbitraged.

Running properly but not making money.

Version 7

We optimize using only 2 WebSockets. For example, we collect only the current bid/ask for ETHBTC and ETHUSDT and place a limit order for BTCUSDT.

We also need to avoid running multiple instances of the TraderBot class in parallel since it doesn't work well.