binance-trader icon indicating copy to clipboard operation
binance-trader copied to clipboard

Miscalculating Profit for Sell Order

Open tapir1 opened this issue 7 years ago • 6 comments

Latest WeSpeakCrypto (Binance server delay & Partial fill error). VIBE/BTC at 0.8%, stoploss disabled.

price:0.00010944 buyp:0.00010830 sellp:0.00010894-bid:0.00010808 ask:0.00010941 Buy order created id:2653211, q:27.00000000, p:0.00010830 Buy order filled... Try sell... Sell order create id: 2653255 Sell order (Filled) id: 2653255 LastPrice : 0.00010944 Profit: %0.8. Buy price: 0.00010830 Sell price: 0.00010873 price:0.00010939 buyp:0.00010961 sellp:0.00011027-bid:0.00010939 ask:0.00010998

I'm not too sure what happened but the sell order was created for the wrong price, where profit clearly was not 0.8%, but rather 0.3% and completely undersold the bid/ask price...

EDIT: I'm guessing this next error is a problem with --max_amount True

gb: 'balances' Traceback (most recent call last): File "./trader.py", line 46, in t.run() File "./app/Trading.py", line 469, in run self.action(symbol) File "./app/Trading.py", line 302, in action self.amount = float(Orders.get_balance("BTC")) TypeError: float() argument must be a string or a number

Nevertheless, you guys have been fantastic over this weekend and made great development progress. Apart from the errors mentioned above, this bot has become SO DAMN stable. Thank you!!

tapir1 avatar Jan 21 '18 20:01 tapir1

Also, it seems like the bot crashed after a few hours waiting for a sell order to be filled, not sure if this can really be fixed as it seems like a limitation on the API.

gt: HTTPSConnectionPool(host='www.binance.com', port=443): Max retries exceeded with url: /api/v1/ticker/24hr?symbol=VIBEBTC (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f347a0d7410>: Failed to establish a new connection: [Errno -2] Name or service not known',)) Traceback (most recent call last): File "./trader.py", line 46, in t.run() File "./app/Trading.py", line 469, in run self.action(symbol) File "./app/Trading.py", line 361, in action self.sell(symbol, quantity, self.order_id, profitableSellingPrice, lastPrice) File "./app/Trading.py", line 179, in sell lastPrice = float(Orders.get_ticker(symbol)['lastPrice']) TypeError: 'NoneType' object has no attribute 'getitem'

tapir1 avatar Jan 22 '18 02:01 tapir1

For the first part. Change the default --increasing and --decreasing to 0 if you don't want your buy price and sell price to have some buffer.

Second, is --max_amount True working before that error or that is your first try?

Third, it seems that your internet goes off for sometime there. While holding a coin to be sold. It only checks every 5 seconds so I don't think Binance will ban your ip for that.

WeSpeakCrypto avatar Jan 22 '18 02:01 WeSpeakCrypto

I'm having the same issue... i have switched Internet connections from wireless to gigabit wired to see if it salves the issue.

01325100 buyp:0.01321400 sellp:0.01326700-bid:0.01320100 ask:0.01325000 gt: HTTPSConnectionPool(host='www.binance.com', port=443): Max retries exceeded with url: /api/v1/ticker/24hr?symbol=BNBETH (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f6aa0b87790>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',)) Traceback (most recent call last): File "trader.py", line 46, in t.run() File "./app/Trading.py", line 469, in run self.action(symbol) File "./app/Trading.py", line 280, in action lastPrice = float(ticker['lastPrice']) TypeError: 'NoneType' object has no attribute 'getitem'

nealgentry avatar Jan 22 '18 03:01 nealgentry

@nealgentry Yours is not holding a coin. How many trader are running in your computer? What is your --wait_time (default 0.7)

@elCapitanoh I just got the same issue about the holding coin error. I think what we could do is change the interval it checks. I'll update this to maybe 10 seconds instead of 5.

WeSpeakCrypto avatar Jan 22 '18 04:01 WeSpeakCrypto

Switching to wired connection fixed all my issue...

nealgentry avatar Jan 22 '18 06:01 nealgentry

Hey @WeSpeakCrypto Seems like --max_amount is just broken. I've never been able to get it working even though I have enough balance to meet Binance trading rules. I use BNB for my fees if that's of relevance, and have more than enough of it to cover my trades.

price:0.00009970 buyp:0.00009965 sellp:0.00010045-bid:0.00009965 ask:0.00010053 m: Account has insufficient balance for requested action. bl: 'orderId' price:0.00009970 buyp:0.00009967 sellp:0.00010047-bid:0.00009967 ask:0.00010053 m: Account has insufficient balance for requested action. bl: 'orderId' price:0.00009970 buyp:0.00009969 sellp:0.00010049-bid:0.00009969 ask:0.00010053 m: Account has insufficient balance for requested action. bl: 'orderId' price:0.00009970 buyp:0.00009971 sellp:0.00010051-bid:0.00009971 ask:0.00010053 m: Account has insufficient balance for requested action. bl: 'orderId'

tapir1 avatar Jan 22 '18 15:01 tapir1