fix more tests including process_open_trade_positions
This commit is contained in:
@@ -615,7 +615,8 @@ class FreqtradeBot(LoggingMixin):
|
|||||||
# Walk through each pair and check if it needs changes
|
# Walk through each pair and check if it needs changes
|
||||||
for trade in Trade.get_open_trades():
|
for trade in Trade.get_open_trades():
|
||||||
# If there is any open orders, wait for them to finish.
|
# If there is any open orders, wait for them to finish.
|
||||||
if trade.open_order_id is None:
|
# TODO Remove to allow mul open orders
|
||||||
|
if trade.open_entry_or_exit_orders_count == 0:
|
||||||
try:
|
try:
|
||||||
self.check_and_call_adjust_trade_position(trade)
|
self.check_and_call_adjust_trade_position(trade)
|
||||||
except DependencyException as exception:
|
except DependencyException as exception:
|
||||||
@@ -1213,7 +1214,6 @@ class FreqtradeBot(LoggingMixin):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
logger.debug('Handling stoploss on exchange %s ...', trade)
|
logger.debug('Handling stoploss on exchange %s ...', trade)
|
||||||
|
|
||||||
stoploss_order = None
|
stoploss_order = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -1236,16 +1236,11 @@ class FreqtradeBot(LoggingMixin):
|
|||||||
self.handle_protections(trade.pair, trade.trade_direction)
|
self.handle_protections(trade.pair, trade.trade_direction)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
print("***************open_orders DEBUG***************")
|
if trade.open_entry_or_exit_orders_count != 0 or not trade.is_open:
|
||||||
print(f"trade.open_orders: {trade.open_orders}")
|
# Trade has an open Buy or Sell order, Stoploss-handling can't happen in this case
|
||||||
print(f"trade.open_orders_count: {trade.open_orders_count}")
|
# as the Amount on the exchange is tied up in another trade.
|
||||||
print(f"trade.open_entry_or_exit_orders_count: {trade.open_entry_or_exit_orders_count}")
|
# The trade can be closed already (sell-order fill confirmation came in this iteration)
|
||||||
|
return False
|
||||||
# if trade.open_entry_or_exit_orders_count != 0 or not trade.is_open:
|
|
||||||
# Trade has an open Buy or Sell order, Stoploss-handling can't happen in this case
|
|
||||||
# as the Amount on the exchange is tied up in another trade.
|
|
||||||
# The trade can be closed already (sell-order fill confirmation came in this iteration)
|
|
||||||
# return False
|
|
||||||
|
|
||||||
# If enter order is fulfilled but there is no stoploss, we add a stoploss on exchange
|
# If enter order is fulfilled but there is no stoploss, we add a stoploss on exchange
|
||||||
if not stoploss_order:
|
if not stoploss_order:
|
||||||
|
|||||||
@@ -5958,7 +5958,7 @@ def test_position_adjust(mocker, default_conf_usdt, fee) -> None:
|
|||||||
assert len(orders) == 2
|
assert len(orders) == 2
|
||||||
trade = Trade.session.scalars(select(Trade)).first()
|
trade = Trade.session.scalars(select(Trade)).first()
|
||||||
assert trade
|
assert trade
|
||||||
assert trade.open_order_id == '651'
|
assert '651' in trade.open_orders_ids
|
||||||
assert trade.open_rate == 11
|
assert trade.open_rate == 11
|
||||||
assert trade.amount == 10
|
assert trade.amount == 10
|
||||||
assert trade.stake_amount == 110
|
assert trade.stake_amount == 110
|
||||||
@@ -5995,7 +5995,7 @@ def test_position_adjust(mocker, default_conf_usdt, fee) -> None:
|
|||||||
# Assert trade is as expected
|
# Assert trade is as expected
|
||||||
trade = Trade.session.scalars(select(Trade)).first()
|
trade = Trade.session.scalars(select(Trade)).first()
|
||||||
assert trade
|
assert trade
|
||||||
assert trade.open_order_id == '651'
|
assert '651' in trade.open_orders_ids
|
||||||
assert trade.open_rate == 11
|
assert trade.open_rate == 11
|
||||||
assert trade.amount == 10
|
assert trade.amount == 10
|
||||||
assert trade.stake_amount == 110
|
assert trade.stake_amount == 110
|
||||||
|
|||||||
Reference in New Issue
Block a user