None handling in switch_to_long
This commit is contained in:
parent
eab93ebdf8
commit
35c061cd10
19
trader.py
19
trader.py
|
|
@ -700,12 +700,12 @@ class trader:
|
|||
return 1
|
||||
|
||||
#Check if the orders are OK (Is this really necessary?)
|
||||
if self.tp_order is None:
|
||||
self.broker.logger.log_this("Take profit order is None, can't switch to short",1,self.pair)
|
||||
return 1
|
||||
if self.so is None:
|
||||
self.broker.logger.log_this("Safety order is None, can't switch to short",1,self.pair)
|
||||
return 1
|
||||
# if self.tp_order is None:
|
||||
# self.broker.logger.log_this("Take profit order is None, can't switch to short",1,self.pair)
|
||||
# return 1
|
||||
# if self.so is None:
|
||||
# self.broker.logger.log_this("Safety order is None, can't switch to short",1,self.pair)
|
||||
# return 1
|
||||
|
||||
#Send Telegram message
|
||||
self.broker.logger.log_this("Attempting to switch to long bot",0,self.pair)
|
||||
|
|
@ -718,15 +718,22 @@ class trader:
|
|||
except Exception as e:
|
||||
#self.write_to_log(time.strftime(f"[%Y/%m/%d %H:%M:%S] | {self.pair} | Can't find old long file"))
|
||||
self.broker.logger.log_this(f"Can't file oldlong file. Exception: {e}",1,self.pair)
|
||||
self.quit = True
|
||||
return 1
|
||||
|
||||
#Cancel open orders
|
||||
try:
|
||||
if self.so is not None:
|
||||
self.broker.cancel_order(self.so["id"],self.pair)
|
||||
else:
|
||||
self.broker.logger.log_this("Take profit order is None",1,self.pair)
|
||||
except Exception as e:
|
||||
self.broker.logger.log_this(f"Error in cancel_order while cancelling safety order. Exception: {e}",1,self.pair)
|
||||
try:
|
||||
if self.tp_order is not None:
|
||||
self.broker.cancel_order(self.tp_order["id"],self.pair)
|
||||
else:
|
||||
self.broker.logger.log_this("Safety order is None",1,self.pair)
|
||||
except Exception as e:
|
||||
self.broker.logger.log_this(f"Error in cancel_order while cancelling take profit order. Exception: {e}",1,self.pair)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue