Added patch_get_signal(freqtrade, enter_long=False, enter_short=True, exit_short=True) a bunch
This commit is contained in:
parent
d8ba3d8cde
commit
362c29c315
@ -1963,6 +1963,9 @@ def test_handle_trade(
|
||||
assert trade.is_open is True
|
||||
freqtrade.wallets.update()
|
||||
|
||||
if is_short:
|
||||
patch_get_signal(freqtrade, enter_long=False, exit_short=True)
|
||||
else:
|
||||
patch_get_signal(freqtrade, enter_long=False, exit_long=True)
|
||||
assert freqtrade.handle_trade(trade) is True
|
||||
assert trade.open_order_id == exit_order['id']
|
||||
@ -1994,6 +1997,9 @@ def test_handle_overlapping_signals(
|
||||
)
|
||||
|
||||
freqtrade = FreqtradeBot(default_conf_usdt)
|
||||
if is_short:
|
||||
patch_get_signal(freqtrade, enter_long=False, enter_short=True, exit_short=True)
|
||||
else:
|
||||
patch_get_signal(freqtrade, enter_long=True, exit_long=True)
|
||||
freqtrade.strategy.min_roi_reached = MagicMock(return_value=False)
|
||||
|
||||
@ -2026,6 +2032,9 @@ def test_handle_overlapping_signals(
|
||||
assert trades[0].is_open is True
|
||||
|
||||
# Buy and Sell are triggering, so doing nothing ...
|
||||
if is_short:
|
||||
patch_get_signal(freqtrade, enter_long=False, enter_short=True, exit_short=True)
|
||||
else:
|
||||
patch_get_signal(freqtrade, enter_long=True, exit_long=True)
|
||||
assert freqtrade.handle_trade(trades[0]) is False
|
||||
trades = Trade.query.all()
|
||||
@ -2036,6 +2045,9 @@ def test_handle_overlapping_signals(
|
||||
assert trades[0].is_open is True
|
||||
|
||||
# Sell is triggering, guess what : we are Selling!
|
||||
if is_short:
|
||||
patch_get_signal(freqtrade, enter_long=False, exit_short=True)
|
||||
else:
|
||||
patch_get_signal(freqtrade, enter_long=False, exit_long=True)
|
||||
trades = Trade.query.all()
|
||||
for trade in trades:
|
||||
@ -2115,11 +2127,12 @@ def test_handle_trade_use_sell_signal(
|
||||
trade.is_short = is_short
|
||||
trade.is_open = True
|
||||
|
||||
# TODO-lev: patch for short
|
||||
patch_get_signal(freqtrade, enter_long=False, exit_long=False)
|
||||
assert not freqtrade.handle_trade(trade)
|
||||
|
||||
# TODO-lev: patch for short
|
||||
if is_short:
|
||||
patch_get_signal(freqtrade, enter_long=False, exit_short=True)
|
||||
else:
|
||||
patch_get_signal(freqtrade, enter_long=False, exit_long=True)
|
||||
assert freqtrade.handle_trade(trade)
|
||||
assert log_has("ETH/USDT - Sell signal received. sell_type=SellType.SELL_SIGNAL",
|
||||
@ -3143,7 +3156,6 @@ def test_may_execute_trade_exit_after_stoploss_on_exchange_hit(default_conf_usdt
|
||||
freqtrade.enter_positions()
|
||||
freqtrade.check_handle_timedout()
|
||||
trade = Trade.query.first()
|
||||
trade.is_short = is_short
|
||||
trades = [trade]
|
||||
assert trade.stoploss_order_id is None
|
||||
|
||||
@ -3481,10 +3493,17 @@ def test_ignore_roi_if_buy_signal(default_conf_usdt, limit_order, limit_order_op
|
||||
trade.is_short = is_short
|
||||
trade.update(limit_order[enter_side(is_short)])
|
||||
freqtrade.wallets.update()
|
||||
if is_short:
|
||||
patch_get_signal(freqtrade, enter_long=False, enter_short=True, exit_short=True)
|
||||
else:
|
||||
patch_get_signal(freqtrade, enter_long=True, exit_long=True)
|
||||
|
||||
assert freqtrade.handle_trade(trade) is False
|
||||
|
||||
# Test if buy-signal is absent (should sell due to roi = true)
|
||||
if is_short:
|
||||
patch_get_signal(freqtrade, enter_long=False, exit_short=True)
|
||||
else:
|
||||
patch_get_signal(freqtrade, enter_long=False, exit_long=True)
|
||||
assert freqtrade.handle_trade(trade) is True
|
||||
assert trade.sell_reason == SellType.ROI.value
|
||||
@ -3677,11 +3696,17 @@ def test_disable_ignore_roi_if_buy_signal(default_conf_usdt, limit_order, limit_
|
||||
trade.is_short = is_short
|
||||
trade.update(limit_order[enter_side(is_short)])
|
||||
# Sell due to min_roi_reached
|
||||
if is_short:
|
||||
patch_get_signal(freqtrade, enter_long=False, enter_short=True, exit_short=True)
|
||||
else:
|
||||
patch_get_signal(freqtrade, enter_long=True, exit_long=True)
|
||||
assert freqtrade.handle_trade(trade) is True
|
||||
|
||||
# Test if buy-signal is absent
|
||||
if is_short:
|
||||
patch_get_signal(freqtrade, enter_long=False, exit_long=True)
|
||||
else:
|
||||
patch_get_signal(freqtrade, enter_long=False, exit_short=True)
|
||||
assert freqtrade.handle_trade(trade) is True
|
||||
assert trade.sell_reason == SellType.SELL_SIGNAL.value
|
||||
|
||||
@ -4134,6 +4159,9 @@ def test_order_book_ask_strategy(
|
||||
freqtrade.wallets.update()
|
||||
assert trade.is_open is True
|
||||
|
||||
if is_short:
|
||||
patch_get_signal(freqtrade, enter_long=False, exit_short=True)
|
||||
else:
|
||||
patch_get_signal(freqtrade, enter_long=False, exit_long=True)
|
||||
assert freqtrade.handle_trade(trade) is True
|
||||
assert trade.close_rate_requested == order_book_l2.return_value['asks'][0][0]
|
||||
|
Loading…
Reference in New Issue
Block a user