GUI - Stop button not clearing orders

Issue #623 resolved
Desrever Nu created an issue

Due to the running tasks and despite the fix introduced last week, there are still some situations where an order get placed after the bot is stopped :

12:01:36.634 [qtp1381534221-91 - //localhost:4567/startstop] DEBUG - /startstop called [com.nubits.nubot.webui.BotController:52]
12:01:36.634 [qtp1381534221-91 - //localhost:4567/startstop] INFO  - bot start/stop  >> stop [com.nubits.nubot.webui.BotController:67]
12:01:36.635 [qtp1381534221-91 - //localhost:4567/startstop] INFO  - try interrupt bot [com.nubits.nubot.webui.BotController:111]
12:01:36.635 [qtp1381534221-91 - //localhost:4567/startstop] INFO  - Bot shutting down sequence started. [com.nubits.nubot.bot.NuBotBase:293]
12:01:36.636 [qtp1381534221-91 - //localhost:4567/startstop] INFO  - after 0 hours 0 minutes 9 seconds uptime on ccedk [nbt_btc] [com.nubits.nubot.bot.NuBotBase:302]
12:01:36.817 [qtp1381534221-91 - //localhost:4567/startstop] INFO  - try to shutdown all tasks [com.nubits.nubot.bot.NuBotBase:310]
12:01:36.817 [qtp1381534221-91 - //localhost:4567/startstop] INFO  - Stopping all BotTasks.  [com.nubits.nubot.tasks.TaskManager:148]
12:01:36.817 [qtp1381534221-91 - //localhost:4567/startstop] DEBUG - Shutting down checkConnection (CheckConnectionTask) [com.nubits.nubot.tasks.TaskManager:154]
12:01:36.818 [qtp1381534221-91 - //localhost:4567/startstop] DEBUG - Stopping checkConnection (com.nubits.nubot.tasks.BotTask@5e4334f2) [com.nubits.nubot.tasks.BotTask:69]
12:01:36.818 [qtp1381534221-91 - //localhost:4567/startstop] INFO  - Stopped BotTask checkConnection [com.nubits.nubot.tasks.BotTask:74]
12:01:36.818 [qtp1381534221-91 - //localhost:4567/startstop] DEBUG - Shutting down sendLiquidity (SubmitLiquidityinfoTask) [com.nubits.nubot.tasks.TaskManager:154]
12:01:36.818 [qtp1381534221-91 - //localhost:4567/startstop] DEBUG - Stopping sendLiquidity (com.nubits.nubot.tasks.BotTask@1be6d5d0) [com.nubits.nubot.tasks.BotTask:69]
12:01:36.818 [qtp1381534221-91 - //localhost:4567/startstop] INFO  - Stopped BotTask sendLiquidity [com.nubits.nubot.tasks.BotTask:74]
12:01:36.819 [qtp1381534221-91 - //localhost:4567/startstop] DEBUG - Shutting down Strategy Fiat Task (StrategyPrimaryPegTask) [com.nubits.nubot.tasks.TaskManager:154]
12:01:36.819 [qtp1381534221-91 - //localhost:4567/startstop] DEBUG - Stopping Strategy Fiat Task (com.nubits.nubot.tasks.BotTask@6970ae2a) [com.nubits.nubot.tasks.BotTask:69]
12:01:36.819 [qtp1381534221-91 - //localhost:4567/startstop] INFO  - Stopped BotTask Strategy Fiat Task [com.nubits.nubot.tasks.BotTask:74]
12:01:36.819 [qtp1381534221-91 - //localhost:4567/startstop] DEBUG - Shutting down Strategy Crypto Task (StrategySecondaryPegTask) [com.nubits.nubot.tasks.TaskManager:154]
12:01:36.819 [qtp1381534221-91 - //localhost:4567/startstop] DEBUG - Stopping Strategy Crypto Task (com.nubits.nubot.tasks.BotTask@783ef0f1) [com.nubits.nubot.tasks.BotTask:69]
12:01:36.819 [qtp1381534221-91 - //localhost:4567/startstop] INFO  - Stopped BotTask Strategy Crypto Task [com.nubits.nubot.tasks.BotTask:74]
12:01:36.820 [qtp1381534221-91 - //localhost:4567/startstop] DEBUG - Shutting down priceTriggerTask (PriceMonitorTriggerTask) [com.nubits.nubot.tasks.TaskManager:154]
12:01:36.820 [qtp1381534221-91 - //localhost:4567/startstop] DEBUG - Stopping priceTriggerTask (com.nubits.nubot.tasks.BotTask@3f9dafa0) [com.nubits.nubot.tasks.BotTask:69]
12:01:36.820 [qtp1381534221-91 - //localhost:4567/startstop] INFO  - Stopped BotTask priceTriggerTask [com.nubits.nubot.tasks.BotTask:74]
12:01:36.820 [qtp1381534221-91 - //localhost:4567/startstop] INFO  - BotTasks stopped.  [com.nubits.nubot.tasks.TaskManager:162]
12:01:36.820 [qtp1381534221-91 - //localhost:4567/startstop] INFO  - Clearing out active orders ...  [com.nubits.nubot.bot.NuBotBase:321]
12:01:37.107 [qtp1381534221-91 - //localhost:4567/startstop] DEBUG - {"errors":false,"response":{"entities":[{"order_id":464065,"pair_id":47,"type":"sell","price":0.00708835,"volume":1.5,"fee_percent":0.2,"active":1,"created":1430118092}]},"pagination":{"items_per_page":100,"total_items":1,"current_page":1,"total_pages":1}} [com.nubits.nubot.trading.wrappers.CcedkWrapper:744]
12:01:37.402 [qtp1381534221-91 - //localhost:4567/startstop] DEBUG - {"errors":false,"response":{"entity":{"transaction_id":1031730}},"pagination":false} [com.nubits.nubot.trading.wrappers.CcedkWrapper:744]
12:01:37.403 [qtp1381534221-91 - //localhost:4567/startstop] ERROR - Could not submit request to clear orders [c.n.n.b.NuBotBase:330]
12:01:37.404 [qtp1381534221-91 - //localhost:4567/startstop] INFO  - Logs of this session saved in logs/session_1430128824176 [com.nubits.nubot.bot.NuBotBase:361]
12:01:37.404 [qtp1381534221-91 - //localhost:4567/startstop] DEBUG - remove session file [com.nubits.nubot.bot.NuBotBase:362]
12:01:37.404 [qtp1381534221-91 - //localhost:4567/startstop] INFO  - ** end of the session ** [com.nubits.nubot.bot.NuBotBase:364]
12:01:37.942 [Strategy Crypto Task] DEBUG - {"errors":false,"response":{"entities":[{"currency_id":1,"balance":0.01361381,"address":null},{"currency_id":2,"balance":0.00840513,"address":"1HMuGKuLWChWLBbg1rix4AMoP6twDmw7NZ"},{"currency_id":3,"balance":0,"address":null},{"currency_id":4,"balance":0.06728867,"address":null},{"currency_id":5,"balance":0,"address":null},{"currency_id":7,"balance":0,"address":null},{"currency_id":8,"balance":0.87934115,"address":"PPRmfabN4h3X8pq1z2fm3Vg2LZfb3CPfcP"},{"currency_id":11,"balance":0,"address":null},{"currency_id":12,"balance":0,"address":null},{"currency_id":14,"balance":0,"address":null},{"currency_id":15,"balance":30.02938201,"address":"BKzUQa1QPtEiPbdyXDpBUrbtKYBBKs8Ct2"},{"currency_id":16,"balance":0,"address":null},{"currency_id":17,"balance":0,"address":null},{"currency_id":21,"balance":0,"address":null},{"currency_id":22,"balance":0,"address":null},{"currency_id":23,"balance":0,"address":"SY51eNFoiodcu4bs5cMUM6pr1GekzpxRVf"},{"currency_id":24,"balance":0,"address":null},{"currency_id":25,"balance":0,"address":null}]},"pagination":{"items_per_page":100,"total_items":18,"current_page":1,"total_pages":1}} [com.nubits.nubot.trading.wrappers.CcedkWrapper:744]
12:01:37.943 [Strategy Crypto Task] WARN  - Submiting limit order : SELL side order :  SELL 1.5 NBT @ 0.00708835 BTC [c.n.n.s.S.StrategySecondaryPegUtils:181]
12:01:37.944 [Strategy Crypto Task] INFO  - executeSellsideOrder : nbtbtc 1.5 0.00708835 [com.nubits.nubot.strategy.Secondary.StrategySecondaryPegUtils:166]
12:01:38.245 [Strategy Crypto Task] DEBUG - {"errors":false,"response":{"entity":{"order_id":464078,"transaction_id":1031735}},"pagination":false} [com.nubits.nubot.trading.wrappers.CcedkWrapper:744]
12:01:38.450 [Strategy Crypto Task] INFO  - Strategy - Order success: SELL Response = 464078 [com.nubits.nubot.strategy.Secondary.StrategySecondaryPegUtils:196]
12:01:38.450 [Strategy Crypto Task] INFO  - Initial walls placed [com.nubits.nubot.strategy.Secondary.StrategySecondaryPegUtils:143]

Comments (6)

  1. Desrever Nu reporter

    I wonder when the flag (mode) is changed because right before placing the order there is an interruption check : c.n.n.s.S.StrategySecondaryPegUtils:181

     if (SessionManager.sessionInterrupted()) return false;
            String orderString = orderString(type, amount, rate);
            LOG.warn("Submiting limit order : " + orderString);
    

    More than one second elapsed since the bot received the stop signal. By then that flag (now mode) should be already "shutting down"

    12:01:36.634 [qtp1381534221-91 - //localhost:4567/startstop] DEBUG - /startstop called [com.nubits.nubot.webui.BotController:52]
    .
    .
    .
    12:01:37.943 [Strategy Crypto Task] WARN  - Submiting limit order : SELL side order :  SELL 1.5 NBT @ 0.00708835 BTC [c.n.n.s.S.StrategySecondaryPegUtils:181]
    

    -- any clue?

    PS: Please add a one line explanatory comment around the method : * startupOrShutdown()*

  2. Benjamin Cordes

    A workaround solution: if user starts or stops, he will blocked for 10 seconds from triggering another toggle.

    I think this problem occurs because there is a race between startup and shutdown. So, because the session was only running for a few seconds, we set to halting, and only after that is startup finished and the flag set back. All these difficulties are related to the UI requireing different threading. In console case we kill everything and that's no problem. I'm a bit surprised about the persistence of these issues. To prevent this from happening we need a further check somewhere to prevent this order of events.

    With regards to orders, this looks like a CCEDK issue. "Could not submit request to clear orders "

  3. Desrever Nu reporter

    With regards to orders, this looks like a CCEDK issue. "Could not submit request to clear orders "

    yep, I fixed it in a recent commit.

    if user starts or stops, he will blocked for 10 seconds from triggering another toggle.

    That can be implemented in the UI

  4. Log in to comment