Add protections to startup messages
This commit is contained in:
parent
d4799e6aa3
commit
c993831a04
@ -137,7 +137,7 @@ class FreqtradeBot(LoggingMixin):
|
|||||||
Called on startup and after reloading the bot - triggers notifications and
|
Called on startup and after reloading the bot - triggers notifications and
|
||||||
performs startup tasks
|
performs startup tasks
|
||||||
"""
|
"""
|
||||||
self.rpc.startup_messages(self.config, self.pairlists)
|
self.rpc.startup_messages(self.config, self.pairlists, self.protections)
|
||||||
if not self.edge:
|
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)
|
||||||
|
@ -62,7 +62,7 @@ class RPCManager:
|
|||||||
except NotImplementedError:
|
except NotImplementedError:
|
||||||
logger.error(f"Message type '{msg['type']}' not implemented by handler {mod.name}.")
|
logger.error(f"Message type '{msg['type']}' not implemented by handler {mod.name}.")
|
||||||
|
|
||||||
def startup_messages(self, config: Dict[str, Any], pairlist) -> None:
|
def startup_messages(self, config: Dict[str, Any], pairlist, protections) -> None:
|
||||||
if config['dry_run']:
|
if config['dry_run']:
|
||||||
self.send_msg({
|
self.send_msg({
|
||||||
'type': RPCMessageType.WARNING_NOTIFICATION,
|
'type': RPCMessageType.WARNING_NOTIFICATION,
|
||||||
@ -90,3 +90,8 @@ class RPCManager:
|
|||||||
'status': f'Searching for {stake_currency} pairs to buy and sell '
|
'status': f'Searching for {stake_currency} pairs to buy and sell '
|
||||||
f'based on {pairlist.short_desc()}'
|
f'based on {pairlist.short_desc()}'
|
||||||
})
|
})
|
||||||
|
if len(protections.name_list) > 0:
|
||||||
|
self.send_msg({
|
||||||
|
'type': RPCMessageType.STARTUP_NOTIFICATION,
|
||||||
|
'status': f'Using Protections {protections.short_desc()}'
|
||||||
|
})
|
||||||
|
@ -137,7 +137,7 @@ def test_startupmessages_telegram_enabled(mocker, default_conf, caplog) -> None:
|
|||||||
|
|
||||||
freqtradebot = get_patched_freqtradebot(mocker, default_conf)
|
freqtradebot = get_patched_freqtradebot(mocker, default_conf)
|
||||||
rpc_manager = RPCManager(freqtradebot)
|
rpc_manager = RPCManager(freqtradebot)
|
||||||
rpc_manager.startup_messages(default_conf, freqtradebot.pairlists)
|
rpc_manager.startup_messages(default_conf, freqtradebot.pairlists, freqtradebot.protections)
|
||||||
|
|
||||||
assert telegram_mock.call_count == 3
|
assert telegram_mock.call_count == 3
|
||||||
assert "*Exchange:* `bittrex`" in telegram_mock.call_args_list[1][0][0]['status']
|
assert "*Exchange:* `bittrex`" in telegram_mock.call_args_list[1][0][0]['status']
|
||||||
@ -147,10 +147,14 @@ def test_startupmessages_telegram_enabled(mocker, default_conf, caplog) -> None:
|
|||||||
default_conf['whitelist'] = {'method': 'VolumePairList',
|
default_conf['whitelist'] = {'method': 'VolumePairList',
|
||||||
'config': {'number_assets': 20}
|
'config': {'number_assets': 20}
|
||||||
}
|
}
|
||||||
|
default_conf['protections'] = [{"method": "StoplossGuard",
|
||||||
|
"lookback_period": 60, "trade_limit": 2, "stop_duration": 60}]
|
||||||
|
freqtradebot = get_patched_freqtradebot(mocker, default_conf)
|
||||||
|
|
||||||
rpc_manager.startup_messages(default_conf, freqtradebot.pairlists)
|
rpc_manager.startup_messages(default_conf, freqtradebot.pairlists, freqtradebot.protections)
|
||||||
assert telegram_mock.call_count == 3
|
assert telegram_mock.call_count == 4
|
||||||
assert "Dry run is enabled." in telegram_mock.call_args_list[0][0][0]['status']
|
assert "Dry run is enabled." in telegram_mock.call_args_list[0][0][0]['status']
|
||||||
|
assert 'StoplossGuard' in telegram_mock.call_args_list[-1][0][0]['status']
|
||||||
|
|
||||||
|
|
||||||
def test_init_apiserver_disabled(mocker, default_conf, caplog) -> None:
|
def test_init_apiserver_disabled(mocker, default_conf, caplog) -> None:
|
||||||
|
Loading…
Reference in New Issue
Block a user