yasinkuyu / binance-trader

💰 Cryptocurrency Trading Bot for Binance (Experimental)
2.54k stars 833 forks source link

Key Error? #147

Open nealgentry opened 6 years ago

nealgentry commented 6 years ago

price:0.66850000 buyp:0.66600000 sellp:0.66965500-bid:0.66500000 ask:0.66990000 Buy order created id:2757894, q:20.00000000, p:0.66600000 Profit loss, called order, 2757894 Buy order fail (Not filled) Cancel order... price:0.66800000 buyp:0.66600000 sellp:0.66965500-bid:0.66500000 ask:0.66980000 Buy order created id:2757900, q:20.00000000, p:0.66600000 Buy order filled... Try sell... Sell order create id: 2757906 Profit loss, called order, 2757906 m: Filter failure: PRICE_FILTER Traceback (most recent call last): File "trader.py", line 46, in t.run() File "./app/Trading.py", line 477, in run self.action(symbol) File "./app/Trading.py", line 369, in action self.sell(symbol, quantity, self.order_id, profitableSellingPrice, lastPrice) File "./app/Trading.py", line 165, in sell if self.stop(symbol, quantity, sell_id, sell_price): File "./app/Trading.py", line 233, in stop sell_id = sello['orderId'] KeyError: 'orderId'

6r6 commented 6 years ago

printed the sell-order info in Line 132 , Trading.py.

{'msg': 'Account has insufficient balance for requested action.', 'code': -2010}

binance-rest-server returned code '-2010':

https://github.com/binance-exchange/binance-official-api-docs/blob/master/errors.md

6r6 commented 6 years ago

transfer charge !!!!!!!!!

python trader.py --symbol ETHUSDT --quantity 0.03 --profit 0.4

Through Chrome F12 network tools, I found the deal

You buy 0.03 ETH through REST-API , then you exactaly buy 0.003001 ETH ! you sell 0.03 ETH through REST-API , if your Binance ETH Wallet don't have more than 0.003001 ETH then you automatically sell 0.02998 ETH in Binance-WEB-Client ; but when you sell it through REST-API and exactaly sell 0.03 ETH ,then the error occured !

So the solution is

leave at least 0.01 ETH in your Binance ETH Wallet , then the ETH->USDT deal will be smoothly . So does other tokens . Don't leave your token coin = 0 !

中文解释

你通过币安API买0.03个ETH,实际买下来的就是0.03001个ETH。 你通过币安API卖0.03个ETH,实际卖的是0.03个ETH,如果钱包余额不足,币安网页版会自动转码为0.02998个ETH出售;而通过API提交足量出售申请了,那么API就报错了! 这一点可以从历时委托中,抓取封包看出来。https://www.binance.com/userCenter/orderHistory.html

解决方案就是:如果你要用程序自动交易这个币,保留被套利的币种余额不为0,根据币价值留一点即可。

👍 💯I wish this could help the same people who met the problem 'KeyError: 'orderId''

nealgentry commented 6 years ago

thank you!