pyjuque icon indicating copy to clipboard operation
pyjuque copied to clipboard

error on tryExitOrder; cannot place limit order after buy fill due to balance error

Open Joris-H opened this issue 3 years ago • 4 comments

Running the bot on multiple symbols. 1m timeframe. After a while all the filled buy orders get this error:

INFO:pyjuque.Engine.BotController:FILLED BUY order on BNB/USDT, try exit. INFO:pyjuque.Engine.BotController:Error placing order for BNB/USDT: (<class 'ccxt.base.errors.InsufficientFunds'>, InsufficientFunds('binance Account has insufficient balance for requested action.'), <traceback object at 0x7f9db3739ec0>)

I tried playing around with removing take profit, changing 'signal_distance' to market orders. But the issue remains.

The bot is unable to evaluate stop loss or exit signals after this error occurred for a symbol.

Help is appreciated!

Thanks

Joris-H avatar Apr 06 '21 19:04 Joris-H

The problem might be here, that the quantity calculation does not take fees into account, resulting in a too low budget of the symbol. I noticed that Binance does not always take fees in the form of BNB but sometimes in the form of the target symbol.

def computeMatchingOrderQuantity(self, order):
        """ Compute exit quantity so that also partially 
        filled orders can be handled."""
        if order.side == 'buy':
            exit_quantity = order.executed_quantity
        elif order.side == 'sell':
            exit_quantity = order.original_quantity \
                - order.executed_quantity
        return exit_quantity

Joris-H avatar Apr 07 '21 13:04 Joris-H

Hey Joris, thanks a lot for trying pyjuque!

Could you please paste the bot_config that you used to set up this bot?

One potential suggestion is that you set your bot up using a starting_balance parameter that is less than what you actually hold in your inventory. Also, all the symbols in the bot_config should be ending in the same coin.

tudorelu avatar Apr 14 '21 01:04 tudorelu

I see now that that might not necessarily be the fix I need to put some checks in place regarding how much the fees cost and what can be sold on top of that.

What version of pyjuque are you running?

tudorelu avatar Apr 14 '21 01:04 tudorelu

Have same issue Now i clean up database with:

Step 1: it need for we can clean database PRAGMA foreign_keys = OFF;

Step 2: look at breaked orders SELECT * FROM [order] WHERE status = 'closed' AND side = 'buy' AND is_entry = 1 AND is_closed = 0; and delete all of them DELETE FROM [order] WHERE status = 'closed' AND side = 'buy' AND is_entry = 1 AND is_closed = 0;

mikedigriz avatar Jul 13 '21 21:07 mikedigriz