Dave-Vallance / bt-ccxt-store

Fork of Ed Bartosh's CCXT Store Work
MIT License
422 stars 185 forks source link

Crypto-coins errors on sell and buy #31

Open Kadiri84 opened 4 years ago

Kadiri84 commented 4 years ago

Hi fox, i'm coding a scanner bot for short term profit however since the prices are different from coins to coins i got exceptions when buying and selling,i'm 99.9 sure that it has a relation with decimals and the way the function round() is doing the rounding. Here is a block of code:

        m1=client.get_klines(symbol=mycoin, interval='1m')
        tim=datetime.fromtimestamp(int(m1[-1][0])/1000)
        xlslog['Entred time'].append(tim)
        EnterPrice=round(float(m1[-1][4]),7)
        xlslog['inPrice'].append(EnterPrice)
        stoprsi=False
        buystat=True
        xt+=1
        Ploss=(float(EnterPrice)*0.08)/100
        divrsi=(float(EnterPrice)*0.6)/100
        Ploss=float(EnterPrice)-Ploss
        divrsi=round(float(EnterPrice)+divrsi,7)
        inprice=round(float(EnterPrice),7)
        qnt=round(float(15/inprice),4)
        try:
            buyorder = client.order_market_buy(symbol=mycoin,quantity=qnt)
        except BinanceAPIException as e:

            # error handling goes here
            qnt=int(qnt)
            buyorder = client.order_market_buy(symbol=mycoin,quantity=qnt)

Can any experienced coder that dealed with this issue before advise on an idea of how to solve it please? Thank you in advance,

Regards,

Kadiri84 commented 4 years ago

Nobody?

Dave-Vallance commented 4 years ago

What exception are you getting? I would need to see the full error message. If you are getting a Binance API exception, a complete guess without looking at anything is that you are not meeting the minimum order size or tick size.