cryptoeax / arbbot

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

Attempting to refresh exchange data before wallets are initialized #15

Closed grim888 closed 6 years ago

grim888 commented 6 years ago

I'm running the bot on localhost and getting the following:

11:40:14: ARBITRATOR V2.0 launching... sh: 1: /usr/sbin/sendmail: not found 11:40:14: Loading config... 11:40:14: Enabling Bittrex... 11:40:14: Enabling Poloniex... 11:40:14: Configured 2 exchanges! 11:40:14: Testing exchange access... 11:40:15: BITTREX [OK] 11:40:15: POLONIEX [OK] 11:40:15: Refreshing wallets... 11:40:15: Refreshing trading pairs... 11:40:15: Attempting to refresh exchange data before wallets are initialized 11:40:15: Error during main loop: wallets not initialized

0 /var/www/arbbot-production/bot/Arbitrator.php(411): Bittrex->refreshExchangeData()

1 /var/www/arbbot-production/bot/Arbitrator.php(38): Arbitrator->refreshCoinPairs()

2 /var/www/arbbot-production/bot/Arbitrator.php(436): Arbitrator->loop()

3 /var/www/arbbot-production/main.php(62): Arbitrator->run()

4 {main}

Any ideas why?

Thanks

cryptoeax commented 6 years ago

Yeah, I think this means that you currently don't have any wallets generated on Bittrex (I think you are probably using a new account).

I pushed what I think is a fix to this issue in 0c53057. Can you please try updating and give it another shot and let me know how it goes? Thanks!

cryptoeax commented 6 years ago

Oops, I forgot the real fix itself which I pushed in 1f31398. :-)

kingchenx commented 6 years ago

0c53057 and 1f31398 not fixxing the Problem, get the same error :/

grim888 commented 6 years ago

You're correct, both Bittrex and Poloniex are new accounts. The above error is gone but I'm now getting the following: 02:37:33: Error during main loop: [POLONIEX] API error response: Nonce must be greater than 1512959853506130. You provided 1512959853506130.

0 /var/www/arbbot-production/bot/xchange/Poloniex.php(355): Poloniex->queryAPI('returnDepositAd...')

1 /var/www/arbbot-production/bot/xchange/Poloniex.php(238): Poloniex->queryDepositAddresses()

2 /var/www/arbbot-production/bot/Arbitrator.php(411): Poloniex->refreshExchangeData()

3 /var/www/arbbot-production/bot/Arbitrator.php(38): Arbitrator->refreshCoinPairs()

4 /var/www/arbbot-production/bot/Arbitrator.php(436): Arbitrator->loop()

5 /var/www/arbbot-production/main.php(62): Arbitrator->run()

6 {main}

Can the bot run in simulation (i.e. view potential trades and pnl) or do the wallets need to be funded in order for the bot to run?

cryptoeax commented 6 years ago

0c53057 and 1f31398 not fixxing the Problem, get the same error :/

Since you are an existing user (given you have commented on other issues) I suspect your problem may be different, can you please file a new issue and explain the bug you are seeing in more detail?

cryptoeax commented 6 years ago

You're correct, both Bittrex and Poloniex are new accounts. The above error is gone but I'm now getting the following: 02:37:33: Error during main loop: [POLONIEX] API error response: Nonce must be greater than 1512959853506130. You provided 1512959853506130.

0 /var/www/arbbot-production/bot/xchange/Poloniex.php(355): Poloniex->queryAPI('returnDepositAd...')

1 /var/www/arbbot-production/bot/xchange/Poloniex.php(238): Poloniex->queryDepositAddresses()

2 /var/www/arbbot-production/bot/Arbitrator.php(411): Poloniex->refreshExchangeData()

3 /var/www/arbbot-production/bot/Arbitrator.php(38): Arbitrator->refreshCoinPairs()

4 /var/www/arbbot-production/bot/Arbitrator.php(436): Arbitrator->loop()

5 /var/www/arbbot-production/main.php(62): Arbitrator->run()

6 {main}

I have some code on another branch that should improve the cases where we get this error, but this is an intermittent error, which usually goes away if you try again (and is not very common.) I think (or hope at least) it's just bad luck you hit the two of them in succession. Does this go away if you run the bot again?

Can the bot run in simulation (i.e. view potential trades and pnl) or do the wallets need to be funded in order for the bot to run?

It depends on what you mean by simulation. The bot can run without a balance in any wallet or even with balance on your exchange it won't buy any assets if you don't set the autobuy funds setting explicitly, and in that mode it will record the number of arbitrage opportunities it encounters for each asset. Once you give it some autobuy funds then it starts to build up a portfolio and actually perform trades.

Before any trades are made, however, the bot doesn't try to keep track of how much profits it would have made, since it can't take the risk factor into account and such calculations would be fairly pointless.

