cryptoeax / arbbot

Arbitrator, a bitcoin/altcoin arbitrage trading bot
https://gitter.im/cryptoeax-arbbot/Lobby
GNU General Public License v3.0
198 stars 78 forks source link

Add a CCXT backend for exchange support, and start with initial Binance support #109

Open cryptoeax opened 6 years ago

cryptoeax commented 6 years ago

Blocks #5

I have an adapter for the CCXT library that makes the job of writing an exchange backend for arbbot super simple, and I have used it to implement Binance support as a demo.

Help with testing is appreciated.

ericfraselle commented 6 years ago

I can help on this.

cryptoeax commented 6 years ago

I pushed my branch here: https://github.com/cryptoeax/arbbot/tree/binance

Please note that THIS BRANCH HAS KNOWN BUGS and you should use it at your own risk for now. I'm putting out the code for now mostly for exchange developers who want to start to use the CCXTAdapter class.

Right now the bot isn't yet able to make full transactions from other exchanges to Binance successfully, so beware when testing with a lot of altcoins on Binance. But depending on the altcoin pairs the bot finds, testing it without setting an autobuy fund value may be safe. Watch out for altcoins which get to a non-zero balance on Binance.

I'll post here when this is ready for more general testing and also it's useful to report bugs...

mrtomeq commented 6 years ago

Looks like you are already aware of the cross-exchange transaction issue so I wont create new issue and just post my log for reference:

It goes into an infinite loop during transfer attempt:

01:58:52: balanceAltcoins() 01:59:07: balance(GAS) 01:59:09: BINANCE: 0.4995 GAS (3 usages) 01:59:09: POLONIEX: 0.49875000 GAS (3 usages) 01:59:09: TOTAL: 0.9982500000000001 GAS 01:59:09: AVERAGE: 0.49912500 GAS 01:59:09: XFER THRES.: 0 GAS 01:59:09: BINANCE could give 0.00037500 GAS 01:59:09: POLONIEX is missing -0.00037500 GAS 01:59:09: Transfering 0.00037500 GAS BINANCE => POLONIEX 01:59:09: Deposit address: xxxxxxxxxxxxxxxxxxxxxxxxxxxx 01:59:10: Transfering 0 GAS BINANCE => POLONIEX 01:59:10: Deposit address: xxxxxxxxxxxxxxxxxxxxxxxxxxxx 01:59:10: Transfering 0 GAS BINANCE => POLONIEX 01:59:10: Deposit address: xxxxxxxxxxxxxxxxxxxxxxxxxxxx 01:59:11: Transfering 0 GAS BINANCE => POLONIEX 01:59:11: Deposit address: xxxxxxxxxxxxxxxxxxxxxxxxxxxx 01:59:11: Transfering 0 GAS BINANCE => POLONIEX 01:59:11: Deposit address: xxxxxxxxxxxxxxxxxxxxxxxxxxxx 01:59:11: Transfering 0 GAS BINANCE => POLONIEX [...]

After restart, I get this error but then it moves on:

02:13:56: balanceAltcoins() 02:14:16: balance(GAS) 02:14:22: BINANCE: 0.4995 GAS (3 usages) 02:14:22: POLONIEX: 0.52662504 GAS (3 usages) 02:14:22: TOTAL: 1.02612504 GAS 02:14:22: AVERAGE: 0.51306252 GAS 02:14:22: XFER THRES.: 0 GAS 02:14:22: BINANCE is missing -0.01356252 GAS 02:14:22: POLONIEX could give 0.01356252 GAS 02:14:22: Transfering 0.01356252 GAS POLONIEX => BINANCE 02:14:22: Deposit address: xxxxxxxxxxxxxxxxxxxxxxxxxxxx 02:14:23: Transfering 0 GAS POLONIEX => BINANCE 02:14:23: Deposit address: xxxxxxxxxxxxxxxxxxxxxxxxxxxx 02:14:23: ERROR during management task: [POLONIEX] API error response: Amount must be greater than zero.

0 /var/www/arbbot/bot/xchange/Poloniex.php(521): Poloniex->queryAPI('withdraw', Array)

1 /var/www/arbbot/bot/xchange/Poloniex.php(64): Poloniex->queryWithdraw('GAS', 0, 'xxxxxxx...')

2 /var/www/arbbot/bot/CoinManager.php(824): Poloniex->withdraw('GAS', 0, 'xxxxxxx...')

3 /var/www/arbbot/bot/CoinManager.php(843): CoinManager->doWithdraw(Object(Poloniex), 'GAS', 0, 'xxxxxxx...')

4 /var/www/arbbot/bot/CoinManager.php(394): CoinManager->withdraw(Object(Poloniex), Object(Binance), 'GAS', 0)

5 /var/www/arbbot/bot/CoinManager.php(693): CoinManager->balance('GAS')

6 /var/www/arbbot/bot/CoinManager.php(668): CoinManager->balanceAltcoins()

7 /var/www/arbbot/bot/CoinManager.php(57): CoinManager->manageWallets(Object(Arbitrator))

8 /var/www/arbbot/bot/Arbitrator.php(56): CoinManager->doManage(Object(Arbitrator))

9 /var/www/arbbot/bot/Arbitrator.php(586): Arbitrator->loop()

10 /var/www/arbbot/bot/Arbitrator.php(22): Arbitrator->innerRun()

11 [internal function]: Arbitrator->{closure}(Object(React\EventLoop\Timer\Timer))

12 /var/www/arbbot/lib/composer/vendor/react/event-loop/src/Timer/Timers.php(90): call_user_func(Object(Closure), Object(React\EventLoop\Timer\Timer))

13 /var/www/arbbot/lib/composer/vendor/react/event-loop/src/StreamSelectLoop.php(177): React\EventLoop\Timer\Timers->tick()

14 /var/www/arbbot/bot/Arbitrator.php(579): React\EventLoop\StreamSelectLoop->run()

15 /var/www/arbbot/main.php(154): Arbitrator->run()

16 {main}

cryptoeax commented 6 years ago

The issue in the last comment should be fixed now.

Binance support should generally be very stable these days, and I'm about to merge it to production. If people are seeing more issues on this branch, now is a good time to speak up! :-)