Merge branch 'develop' into pr/mkavinkumar1/6545
This commit is contained in:
@@ -209,13 +209,14 @@ def test_edge_overrides_stoploss(limit_order, fee, caplog, mocker,
|
||||
#
|
||||
# mocking the ticker: price is falling ...
|
||||
enter_price = limit_order['buy']['price']
|
||||
ticker_val = {
|
||||
'bid': enter_price,
|
||||
'ask': enter_price,
|
||||
'last': enter_price,
|
||||
}
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
fetch_ticker=MagicMock(return_value={
|
||||
'bid': enter_price * buy_price_mult,
|
||||
'ask': enter_price * buy_price_mult,
|
||||
'last': enter_price * buy_price_mult,
|
||||
}),
|
||||
fetch_ticker=MagicMock(return_value=ticker_val),
|
||||
get_fee=fee,
|
||||
)
|
||||
#############################################
|
||||
@@ -228,11 +229,12 @@ def test_edge_overrides_stoploss(limit_order, fee, caplog, mocker,
|
||||
freqtrade.enter_positions()
|
||||
trade = Trade.query.first()
|
||||
caplog.clear()
|
||||
limit_order['buy']['id'] = trade.orders[0].order_id
|
||||
oobj = Order.parse_from_ccxt_object(limit_order['buy'], 'NEO/BTC', 'buy')
|
||||
trade.update_order(limit_order['buy'])
|
||||
trade.update_trade(oobj)
|
||||
#############################################
|
||||
ticker_val.update({
|
||||
'bid': enter_price * buy_price_mult,
|
||||
'ask': enter_price * buy_price_mult,
|
||||
'last': enter_price * buy_price_mult,
|
||||
})
|
||||
|
||||
# stoploss shoud be hit
|
||||
assert freqtrade.handle_trade(trade) is not ignore_strat_sl
|
||||
@@ -1776,9 +1778,7 @@ def test_tsl_on_exchange_compatible_with_edge(mocker, edge_conf, fee, caplog,
|
||||
'type': 'stop_loss_limit',
|
||||
'price': 3,
|
||||
'average': 2,
|
||||
'info': {
|
||||
'stopPrice': '2.178'
|
||||
}
|
||||
'stopPrice': '2.178'
|
||||
})
|
||||
|
||||
mocker.patch('freqtrade.exchange.Exchange.fetch_stoploss_order', stoploss_order_hanging)
|
||||
@@ -2577,6 +2577,7 @@ def test_check_handle_cancelled_buy(
|
||||
get_fee=fee
|
||||
)
|
||||
freqtrade = FreqtradeBot(default_conf_usdt)
|
||||
open_trade.orders = []
|
||||
open_trade.is_short = is_short
|
||||
Trade.query.session.add(open_trade)
|
||||
|
||||
@@ -2961,6 +2962,7 @@ def test_handle_cancel_enter(mocker, caplog, default_conf_usdt, limit_order, is_
|
||||
freqtrade = FreqtradeBot(default_conf_usdt)
|
||||
freqtrade._notify_enter_cancel = MagicMock()
|
||||
|
||||
# TODO: Convert to real trade
|
||||
trade = MagicMock()
|
||||
trade.pair = 'LTC/USDT'
|
||||
trade.open_rate = 200
|
||||
@@ -2968,6 +2970,7 @@ def test_handle_cancel_enter(mocker, caplog, default_conf_usdt, limit_order, is_
|
||||
trade.entry_side = "buy"
|
||||
l_order['filled'] = 0.0
|
||||
l_order['status'] = 'open'
|
||||
trade.nr_of_successful_entries = 0
|
||||
reason = CANCEL_REASON['TIMEOUT']
|
||||
assert freqtrade.handle_cancel_enter(trade, l_order, reason)
|
||||
assert cancel_order_mock.call_count == 1
|
||||
@@ -3010,7 +3013,9 @@ def test_handle_cancel_enter_exchanges(mocker, caplog, default_conf_usdt, is_sho
|
||||
freqtrade = FreqtradeBot(default_conf_usdt)
|
||||
|
||||
reason = CANCEL_REASON['TIMEOUT']
|
||||
# TODO: Convert to real trade
|
||||
trade = MagicMock()
|
||||
trade.nr_of_successful_entries = 0
|
||||
trade.pair = 'LTC/ETH'
|
||||
trade.entry_side = "sell" if is_short else "buy"
|
||||
assert freqtrade.handle_cancel_enter(trade, limit_buy_order_canceled_empty, reason)
|
||||
@@ -3043,13 +3048,14 @@ def test_handle_cancel_enter_corder_empty(mocker, default_conf_usdt, limit_order
|
||||
|
||||
freqtrade = FreqtradeBot(default_conf_usdt)
|
||||
freqtrade._notify_enter_cancel = MagicMock()
|
||||
|
||||
# TODO: Convert to real trade
|
||||
trade = MagicMock()
|
||||
trade.pair = 'LTC/USDT'
|
||||
trade.entry_side = "buy"
|
||||
trade.open_rate = 200
|
||||
trade.entry_side = "buy"
|
||||
trade.open_order_id = "open_order_noop"
|
||||
trade.nr_of_successful_entries = 0
|
||||
l_order['filled'] = 0.0
|
||||
l_order['status'] = 'open'
|
||||
reason = CANCEL_REASON['TIMEOUT']
|
||||
@@ -3783,6 +3789,7 @@ def test_exit_profit_only(
|
||||
trade = Trade.query.first()
|
||||
assert trade.is_short == is_short
|
||||
oobj = Order.parse_from_ccxt_object(limit_order[eside], limit_order[eside]['symbol'], eside)
|
||||
trade.update_order(limit_order[eside])
|
||||
trade.update_trade(oobj)
|
||||
freqtrade.wallets.update()
|
||||
if profit_only:
|
||||
@@ -4071,6 +4078,7 @@ def test_trailing_stop_loss_positive(
|
||||
trade = Trade.query.first()
|
||||
assert trade.is_short == is_short
|
||||
oobj = Order.parse_from_ccxt_object(limit_order[eside], limit_order[eside]['symbol'], eside)
|
||||
trade.update_order(limit_order[eside])
|
||||
trade.update_trade(oobj)
|
||||
caplog.set_level(logging.DEBUG)
|
||||
# stop-loss not reached
|
||||
@@ -4816,10 +4824,19 @@ def test_startup_update_open_orders(mocker, default_conf_usdt, fee, caplog, is_s
|
||||
assert len(Order.get_open_orders()) == 2
|
||||
|
||||
caplog.clear()
|
||||
mocker.patch('freqtrade.exchange.Exchange.fetch_order', side_effect=InvalidOrderException)
|
||||
mocker.patch('freqtrade.exchange.Exchange.fetch_order', side_effect=ExchangeError)
|
||||
freqtrade.startup_update_open_orders()
|
||||
assert log_has_re(r"Error updating Order .*", caplog)
|
||||
|
||||
mocker.patch('freqtrade.exchange.Exchange.fetch_order', side_effect=InvalidOrderException)
|
||||
hto_mock = mocker.patch('freqtrade.freqtradebot.FreqtradeBot.handle_timedout_order')
|
||||
# Orders which are no longer found after X days should be assumed as canceled.
|
||||
freqtrade.startup_update_open_orders()
|
||||
assert log_has_re(r"Order is older than \d days.*", caplog)
|
||||
assert hto_mock.call_count == 2
|
||||
assert hto_mock.call_args_list[0][0][0]['status'] == 'canceled'
|
||||
assert hto_mock.call_args_list[1][0][0]['status'] == 'canceled'
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("init_persistence")
|
||||
@pytest.mark.parametrize("is_short", [False, True])
|
||||
|
||||
Reference in New Issue
Block a user