Aiming for interest and small money earning, I tried to develop a Bitcoin inter-exchange arbitrage (arbitrage) system. It was interesting to get various knowledge, so I will leave it as an output.
The content is quite old (around 2017-2018), so there may be various changes, but I'm not sure.
It is also known as "without sheath". It is a financially historic trading method, and it seems that it has been certified as one of the world's three major profit-making laws.
It is a method that can surely make a profit by taking an order by piercing the distortion at the moment when some distortion occurs in the market.
Distortion has quite a variety of patterns --Price difference between futures and spots --Price difference between currencies --Price difference between exchanges
There is something like that.
This time, I made a program aiming at the distortion of the price difference between exchanges.
Compared to stocks and historic financial products, virtual currencies have fewer functions on the exchange itself (such as not being able to sell). There is also a reason that it can only be done between exchanges in reality because the API of the exchange must also be published for execution.
Below, arbitrage is referred to as Abitra.
I used. The specific method is as follows.
This is the pattern I tried first, buying at a cheap exchange, sending money and selling at a high exchange. ** This pattern didn't work for the reasons described below. ** **
Deposit the same amount of Japanese Yen to the exchange to be used as a preparation.
The program monitors price information and places buy orders at the cheaper price the moment a difference is created between exchanges.
Example)
1 BTC is 1,000,000 yen on Exchange A 1 BTC on Exchange B is 1,010,000 yen (price difference +10,000 yen)
Buy 0.1 BTC on Exchange A, transfer to Exchange B and sell
** This will instantly generate a profit of 1000 yen. ** **
I thought that if I continued this, I would be able to earn fully automatically, but ...
It was discovered that Bitcoin remittance was slower than I expected ... I thought that it would be sent in an instant after reading a book, but it took me 30 minutes or a few hours to spare. It is meaningless unless the transaction is completed during the momentary distortion. If this is XRP or a currency with fast remittance speed, this may be solved.
I've tried various things since then, but there are fundamental problems when incorporating remittance into the flow.
Since the money is sent from the account you bought, it happens that there is neither Japanese Yen nor BTC in a specific account. Since it is difficult to deposit Japanese Yen automatically, it is necessary to regularly transfer BTC from the surplus exchange, but the logic there has become complicated.
Depending on the exchange, the remittance fee is quite high, isn't it? (I was reading a Bitcoin book and thought that virtual currencies are characterized by low and fast transaction costs, but ...)
Originally, the arbitrage itself is a model that accumulates small profits steadily, so it is quite painful to raise the transaction cost for each transaction.
If you try to do it, you will only trade under conditions that make a profit even if you include the remittance fee, but there was a problem that the number of transactions would be greatly reduced.
In the first place, the remittance API is fairly secure (it is natural because it leads to illegal remittance).
The first few exchanges could be implemented in Gabagaba, but in increasing the number of exchanges, ――The money will be transferred one business day after you hit the remittance API and succeed. --The API parameter requires a 6-digit number for Google Auth two-step verification (what to do)
Something was found and it was really tough.
I gave up because it seems to be difficult to incorporate remittance.
Looking at the price information of the exchange while making it, I noticed that ** basically cheap exchanges and high exchanges are mostly fixed, but there are moments of reversal several times a day. .. ** **
Therefore, put the same amount of Japanese Yen and BTC in all accounts.
--Orders to go for profit as arbitrage --Order to rebalance
I thought that it would go around if I rebalanced within the range that does not lose while taking profits by dividing it into
Buy 0.1 BTC on Exchange A, transfer to Exchange B and sell
At this rate, BTC cannot be purchased at A, and BTC cannot be sold at B, resulting in lost opportunities. Therefore, when the prices of A and B are reversed, the opposite order is placed (transaction fees must also be taken into consideration).
Unlike the model, you can buy at a cheap price and sell at a high price at the moment when the price difference occurs. Buying and selling = The balance is lost and you cannot buy or sell on a specific exchange for a while.
So, to maximize profits
--- If there is a yen difference, place an order to go for profit --- If there is a yen difference, place an order to rebalance.
This parameter needs to be tuned diligently.
Since it was a time when the volatility of Bitcoin itself was high, I was doing frequent maintenance while looking at the data.
Also, since it holds a certain amount of BTC, there is always a risk of price fluctuations.
Due to the rise in the price of BTC, the comparison from the principal has increased considerably. (Actually, it was much less than the figure, so it's about the tears of a sparrow, but ...)
However, unexpectedly, it became difficult to tune the parameters so as not to lose the opportunity and the operating cost, and I was not motivated and I was disappointed.
Also, there are many behaviors that I do not understand well at each exchange. (Some exchanges have an amount that is far from the market price for a moment at 4 am ...)
I wanted to think that optimizing parameters would be an interesting area if combined with machine learning, but that was not the case.
If I have a chance, I would like to try again.
It's rough, but I'll upload the sauce as well. https://github.com/haruhiko-tano/arbitrage-bot
Recommended Posts