Add test for exit_timeout_count
This commit is contained in:
parent
7a907a7636
commit
f7dc47b1c8
@ -496,8 +496,7 @@ class LocalTrade():
|
|||||||
Get amount of failed exiting orders
|
Get amount of failed exiting orders
|
||||||
assumes full exits.
|
assumes full exits.
|
||||||
"""
|
"""
|
||||||
orders = [o for o in self.orders if o.ft_order_side == 'sell']
|
return len([o for o in self.orders if o.ft_order_side == 'sell'])
|
||||||
return len(orders)
|
|
||||||
|
|
||||||
def _calc_open_trade_value(self) -> float:
|
def _calc_open_trade_value(self) -> float:
|
||||||
"""
|
"""
|
||||||
|
@ -2134,11 +2134,12 @@ def test_check_handle_timedout_buy_exception(default_conf_usdt, ticker_usdt,
|
|||||||
|
|
||||||
|
|
||||||
def test_check_handle_timedout_sell_usercustom(default_conf_usdt, ticker_usdt, limit_sell_order_old,
|
def test_check_handle_timedout_sell_usercustom(default_conf_usdt, ticker_usdt, limit_sell_order_old,
|
||||||
mocker, open_trade) -> None:
|
mocker, open_trade, caplog) -> None:
|
||||||
default_conf_usdt["unfilledtimeout"] = {"buy": 1440, "sell": 1440}
|
default_conf_usdt["unfilledtimeout"] = {"buy": 1440, "sell": 1440, "exit_timeout_count": 1}
|
||||||
rpc_mock = patch_RPCManager(mocker)
|
rpc_mock = patch_RPCManager(mocker)
|
||||||
cancel_order_mock = MagicMock()
|
cancel_order_mock = MagicMock()
|
||||||
patch_exchange(mocker)
|
patch_exchange(mocker)
|
||||||
|
et_mock = mocker.patch('freqtrade.freqtradebot.FreqtradeBot.execute_trade_exit')
|
||||||
mocker.patch.multiple(
|
mocker.patch.multiple(
|
||||||
'freqtrade.exchange.Exchange',
|
'freqtrade.exchange.Exchange',
|
||||||
fetch_ticker=ticker_usdt,
|
fetch_ticker=ticker_usdt,
|
||||||
@ -2181,6 +2182,14 @@ def test_check_handle_timedout_sell_usercustom(default_conf_usdt, ticker_usdt, l
|
|||||||
assert open_trade.is_open is True
|
assert open_trade.is_open is True
|
||||||
assert freqtrade.strategy.check_sell_timeout.call_count == 1
|
assert freqtrade.strategy.check_sell_timeout.call_count == 1
|
||||||
|
|
||||||
|
# 2nd canceled trade ...
|
||||||
|
caplog.clear()
|
||||||
|
open_trade.open_order_id = 'order_id_2'
|
||||||
|
mocker.patch('freqtrade.persistence.Trade.get_exit_order_count', return_value=1)
|
||||||
|
freqtrade.check_handle_timedout()
|
||||||
|
assert log_has_re('Emergencyselling trade.*', caplog)
|
||||||
|
assert et_mock.call_count == 1
|
||||||
|
|
||||||
|
|
||||||
def test_check_handle_timedout_sell(default_conf_usdt, ticker_usdt, limit_sell_order_old, mocker,
|
def test_check_handle_timedout_sell(default_conf_usdt, ticker_usdt, limit_sell_order_old, mocker,
|
||||||
open_trade) -> None:
|
open_trade) -> None:
|
||||||
|
@ -13,7 +13,7 @@ from sqlalchemy import create_engine, inspect, text
|
|||||||
from freqtrade import constants
|
from freqtrade import constants
|
||||||
from freqtrade.exceptions import DependencyException, OperationalException
|
from freqtrade.exceptions import DependencyException, OperationalException
|
||||||
from freqtrade.persistence import LocalTrade, Order, Trade, clean_dry_run_db, init_db
|
from freqtrade.persistence import LocalTrade, Order, Trade, clean_dry_run_db, init_db
|
||||||
from tests.conftest import create_mock_trades, log_has, log_has_re
|
from tests.conftest import create_mock_trades, create_mock_trades_usdt, log_has, log_has_re
|
||||||
|
|
||||||
|
|
||||||
def test_init_create_session(default_conf):
|
def test_init_create_session(default_conf):
|
||||||
@ -1190,6 +1190,14 @@ def test_get_best_pair(fee):
|
|||||||
assert res[1] == 0.01
|
assert res[1] == 0.01
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("init_persistence")
|
||||||
|
def test_get_exit_order_count(fee):
|
||||||
|
|
||||||
|
create_mock_trades_usdt(fee)
|
||||||
|
trade = Trade.get_trades([Trade.pair == 'ETC/USDT']).first()
|
||||||
|
assert trade.get_exit_order_count() == 1
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.usefixtures("init_persistence")
|
@pytest.mark.usefixtures("init_persistence")
|
||||||
def test_update_order_from_ccxt(caplog):
|
def test_update_order_from_ccxt(caplog):
|
||||||
# Most basic order return (only has orderid)
|
# Most basic order return (only has orderid)
|
||||||
|
Loading…
Reference in New Issue
Block a user