Exclude Edge from startup-stoploss calc

Edge would recalculate / reevaluate stoploss values on startup, so these
values are not reliable
This commit is contained in:
Matthias 2019-05-20 19:35:48 +02:00
parent 53af8f331d
commit a39cdd3b2b
2 changed files with 21 additions and 3 deletions

View File

@ -96,6 +96,7 @@ class FreqtradeBot(object):
: return: None : return: None
""" """
self.rpc.startup_messages(self.config, self.pairlists) self.rpc.startup_messages(self.config, self.pairlists)
if not self.edge:
# Adjust stoploss if it was changed # Adjust stoploss if it was changed
Trade.stoploss_reinitialization(self.strategy.stoploss) Trade.stoploss_reinitialization(self.strategy.stoploss)

View File

@ -3136,10 +3136,27 @@ def test_get_sell_rate(default_conf, mocker, ticker, order_book_l2) -> None:
assert rate == 0.043936 assert rate == 0.043936
def test_startup_messages(default_conf, mocker): def test_startup_state(default_conf, mocker):
default_conf['pairlist'] = {'method': 'VolumePairList', default_conf['pairlist'] = {'method': 'VolumePairList',
'config': {'number_assets': 20} 'config': {'number_assets': 20}
} }
mocker.patch('freqtrade.exchange.Exchange.exchange_has', MagicMock(return_value=True)) mocker.patch('freqtrade.exchange.Exchange.exchange_has', MagicMock(return_value=True))
worker = get_patched_worker(mocker, default_conf) worker = get_patched_worker(mocker, default_conf)
assert worker.state is State.RUNNING assert worker.state is State.RUNNING
def test_startup_trade_reinit(default_conf, edge_conf, mocker):
mocker.patch('freqtrade.exchange.Exchange.exchange_has', MagicMock(return_value=True))
reinit_mock = MagicMock()
mocker.patch('freqtrade.persistence.Trade.stoploss_reinitialization', reinit_mock)
ftbot = get_patched_freqtradebot(mocker, default_conf)
ftbot.startup()
assert reinit_mock.call_count == 1
reinit_mock.reset_mock()
ftbot = get_patched_freqtradebot(mocker, edge_conf)
ftbot.startup()
assert reinit_mock.call_count == 0