如何解决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 举报,一经查实,本站将立刻删除。