Note that if the bot doesn't have any autobuy funds but you do have existing balances of the right altcoins (as the bot will determine while it's running) in your exchange it will trade with them, so you should be aware of that before you run the bot.

I hope this answers your question.

grim888 commented 6 years ago

I tried to run the bot again but no luck. But I'll keep trying.

That does answer my question and more. Thanks!

cryptoeax commented 6 years ago

I tried to run the bot again but no luck. But I'll keep trying.

I thought of a way to simplify the nonce generation algorithm which should completely fix this bug that you are seeing (which I have also seen myself on my machine BTW.) I pushed that in eba64c5. Please give it a shot.

Sorry your initial experience is so thorny. I have inherited all of this code, and it will take a while for these rough edges to be ironed out...

grim888 commented 6 years ago

Still getting the nonce error.

17:25:13: [POLONIEX] Invalid data received: ([]) 17:25:13: Error during main loop: [POLONIEX] API error response: Nonce must be greater than 1513013113437461. You provided 1513013113437461.

0 /var/www/arbbot-production/bot/xchange/Poloniex.php(357): Poloniex->queryAPI('returnDepositAd...')

1 /var/www/arbbot-production/bot/xchange/Poloniex.php(238): Poloniex->queryDepositAddresses()

2 /var/www/arbbot-production/bot/Arbitrator.php(411): Poloniex->refreshExchangeData()

3 /var/www/arbbot-production/bot/Arbitrator.php(38): Arbitrator->refreshCoinPairs()

4 /var/www/arbbot-production/bot/Arbitrator.php(436): Arbitrator->loop()

5 /var/www/arbbot-production/main.php(62): Arbitrator->run()

6 {main}

No worries at all, so far I find the project is very interesting.

dalikman commented 6 years ago

Hi, I was also getting the wallet error but the latest commit seems to have addressed that, however, I do get the same nonce error as grim888 (also with POLONIEX).

cryptoeax commented 6 years ago

Hmm, this is really strange, what version are you each running? Do you mind running git rev-parse HEAD in the installation directory and pasting the result here? Thanks!

cryptoeax commented 6 years ago

I have a guess on what could be wrong here (but I'm not too sure about it) and I pushed 8de8ea5 to see if that's the root cause. I'd appreciate if you could update to the latest production branch and see if that makes any positive difference for you.

kingchenx commented 6 years ago

8de8ea5 not fixxed the Problem, still getting the error git rev-parse HEAD give me this fatal: Not a git repository (or any of the parent directories): .git

kingchenx commented 6 years ago

@cryptoeax I think i found a soloution for this (for me works)... But dont know... I deleted the folder + zip with rm -r /var/www/arbbot-prodction / rm var/www/prodction.zip

after this step i installed the bot fresh and it works without the "old" error/bug, maybe this helps the other guys here with the problem?

grim888 commented 6 years ago

I deleted the folder, zip, did a clean install and also installed scp but still the same error.

dalikman commented 6 years ago

Hi, yes I also tried the same (latest commit and new directory), same issue unfortunately.

born2hate commented 6 years ago

got the same problem:

[19:55:06] Error during main loop: [POLONIEX] API error response: Nonce must be greater than 1513187706021365. You provided 1513187706021365.

0 /home/admin/web/mydomainame.com/public_html/production/bot/xchange/Poloniex.php(357): Poloniex->queryAPI('returnDepositAd...')

1 /home/admin/web/mydomainame.com/public_html/production/bot/xchange/Poloniex.php(238): Poloniex->queryDepositAddresses()

2 /home/admin/web/mydomainame.com/public_html/production/bot/Arbitrator.php(411): Poloniex->refreshExchangeData()

3 /home/admin/web/mydomainame.com/public_html/production/bot/Arbitrator.php(38): Arbitrator->refreshCoinPairs()

4 /home/admin/web/mydomainame.com/public_html/production/bot/Arbitrator.php(436): Arbitrator->loop()

5 /home/admin/web/mydomainame.com/public_html/production/main.php(62): Arbitrator->run()

6 {main}

Scorpic1 commented 6 years ago

Setup arbbot again, not have error. But I know in readme have error in NGINX configuration Correct NGINX configuration:

server {

    listen 80;
    root /var/www/arbbot-production/web;
    index index.html;
    server_name localhost;
    location / {

            try_files $uri $uri/ /index.html;
            auth_basic           "Restricted area";
            auth_basic_user_file /var/www/conf/arbitrage.passwd;
    }

    location ~ \.php$ {

      include snippets/fastcgi-php.conf;
      fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;

    }
}
cryptoeax commented 6 years ago

OK, I have run out of ideas, there is something really tricky going on here. To those people who can reproduce this bug, I can use some help in diagnosing this. I have pushed a debug commit to this branch: https://github.com/cryptoeax/arbbot/tree/15-debug Do you mind please using this bot and pasting the terminal output before it hits this error? I am interested in the lines beginning with Generating nonce for.... Thanks!

cryptoeax commented 6 years ago

But I know in readme have error in NGINX configuration

Thanks, fixed this in c1b957b.

grim888 commented 6 years ago

21:11:32: ARBITRATOR V2.0 launching... sh: 1: /usr/sbin/sendmail: not found 21:11:32: Loading config... 21:11:32: Enabling Bittrex... 21:11:32: Enabling Poloniex... 21:11:32: Configured 2 exchanges! 21:11:32: Testing exchange access... 21:11:33: Generating nonce for BITTREX, previousNonce = 0, none = 1513199492946248

21:11:33: BITTREX [OK] 21:11:33: Generating nonce for POLONIEX, previousNonce = 0, none = 1513199493318569 Debug resutls.

21:11:33: POLONIEX [OK] 21:11:34: Refreshing wallets... 21:11:34: Generating nonce for BITTREX, previousNonce = 1513199492946248, none = 1513199494130420

21:11:34: Generating nonce for POLONIEX, previousNonce = 1513199493318569, none = 1513199494263991

grim888 commented 6 years ago

I incremented the nonce the in Poloniex.php queryAPI function just to see what would happen. The output below may help debug the issue.

private function queryAPI( $command, array $req = [ ] ) {

$key = $this->apiKey;
$secret = $this->apiSecret;
//$mt = explode(' ', microtime());
$nonce = $this->nonce();
**$nonce = $nonce + 1;**

21:37:10: ARBITRATOR V2.0 launching... sh: 1: /usr/sbin/sendmail: not found 21:37:10: Loading config... 21:37:10: Enabling Bittrex... 21:37:10: Enabling Poloniex... 21:37:10: Configured 2 exchanges! 21:37:10: Testing exchange access... 21:37:10: Generating nonce for BITTREX, previousNonce = 0, none = 1513201030390438

21:37:10: BITTREX [OK] 21:37:10: Generating nonce for POLONIEX, previousNonce = 0, none = 1513201030697985

21:37:10: POLONIEX [OK] 21:37:10: Refreshing wallets... 21:37:11: Generating nonce for BITTREX, previousNonce = 1513201030390438, none = 1513201031084851

21:37:17: Generating nonce for POLONIEX, previousNonce = 1513201030697985, none = 1513201037775998

21:37:19: Refreshing trading pairs... 21:37:19: Skipping NXT (Blocked from config) 21:37:19: Skipping XMR (Blocked from config) 21:37:19: Skipping BURST (Blocked from config) 21:37:19: Skipping SWIFT (Blocked from config) 21:37:19: Skipping XRP (Blocked from config) 21:37:19: Skipping ETH (Blocked from config) 21:37:19: Skipping STEEM (Blocked from config) 21:37:19: Skipping SBD (Blocked from config) 21:37:19: Skipping ETC (Blocked from config) 21:37:19: Skipping ARDR (Blocked from config) 21:37:19: 175 tradeable pairs @ BITTREX 21:37:19: Skipping BTS (Blocked from config) 21:37:19: Skipping BURST (Blocked from config) 21:37:19: Skipping NXT (Blocked from config) 21:37:19: Skipping XMR (Blocked from config) 21:37:19: Skipping XRP (Blocked from config) 21:37:19: Skipping ETH (Blocked from config) 21:37:19: Skipping STEEM (Blocked from config) 21:37:20: Skipping SBD (Blocked from config) 21:37:20: Skipping ETC (Blocked from config) 21:37:20: Skipping ARDR (Blocked from config) 21:37:20: Generating nonce for POLONIEX, previousNonce = 1513201037775998, none = 1513201040065542

21:37:20: [POLONIEX] Invalid data received: ([]) 21:37:20: Error during main loop: [POLONIEX] API error response: Nonce must be greater than 1513201040065543. You provided 1513201040065543.

0 /var/www/arbbot-production/bot/xchange/Poloniex.php(357): Poloniex->queryAPI('returnDepositAd...')

1 /var/www/arbbot-production/bot/xchange/Poloniex.php(238): Poloniex->queryDepositAddresses()

2 /var/www/arbbot-production/bot/Arbitrator.php(411): Poloniex->refreshExchangeData()

3 /var/www/arbbot-production/bot/Arbitrator.php(38): Arbitrator->refreshCoinPairs()

4 /var/www/arbbot-production/bot/Arbitrator.php(436): Arbitrator->loop()

5 /var/www/arbbot-production/main.php(62): Arbitrator->run()

6 {main}

21:37:21: Refreshing trading pairs... 21:37:21: Skipping NXT (Blocked from config) 21:37:21: Skipping XMR (Blocked from config) 21:37:21: Skipping BURST (Blocked from config) 21:37:21: Skipping SWIFT (Blocked from config) 21:37:21: Skipping XRP (Blocked from config) 21:37:21: Skipping ETH (Blocked from config) 21:37:21: Skipping STEEM (Blocked from config) 21:37:21: Skipping SBD (Blocked from config) 21:37:21: Skipping ETC (Blocked from config) 21:37:21: Skipping ARDR (Blocked from config) 21:37:21: 175 tradeable pairs @ BITTREX 21:37:21: Skipping BTS (Blocked from config) 21:37:21: Skipping BURST (Blocked from config) 21:37:22: Skipping NXT (Blocked from config) 21:37:22: Skipping XMR (Blocked from config) 21:37:22: Skipping XRP (Blocked from config) 21:37:22: Skipping ETH (Blocked from config) 21:37:22: Skipping STEEM (Blocked from config) 21:37:22: Skipping SBD (Blocked from config) 21:37:22: Skipping ETC (Blocked from config) 21:37:22: Skipping ARDR (Blocked from config) 21:37:22: Generating nonce for POLONIEX, previousNonce = 1513201040065542, none = 1513201042215578

21:37:22: [POLONIEX] Invalid data received: ([]) 21:37:22: Error during main loop: [POLONIEX] API error response: Nonce must be greater than 1513201042215579. You provided 1513201042215579.

0 /var/www/arbbot-production/bot/xchange/Poloniex.php(357): Poloniex->queryAPI('returnDepositAd...')

1 /var/www/arbbot-production/bot/xchange/Poloniex.php(238): Poloniex->queryDepositAddresses()

2 /var/www/arbbot-production/bot/Arbitrator.php(411): Poloniex->refreshExchangeData()

3 /var/www/arbbot-production/bot/Arbitrator.php(38): Arbitrator->refreshCoinPairs()

4 /var/www/arbbot-production/bot/Arbitrator.php(436): Arbitrator->loop()

5 /var/www/arbbot-production/main.php(62): Arbitrator->run()

6 {main}

21:37:23: Refreshing trading pairs... 21:37:23: Skipping NXT (Blocked from config) 21:37:23: Skipping XMR (Blocked from config) 21:37:23: Skipping BURST (Blocked from config) 21:37:23: Skipping SWIFT (Blocked from config) 21:37:23: Skipping XRP (Blocked from config) 21:37:23: Skipping ETH (Blocked from config) 21:37:23: Skipping STEEM (Blocked from config) 21:37:23: Skipping SBD (Blocked from config) 21:37:23: Skipping ETC (Blocked from config) 21:37:23: Skipping ARDR (Blocked from config) 21:37:23: 175 tradeable pairs @ BITTREX ^Z [34]+ Stopped php main.php

cryptoeax commented 6 years ago

This is getting very strange! Your log shows no sign of a nonce of 1513201040065543 being generated.

Neither 1513201042215579.

I bet there is another Exchange.php somewhere that is being mis-imported somehow. Can you please run the following command on your root installation directory and find out where your Exchange.php files are located? ls -lR .

cryptoeax commented 6 years ago

(Oh, and please go back to the production branch now, thanks a lot for testing!)

cryptoeax commented 6 years ago

9d37b77 is a fix to the problem that I think is happening based on the logs submitted here. Once you upgrade to that revision, the bot should show you a prompt if there are any stale files in your installation directory at need to be removed, and it will tell you exactly which files those are.

grim888 commented 6 years ago

I did a fresh install on a new machine with new api keys for both exchanges and got the same error. When I run git rev-parse HEAD I get the following 35825fa8e0543c6f99e9611bdfca2ac766793bc3

cryptoeax commented 6 years ago

Hmm. I'm definitely out of ideas on why this is happening at the moment, sorry. I'll keep thinking. I wish I could reproduce this error so I could debug it...

grim888 commented 6 years ago

Hey,

Not sure if you'll get this message, I'm replying to the email notification for issue updates. If you want I can setup a shared meeting session and you can attempt to debug the error on my machine.

Just a thought, so let me know.

grim88

On Thu, Dec 14, 2017 at 7:43 PM, cryptoeax notifications@github.com wrote:

Hmm. I'm definitely out of ideas on why this is happening at the moment, sorry. I'll keep thinking. I wish I could reproduce this error so I could debug it...

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/cryptoeax/arbbot/issues/15#issuecomment-351879921, or mute the thread https://github.com/notifications/unsubscribe-auth/AgnLO9_-4FxuN1mMMbKD-QOlCriSJ-jhks5tAcC1gaJpZM4Q8dtL .

cryptoeax commented 6 years ago

I created a gitter room for discussions, please feel free to join there and send me a message, I will respond if I'm available at the time.