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

Why am I receiving the error "APIError(code=-1013): Filter failure: LOT_SIZE" from python-binance library?

我用 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 TRADE\n\n"
    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.\n\n"
    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.\n\n"
    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. \n\n"
    third_order += "THE BOT HAS FINISHED"
    print(third_order)
    data_log_to_file(third_order)

我不知道怎么改,自从我把第一个 'order_market_buy' 中的 'quantity' 改成 0.26 以来,我认为我一直做对了,它没有买问题。

在 Binance 上交易 BNBBTC 的最小数量是:0.01

您可以通过向 https://api.binance.com/api/v3/exchangeInfo

发送 GET 请求来检查这一点

这里是回复的摘录(LOT_SIZE for 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"
        },
    ],
}