Merge branch 'freqtrade:develop' into dca
This commit is contained in:
commit
7200659b35
@ -729,7 +729,7 @@ class FreqtradeBot(LoggingMixin):
|
|||||||
trades_closed += 1
|
trades_closed += 1
|
||||||
|
|
||||||
except DependencyException as exception:
|
except DependencyException as exception:
|
||||||
logger.warning('Unable to sell trade %s: %s', trade.pair, exception)
|
logger.warning(f'Unable to sell trade {trade.pair}: {exception}')
|
||||||
|
|
||||||
# Updating wallets if any trade occurred
|
# Updating wallets if any trade occurred
|
||||||
if trades_closed:
|
if trades_closed:
|
||||||
@ -973,8 +973,12 @@ class FreqtradeBot(LoggingMixin):
|
|||||||
if max_timeouts > 0 and canceled_count >= max_timeouts:
|
if max_timeouts > 0 and canceled_count >= max_timeouts:
|
||||||
logger.warning(f'Emergencyselling trade {trade}, as the sell order '
|
logger.warning(f'Emergencyselling trade {trade}, as the sell order '
|
||||||
f'timed out {max_timeouts} times.')
|
f'timed out {max_timeouts} times.')
|
||||||
self.execute_trade_exit(trade, order.get('price'), sell_reason=SellCheckTuple(
|
try:
|
||||||
sell_type=SellType.EMERGENCY_SELL))
|
self.execute_trade_exit(
|
||||||
|
trade, order.get('price'),
|
||||||
|
sell_reason=SellCheckTuple(sell_type=SellType.EMERGENCY_SELL))
|
||||||
|
except DependencyException as exception:
|
||||||
|
logger.warning(f'Unable to emergency sell trade {trade.pair}: {exception}')
|
||||||
|
|
||||||
def cancel_all_open_orders(self) -> None:
|
def cancel_all_open_orders(self) -> None:
|
||||||
"""
|
"""
|
||||||
|
@ -2171,10 +2171,20 @@ 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 ...
|
# 2nd canceled trade - Fail execute sell
|
||||||
caplog.clear()
|
caplog.clear()
|
||||||
open_trade.open_order_id = 'order_id_2'
|
open_trade.open_order_id = 'order_id_2'
|
||||||
mocker.patch('freqtrade.persistence.Trade.get_exit_order_count', return_value=1)
|
mocker.patch('freqtrade.persistence.Trade.get_exit_order_count', return_value=1)
|
||||||
|
mocker.patch('freqtrade.freqtradebot.FreqtradeBot.execute_trade_exit',
|
||||||
|
side_effect=DependencyException)
|
||||||
|
freqtrade.check_handle_timedout()
|
||||||
|
assert log_has_re('Unable to emergency sell .*', caplog)
|
||||||
|
|
||||||
|
et_mock = mocker.patch('freqtrade.freqtradebot.FreqtradeBot.execute_trade_exit')
|
||||||
|
caplog.clear()
|
||||||
|
|
||||||
|
# 2nd canceled trade ...
|
||||||
|
open_trade.open_order_id = 'order_id_2'
|
||||||
freqtrade.check_handle_timedout()
|
freqtrade.check_handle_timedout()
|
||||||
assert log_has_re('Emergencyselling trade.*', caplog)
|
assert log_has_re('Emergencyselling trade.*', caplog)
|
||||||
assert et_mock.call_count == 1
|
assert et_mock.call_count == 1
|
||||||
|
@ -184,16 +184,18 @@ def test_render_template_fallback(mocker):
|
|||||||
assert 'if self.dp' in val
|
assert 'if self.dp' in val
|
||||||
|
|
||||||
|
|
||||||
def test_parse_db_uri_for_logging() -> None:
|
@pytest.mark.parametrize('conn_url,expected', [
|
||||||
postgresql_conn_uri = "postgresql+psycopg2://scott123:scott123@host/dbname"
|
("postgresql+psycopg2://scott123:scott123@host:1245/dbname",
|
||||||
mariadb_conn_uri = "mariadb+mariadbconnector://app_user:Password123!@127.0.0.1:3306/company"
|
"postgresql+psycopg2://scott123:*****@host:1245/dbname"),
|
||||||
mysql_conn_uri = "mysql+pymysql://user:pass@some_mariadb/dbname?charset=utf8mb4"
|
("postgresql+psycopg2://scott123:scott123@host.name.com/dbname",
|
||||||
sqlite_conn_uri = "sqlite:////freqtrade/user_data/tradesv3.sqlite"
|
"postgresql+psycopg2://scott123:*****@host.name.com/dbname"),
|
||||||
censored_pwd = "*****"
|
("mariadb+mariadbconnector://app_user:Password123!@127.0.0.1:3306/company",
|
||||||
|
"mariadb+mariadbconnector://app_user:*****@127.0.0.1:3306/company"),
|
||||||
|
("mysql+pymysql://user:pass@some_mariadb/dbname?charset=utf8mb4",
|
||||||
|
"mysql+pymysql://user:*****@some_mariadb/dbname?charset=utf8mb4"),
|
||||||
|
("sqlite:////freqtrade/user_data/tradesv3.sqlite",
|
||||||
|
"sqlite:////freqtrade/user_data/tradesv3.sqlite"),
|
||||||
|
])
|
||||||
|
def test_parse_db_uri_for_logging(conn_url, expected) -> None:
|
||||||
|
|
||||||
def get_pwd(x): return x.split(':')[2].split('@')[0]
|
assert parse_db_uri_for_logging(conn_url) == expected
|
||||||
|
|
||||||
assert get_pwd(parse_db_uri_for_logging(postgresql_conn_uri)) == censored_pwd
|
|
||||||
assert get_pwd(parse_db_uri_for_logging(mariadb_conn_uri)) == censored_pwd
|
|
||||||
assert get_pwd(parse_db_uri_for_logging(mysql_conn_uri)) == censored_pwd
|
|
||||||
assert sqlite_conn_uri == parse_db_uri_for_logging(sqlite_conn_uri)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user