为什么我会收到来自python-binance库的错误"APIError(code=-1013): Filter failure: LOT_SIZE"?



我用Python编程语言创建了一个三角套利机器人,用于从VPS在Binance上进行交易。

我已经购买了BTC,这是我想要操作的货币,特别是总共";0.00278926〃;。我也有一个列表的各种代币做三角套利。

想象一下,机器人发现了一个有以下对的套利机会:['BNBBTC', 'ADABNB', 'ADABTC']。显然,机器人应该用BTC购买一定数量的BNB,然后用BNB购买ADA,然后将ADA出售给BTC。在那之前很好。

然而,当它发现这个机会并试图购买时,机器人会在控制台中向我发送以下错误:

APIError(code=-1013): Filter failure: LOT_SIZE

我之前检查过用BTC购买BNB的最低金额是否大于我的金额,事实并非如此,我的金额在最低和最高之间。

这是我的代码,一旦套利机会(扣除费用(将为我们带来利润:

from binance.client import Client
from binance.enums import *
import time
from datetime import datetime
import matplotlib
from matplotlib import cm
import matplotlib.pyplot as plt
import math
from binance_key import BinanceKey
import json
"""
... Here is the code for the Keys, the initialization of the bot, etc.
"""
list_of_arb_sym = [
['BNBBTC', 'ADABNB', 'ADABTC'],         #Buying BNB
['BNBBTC', 'AAVEBNB', 'AAVEBTC'],
['...'] #Imagine that here there are a list of 300 pairs
#Then I have taken care of passing the values ​​of a line from the list to list_of_sym [0], list_of_sym [1], list_of_sym [2] but I do not add it so that it is not excessively long
"""
... here will be that code
"""
# Get values and prices
price_order_1 = client.get_avg_price(symbol=list_of_sym[0])
price_order_2 = client.get_avg_price(symbol=list_of_sym[1])
price_order_3 = client.get_avg_price(symbol=list_of_sym[2])
price1 = float(price_order_1["price"])
price2 = float(price_order_2["price"])
price3 = float(price_order_3["price"])
"""
... more irrelevant code that is working
"""
if arb_opportunity == 'Yes':
place_order_msg = "STARTING TO TRADEnn"
print(place_order_msg)
data_log_to_file(place_order_msg)
#First buy
balance1 = client.get_asset_balance('BTC')
quantity1 = (float(balance1['free'])/price1)
quantity_1 = round(quantity1, 5)


order_1 = client.order_market_buy(
symbol=list_of_sym[0],
quantity=quantity_1)

first_order = "FIRST ORDER DID IT.nn"
print(first_order)
data_log_to_file(first_order)
#Second buy
simbolo2 =list_of_sym[0]
simbolo2form = simbolo2[0:3]
balance2 = client.get_asset_balance(simbolo2form)
quantity2 = (float(balance2['free'])/price2)
quantity_2 = round(quantity2, 5)

order_2 = client.order_market_buy(
symbol=list_of_sym[1],
quantity=quantity_2)
second_order = "SECOND ORDER DID IT.nn"
print(second_order)
data_log_to_file(second_order)
#Sell 
simbolo3 = list_of_sym[1]
simbolo3form = simbolo3[0:-3]
balance3 = client.get_asset_balance(simbolo3form)
quantity3 = (float(balance3['free'])/price3)
quantity_3 = round(quantity3, 5)
order_3 = client.order_market_sell(
symbol=list_of_sym[2],
quantity=quantity_3)

third_order = "SELL DID. nn"
third_order += "THE BOT HAS FINISHED"
print(third_order)
data_log_to_file(third_order)

我不知道如何解决它,我想我一直都做了正确的事情,因为当我把第一个"order_market_buy"中的"数量"改为0.26时,它买起来没有问题。

币安交易BNBBTC的最小数量为:0.01

您可以通过向发送GET请求来对此进行检查https://api.binance.com/api/v3/exchangeInfo

以下是响应的摘录(LOT_SIZE表示BNBBTC(:

{
"symbol": "BNBBTC",
"status": "TRADING",
"baseAsset": "BNB",
"baseAssetPrecision": 8,
"quoteAsset": "BTC",
"quotePrecision": 8,
"quoteAssetPrecision": 8,
"baseCommissionPrecision": 8,
"quoteCommissionPrecision": 8,
...
"filters": [
...
{
"filterType": "LOT_SIZE",
"minQty": "0.01000000",
"maxQty": "100000.00000000",
"stepSize": "0.01000000"
},
],
}

最新更新