Api 说余额不足,而我有足够的

问题描述

我正在尝试创建与 binance-api 的连接。但是当我尝试购买某种硬币时,在这种情况下是 PANCAKESWAP,我收到以下错误

binance.exceptions.BinanceAPIException: APIError(code=-2010): 账户余额不足,无法执行请求的操作。

我知道我有足够的可用余额,我可以购买其他硬币。我不知道我需要在这里更改什么,下限价订单给了我同样的错误,并且在他们的网站上手动填写订单可以很好地使用完全相同的值。这已经困扰了我几个小时,几个线程并没有让我更明智。这是我的代码

url = "https://api.binance.com/api"

api_secret = "X"
api_key = "X"

client = Client(api_key,api_secret)
client.API_URL = url

# get latest price from Binance API
coin_price = client.get_symbol_ticker(symbol=stringShot)
price = coin_price['price']

#get precision
info = client.get_symbol_info(stringShot)
print(info['filters'][2]['minQty'])
test = info['filters'][2]['minQty']
deci = test.index('1')  # precision is noted as 0.00001,so the index of 1 is the precision.
print(deci)

#get amount of usdt
balance = client.get_asset_balance(asset='USDT')
print(balance['free'])

usdt = (float(11)/float(price))  # buy 11 dollars worth of coin
quantity = float(round(usdt,(deci - 1))) # get the right precision by rounding the numbers 
print(usdt)
print(quantity)

#Convert it in order to buy for a certain amount of USDT
if float(balance['free'])>float(11):  # if there is more than 11 usdt available,buy
        pass

else:
        print("Not enough USDT available.")
        

order = client.create_order(
        symbol=stringShot,side=Client.SIDE_BUY,type=Client.ORDER_TYPE_MARKET,quantity=quantity
)  #market order for buying the coin

解决方法

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

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

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

相关问答

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