Skip to content

Commit

Permalink
wip fix test_rpc_force_exit
Browse files Browse the repository at this point in the history
  • Loading branch information
Axel-CH committed Jun 21, 2023
1 parent ca4ef22 commit 1ed6f18
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions freqtrade/rpc/rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,21 +763,22 @@ def _rpc_reload_trade_from_exchange(self, trade_id: int) -> Dict[str, str]:

def __exec_force_exit(self, trade: Trade, ordertype: Optional[str],
amount: Optional[float] = None) -> bool:
# Check if there is there is an open order
# Check if there is there is open orders
fully_canceled = False
if trade.open_order_id:
order = self._freqtrade.exchange.fetch_order(trade.open_order_id, trade.pair)
for oo in trade.open_orders:
order = self._freqtrade.exchange.fetch_order(oo.order_id, trade.pair)

if order['side'] == trade.entry_side:
fully_canceled = self._freqtrade.handle_cancel_enter(
trade, order, CANCEL_REASON['FORCE_EXIT'])
trade, order, oo.order_id, CANCEL_REASON['FORCE_EXIT'])

if order['side'] == trade.exit_side:
# Cancel order - so it is placed anew with a fresh price.
self._freqtrade.handle_cancel_exit(trade, order, CANCEL_REASON['FORCE_EXIT'])
self._freqtrade.handle_cancel_exit(
trade, order, oo.order_id, CANCEL_REASON['FORCE_EXIT'])

if not fully_canceled:
if trade.open_order_id is not None:
if trade.has_open_orders:
# Order cancellation failed, so we can't exit.
return False
# Get current rate and execute sell
Expand Down

0 comments on commit 1ed6f18

Please sign in to comment.