Running the bot with UI breaks the nonces

Issue #574 resolved
Desrever Nu created an issue

I tried running bitcoincoid bot without UI, for 20 minutes without errors.

Running it via GUI generates a lot of nonce errors, probably due to the frequent calls to order manager. .

trying now the same with poloniex

Comments (10)

  1. Desrever Nu reporter

    Same is true with poloniex.

    This exposes a known problem with the wrappers. We can't call their API too often or it will break their pipeline.

    There is no quick solution to this without changing the strategy logic completely and the TradeInterfaces to use queues for API calls. That is something planned for the future.

    I now suggest trying to slow down the request to update active orders (one per minute, one per 30 seconds .... ) . Or require the user to press a refresh button (and check he doesn't do it too often). Or, instead of making new API calls, we can use the information when it is available to the strategy and inject it into html pages in the front end.

    Can't think anything else at the moment

  2. Benjamin Cordes

    this fetch call needs to be removed

    Global.balanceManager.fetchBalance(CurrencyList.BTC);
    Amount balance = Global.balanceManager.getBalance();
    
  3. Desrever Nu reporter

    If, as we assessed in fix/574, the number of remote calls doesn't augment with GUI, then there must be something different in the way the Strategy is initialised in GUI vs. CLI.

    Can be something subtle, some timeout , some delay in running a task... Will explore more

  4. Desrever Nu reporter

    An update on this issue: I have been running a poloniex bot for several hours, without GUI, and despite considerably less than with GUI, we still have nonce errors .

    Below an extraction of all the nonce errors along a 16 hours session:

    17:44:49.928 c.n.n.t.w.PoloniexWrapper - Poloniex API returned an error: Nonce must be greater than 14296272715090000. You provided 1429631086.
    17:44:49.929 c.n.n.t.w.PoloniexWrapper - nonce error. retry with corrected nonce 14296272715090005
    20:19:20.887 c.n.n.t.w.PoloniexWrapper - Poloniex API returned an error: Nonce must be greater than 14296272715091377. You provided 14296272715091376.
    20:19:20.887 c.n.n.t.w.PoloniexWrapper - nonce error. retry with corrected nonce 14296272715091382
    20:32:21.245 c.n.n.t.w.PoloniexWrapper - Poloniex API returned an error: Nonce must be greater than 14296272715091492. You provided 14296272715091491.
    20:32:21.245 c.n.n.t.w.PoloniexWrapper - nonce error. retry with corrected nonce 14296272715091497
    21:20:31.746 c.n.n.p.PriceFeedManager - Error (null) while updating BTC price from class com.nubits.nubot.pricefeeds.feedservices.CoinbasePriceFeed
    21:35:11.522 c.n.n.t.w.PoloniexWrapper - Poloniex API returned an error: Nonce must be greater than 14296272715092113. You provided 14296272715092112.
    21:35:11.522 c.n.n.t.w.PoloniexWrapper - nonce error. retry with corrected nonce 14296272715092118
    21:35:12.648 c.n.n.t.w.PoloniexWrapper - Poloniex API returned an error: Nonce must be greater than 14296272715092121. You provided 14296272715092120.
    21:35:12.649 c.n.n.t.w.PoloniexWrapper - nonce error. retry with corrected nonce 14296272715092126
    22:32:38.140 c.n.n.t.w.PoloniexWrapper - Poloniex API returned an error: Nonce must be greater than 14296272715092765. You provided 14296272715092764.
    22:32:38.140 c.n.n.t.w.PoloniexWrapper - nonce error. retry with corrected nonce 14296272715092770
    22:32:38.754 c.n.n.t.w.PoloniexWrapper - Poloniex API returned an error: Nonce must be greater than 14296272715092772. You provided 14296272715092771.
    22:32:38.755 c.n.n.s.OrderManager - ApiError [5 : Nonce must be greater than 14296272715092772. You provided 14296272715092771.]
    23:55:59.209 c.n.n.t.w.PoloniexWrapper - Poloniex API returned an error: Nonce must be greater than 14296272715093672. You provided 14296272715093671.
    23:55:59.209 c.n.n.t.w.PoloniexWrapper - nonce error. retry with corrected nonce 14296272715093677
    23:58:00.130 c.n.n.t.w.PoloniexWrapper - Poloniex API returned an error: Nonce must be greater than 14296272715093702. You provided 14296272715093701.
    23:58:00.131 c.n.n.t.w.PoloniexWrapper - nonce error. retry with corrected nonce 14296272715093707
    00:19:51.972 c.n.n.t.w.PoloniexWrapper - Poloniex API returned an error: Nonce must be greater than 14296272715093933. You provided 14296272715093931.
    00:19:51.972 c.n.n.t.w.PoloniexWrapper - nonce error. retry with corrected nonce 14296272715093938
    00:32:51.165 c.n.n.t.w.PoloniexWrapper - Poloniex API returned an error: Nonce must be greater than 14296272715094060. You provided 14296272715094059.
    00:32:51.165 c.n.n.t.w.PoloniexWrapper - nonce error. retry with corrected nonce 14296272715094065
    00:32:51.874 c.n.n.t.w.PoloniexWrapper - Poloniex API returned an error: Nonce must be greater than 14296272715094068. You provided 14296272715094066.
    00:32:51.874 c.n.n.t.w.PoloniexWrapper - nonce error. retry with corrected nonce 14296272715094073
    01:01:01.758 c.n.n.t.w.PoloniexWrapper - Poloniex API returned an error: Nonce must be greater than 14296272715094330. You provided 14296272715094329.
    01:01:01.758 c.n.n.t.w.PoloniexWrapper - nonce error. retry with corrected nonce 14296272715094335
    02:01:41.256 c.n.n.t.w.PoloniexWrapper - Poloniex API returned an error: Nonce must be greater than 14296272715094927. You provided 14296272715094926.
    02:01:41.256 c.n.n.t.w.PoloniexWrapper - nonce error. retry with corrected nonce 14296272715094932
    03:26:25.867 c.n.n.t.w.PoloniexWrapper - Poloniex API returned an error: Nonce must be greater than 14296272715095808. You provided 14296272715095806.
    03:26:25.867 c.n.n.t.w.PoloniexWrapper - nonce error. retry with corrected nonce 14296272715095813
    03:26:26.736 c.n.n.t.w.PoloniexWrapper - Poloniex API returned an error: Nonce must be greater than 14296272715095816. You provided 14296272715095815.
    03:26:26.736 c.n.n.t.w.PoloniexWrapper - nonce error. retry with corrected nonce 14296272715095821
    03:30:31.279 c.n.n.t.w.PoloniexWrapper - Poloniex API returned an error: Nonce must be greater than 14296272715095852. You provided 14296272715095851.
    03:30:31.279 c.n.n.t.w.PoloniexWrapper - nonce error. retry with corrected nonce 14296272715095857
    03:30:32.084 c.n.n.t.w.PoloniexWrapper - Poloniex API returned an error: Nonce must be greater than 14296272715095859. You provided 14296272715095858.
    03:30:32.084 c.n.n.s.OrderManager - ApiError [5 : Nonce must be greater than 14296272715095859. You provided 14296272715095858.]
    04:03:01.210 c.n.n.t.w.PoloniexWrapper - Poloniex API returned an error: Nonce must be greater than 14296272715096101. You provided 14296272715096099.
    04:03:01.210 c.n.n.t.w.PoloniexWrapper - nonce error. retry with corrected nonce 14296272715096106
    04:59:21.342 c.n.n.t.w.PoloniexWrapper - Poloniex API returned an error: Nonce must be greater than 14296272715096726. You provided 14296272715096725.
    04:59:21.342 c.n.n.t.w.PoloniexWrapper - nonce error. retry with corrected nonce 14296272715096731
    06:54:51.199 c.n.n.t.w.PoloniexWrapper - Poloniex API returned an error: Nonce must be greater than 14296272715097940. You provided 14296272715097938.
    06:54:51.199 c.n.n.t.w.PoloniexWrapper - nonce error. retry with corrected nonce 14296272715097945
    07:57:01.559 c.n.n.t.w.PoloniexWrapper - Poloniex API returned an error: Nonce must be greater than 14296272715098543. You provided 14296272715098542.
    07:57:01.559 c.n.n.t.w.PoloniexWrapper - nonce error. retry with corrected nonce 14296272715098548
    08:59:53.554 c.n.n.t.w.PoloniexWrapper - Poloniex API returned an error: Nonce must be greater than 14296272715099141. You provided 14296272715099140.
    08:59:53.554 c.n.n.t.w.PoloniexWrapper - nonce error. retry with corrected nonce 14296272715099146
    09:12:52.124 c.n.n.t.w.PoloniexWrapper - Poloniex API returned an error: Nonce must be greater than 14296272715099296. You provided 14296272715099295.
    09:12:52.124 c.n.n.t.w.PoloniexWrapper - nonce error. retry with corrected nonce 14296272715099301
    09:12:52.474 c.n.n.t.w.PoloniexWrapper - Poloniex API returned an error: Nonce must be greater than 14296272715099302. You provided 14296272715099297.
    09:12:52.474 c.n.n.t.w.PoloniexWrapper - nonce error. retry with corrected nonce 14296272715099307
    09:25:51.632 c.n.n.t.w.PoloniexWrapper - Poloniex API returned an error: Nonce must be greater than 14296272715099429. You provided 14296272715099428.
    09:25:51.632 c.n.n.t.w.PoloniexWrapper - nonce error. retry with corrected nonce 14296272715099434
    09:38:50.908 c.n.n.t.w.PoloniexWrapper - Poloniex API returned an error: Nonce must be greater than 14296272715099575. You provided 14296272715099574.
    09:38:50.908 c.n.n.t.w.PoloniexWrapper - nonce error. retry with corrected nonce 14296272715099580
    
  5. Desrever Nu reporter

    I believe that active orders in GUI it is in fact fetching, not just getting last saved values.

    Please see these two logs, of the same bot run against poloniex :

    with GUI - http://pastebin.com/z7BxwU8y

    without GUI - http://pastebin.com/9R4GmA7a

    With GUI there are lot of these lines that shows that a nonce is computed. If a nonce is computed, I guess it is then used to call the API.

    18:38:21.362 [qtp351747464-21 - //localhost:4567/info] DEBUG - nonce used 14296272715100933 [com.nubits.nubot.trading.wrappers.PoloniexWrapper:772]
    18:38:21.608 [qtp351747464-21 - //localhost:4567/info] DEBUG - activeorders BUY 0 [com.nubits.nubot.strategy.OrderManager:267]
    18:38:21.609 [qtp351747464-21 - //localhost:4567/info] DEBUG - buy orders: 0 [com.nubits.nubot.strategy.OrderManager:283]
    18:38:21.609 [qtp351747464-21 - //localhost:4567/info] DEBUG - nonce used 14296272715100934 [com.nubits.nubot.trading.wrappers.PoloniexWrapper:772]
    18:38:21.851 [qtp351747464-21 - //localhost:4567/info] DEBUG - activeorders SELL 0 [com.nubits.nubot.strategy.OrderManager:267]
    18:38:21.851 [qtp351747464-21 - //localhost:4567/info] DEBUG - sell orders: 0 [com.nubits.nubot.strategy.OrderManager:284]
    18:38:21.852 [qtp351747464-21 - //localhost:4567/info] DEBUG - nonce used 14296272715100935 [com.nubits.nubot.trading.wrappers.PoloniexWrapper:772]
    18:38:21.857 [priceTriggerTask] DEBUG - Obtained price : 235.8 from BtcePriceFeed [com.nubits.nubot.pricefeeds.PriceFeedManager:73]
    18:38:22.367 [qtp351747464-21 - //localhost:4567/info] DEBUG - activeorders BUY 0 [com.nubits.nubot.strategy.OrderManager:267]
    18:38:22.368 [qtp351747464-21 - //localhost:4567/info] DEBUG - nonce used 14296272715100936 [com.nubits.nubot.trading.wrappers.PoloniexWrapper:772]
    18:38:22.369 [qtp351747464-28 - //localhost:4567/startstop] INFO  - start bot success? true [com.nubits.nubot.webui.BotController:104]
    18:38:22.612 [qtp351747464-21 - //localhost:4567/info] DEBUG - activeorders SELL 0 [com.nubits.nubot.strategy.OrderManager:267]
    18:38:22.613 [qtp351747464-21 - //localhost:4567/info] DEBUG - buys: 0 [com.nubits.nubot.webui.LogController:66]
    18:38:22.613 [qtp351747464-21 - //localhost:4567/info] DEBUG - sells: 0 [com.nubits.nubot.webui.
    

    If my suspects were correct, then we need to stop fetching and many of the problems we are experiencing will go away. Do we have a breakthrough here?

  6. Log in to comment