python-binance order_limit_buy() APIError(code=-1013):过滤器失败:LOT_SIZE

问题描述

我在使用 python-binance 执行限价买单时遇到问题。限价卖单功能执行得很好。我的账户中有 35.95302628 USDT 的余额。 0.06545172930180404 * 548.26772 USDT = 35.89 USDT

self.client = Client(KEY,Secret)

def round_decimals_down(self,number:float,decimals:int=2):
    """
    Returns a value rounded down to a specific number of decimal places.
    """
    self.number = number
    self.decimals = decimals
    if not isinstance(self.decimals,int):
        raise TypeError("decimal places must be an integer")
    elif self.decimals < 0:
        raise ValueError("decimal places has to be 0 or more")
    elif self.decimals == 0:
        return math.floor(self.number)

    factor = 10 ** self.decimals
    return math.floor(self.number * factor) / factor


def sell(self,symbol,offerSellPrice):
    self.symbol = symbol
    self.sellSymbol = (self.symbol + str("USDT"))
    self.quantity = self.cursor.execute("SELECT " + self.symbol + "Quantity FROM Table WHERE tID = (SELECT MAX(tID) FROM Table)").fetchval()
    self.offerSellPrice = offerSellPrice

    self.order = self.client.order_limit_sell(symbol=self.sellSymbol,quantity=self.round_decimals_down(self.quantity,6),price=self.round_decimals_down(self.offerSellPrice,2))


def buy(self,cryptoQuantity,offerBuyPrice):
    self.buySymbol = (symbol + str("USDT"))
    self.cryptoQuantity = cryptoQuantity
    self.offerBuyPrice = offerBuyPrice
    
    self.order = self.client.order_limit_buy(symbol=self.buySymbol,quantity=self.round_decimals_down(self.cryptoQuantity,price=self.round_decimals_down(self.offerBuyPrice,2))

buy('BCH',0.06545172930180404,548.26772)

回溯:


Traceback (most recent call last):
  File "c:\Users\User\Documents\CryptoBot\A9.py",line 891,in <module>
    loop.run_until_complete(main())
  File "C:\Program Files\python39\lib\asyncio\base_events.py",line 642,in run_until_complete
    return future.result()
  File "c:\Users\User\Documents\CryptoBot\A9.py",line 881,in main
    s.operations()
  File "c:\Users\User\Documents\CryptoBot\A9.py",line 604,in operations
    self.buy(self.cryptoToBuy,self.rawCryptoQuantityBCH,self.offerBuyPriceBCH) 
  File "c:\Users\User\Documents\CryptoBot\A9.py",line 422,in buy
    self.order = self.client.order_limit_buy(symbol=self.buySymbol,File "C:\Users\User\AppData\Roaming\Python\python39\site-packages\binance\client.py",line 1460,in order_limit_buy
    return self.order_limit(timeInForce=timeInForce,**params)
  File "C:\Users\User\AppData\Roaming\Python\python39\site-packages\binance\client.py",line 1424,in order_limit
    return self.create_order(**params)
  File "C:\Users\User\AppData\Roaming\Python\python39\site-packages\binance\client.py",line 1387,in create_order
    return self._post('order',True,data=params)
  File "C:\Users\User\AppData\Roaming\Python\python39\site-packages\binance\client.py",line 374,in _post
    return self._request_api('post',path,signed,version,**kwargs)
  File "C:\Users\User\AppData\Roaming\Python\python39\site-packages\binance\client.py",line 334,in _request_api
    return self._request(method,uri,line 315,in _request
    return self._handle_response(self.response)
  File "C:\Users\User\AppData\Roaming\Python\python39\site-packages\binance\client.py",line 324,in _handle_response
    raise BinanceAPIException(response,response.status_code,response.text)
binance.exceptions.BinanceAPIException: APIError(code=-1013): Filter failure: LOT_SIZE

info = client.get_symbol_info('BCHUSDT')
print(info)

返回:

{'symbol': 'BCHUSDT','status': 'TradING','baseAsset': 'BCH','baseAssetPrecision': 8,'quoteAsset': 'USDT','quotePrecision': 8,'quoteAssetPrecision': 8,'baseCommissionPrecision': 8,'quoteCommissionPrecision': 8,'orderTypes': ['LIMIT','LIMIT_MAKER','MARKET','STOP_LOSS_LIMIT','TAKE_PROFIT_LIMIT'],'icebergallowed': True,'ocoAllowed': True,'quoteOrderQtyMarketAllowed': True,'isspotTradingallowed': True,'isMarginTradingallowed': True,'filters': [{'filterType': 'PRICE_FILTER','minPrice': '0.01000000','maxPrice': '100000.00000000','tickSize': '0.01000000'},{'filterType': 'PERCENT_PRICE','multiplierUp': '5','multiplierDown': '0.2','avgPriceMins': 5},{'filterType': 'LOT_SIZE','minQty': '0.00001000','maxQty': '90000.00000000','stepSize': '0.00001000'},{'filterType': 'MIN_NOTIONAL','minNotional': '10.00000000','applyToMarket': True,{'filterType': 'ICEBERG_PARTS','limit': 10},{'filterType': 'MARKET_LOT_SIZE','minQty': '0.00000000','maxQty': '3410.06217369','stepSize': '0.00000000'},{'filterType': 'MAX_NUM_ORDERS','maxnumOrders': 200},{'filterType': 'MAX_NUM_ALGO_ORDERS','maxnumAlgoOrders': 5}],'permissions': ['SPOT','MARGIN']}

LOT_SIZE

{'filterType': 'LOT_SIZE','stepSize': '0.00001000'}

我的订单数量大于'minQt': '0.00001000'

我也以 8 的精度(数量)进行了尝试,但收到了相同的错误

如有任何建议,我们将不胜感激。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...