Closed gzf445 closed 3 years ago
def calc_quantity_from_part(self, symbol, quantityPart, price, side):
# if order[side] == sell: need obtain coin balance
if side == 'BUY':
cur_bal = float(self.get_balance_market_by_symbol(symbol)['free'])
quantity = float(quantityPart) * float(cur_bal) / float(price)
else:
cur_bal = float(self.get_balance_coin_by_symbol(symbol)['free'])
quantity = quantityPart*cur_bal
# balanceIndex = [idx for idx, element in enumerate(self.get_balance()) if element['asset'] == str(symbol)[3:]][0]
# cur_bal = float(self.get_balance()[balanceIndex]['free'])
quantity = round(quantity, 6)
return quantity
maybe this is the problem? Instead of rounding to hard-coded 6 digits, you can find actual precision using this API (it can be different for different tokens): https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#lot_size (stepSize). To convert stepSize to the precision, I use this: precision = int(round(-math.log(stepSize, 10), 0)), and then do round(quantity, precision).
You're right. Thanks for the help
Pull request merged
setting up the system and want to try to place the order,get this error Slave {'asset': 'USDT', 'free': '200.00000000', 'locked': '0.00000000'} {'asset': 'ETH', 'free': '0.00000000', 'locked': '0.00000000'}, Create Order: amount: 0.079711, price: 395.62000000 APIError(code=-1013): Filter failure: LOT_SIZE Slave {'asset': 'USDT', 'free': '200.00000000', 'locked': '0.00000000'} {'asset': 'ETH', 'free': '0.00000000', 'locked': '0.00000000'}, Create Order: amount: 0.079711, price: 395.62000000 APIError(code=-1013): Filter failure: LOT_SIZE {'e': 'outboundAccountPosition', 'E': 1596713805704, 'u': 1596713805702, 'B': [{'a': 'ETH', 'f': '0.08937000', 'l': '0.00000000'}, {'a': 'BNB', 'f': '0.84203880', 'l': '0.00000000'}, {'a': 'USDT', 'f': '64.73866910', 'l': '0.00000000'}]}
it seems like that the amounts have problem.Filter failure: LOT_SIZE