yasinkuyu / binance-trader

💰 Cryptocurrency Trading Bot for Binance (Experimental)
2.51k stars 826 forks source link

NameError: global name 'sell_price' is not defined #172

Open elysium-12 opened 6 years ago

elysium-12 commented 6 years ago

I'm running the latest WeSpeakCrypto, after about 12 hours of running with issues I saw the following, just want to make sure it's not an issue with the settings I'm running: This is the command I'm running:

python trader.py --symbol NAVBNB --profit 1 --quantity 10 

This is the traceback, running on Ubuntu 16.04:

price:0.22143000 buyp:0.21823000 sellp:0.21996790-bid:0.21779000 ask:0.22086000
Buy order created id:1091810, q:10.00000000, p:0.21823000
Profit loss, called order, 1091810
Buy order fail (Not filled) Cancel order...
price:0.22143000 buyp:0.21823000 sellp:0.21996790-bid:0.21779000 ask:0.22086000
Buy order created id:1091811, q:10.00000000, p:0.21823000
Buy order partially filled... Wait 1 more second...
Order still partially filled...
Traceback (most recent call last):
  File "trader.py", line 46, in <module>
    t.run()
  File "./app/Trading.py", line 494, in run
    self.action(symbol)
  File "./app/Trading.py", line 378, in action
    self.sell(symbol, quantity, self.order_id, profitableSellingPrice, lastPrice)
  File "./app/Trading.py", line 110, in sell
    quantity = self.check_partial_order(symbol, orderId, sell_price)
  File "./app/Trading.py", line 281, in check_partial_order
    if self.min_notional > quantity * sell_price:
NameError: global name 'sell_price' is not defined
kfiresmith commented 6 years ago

I think that there is a semantic issue with the code where something is calling the sell() without populating one of it's args, 'sell_price'. It looks like for you it happened when a partially filled buy order times out.

Problematic line might be: https://github.com/yasinkuyu/binance-trader/blob/WeSpeakCrypto/app/Trading.py#L113 - This self.cancel(symbol, orderId), should probably be self.cancel(symbol, orderId, sell_price), but anything that calls sell.self.cancel() needs to pass that argument.

My guess at least.