Skip to content

Commit

Permalink
add warning-message when forcebuy_enable is true
Browse files Browse the repository at this point in the history
  • Loading branch information
xmatthias committed Oct 10, 2018
1 parent 6ff4c9b commit 9d219f9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/configuration.md
Expand Up @@ -117,7 +117,7 @@ If the value is `stopped` the bot has to be started with `/start` first.
### Understand forcebuy_enable

`forcebuy_enable` enables the usage of forcebuy commands via Telegram.
This is disabled for security reasons by default.
This is disabled for security reasons by default, and will show a warning message on startup if enabled.
You send `/forcebuy ETH/BTC` to the bot, who buys the pair and holds it until a regular sell-signal appears (ROI, stoploss, /forcesell).

Can be dangerous with some strategies, so use with care
Expand Down
3 changes: 3 additions & 0 deletions freqtrade/configuration.py
Expand Up @@ -127,6 +127,9 @@ def _load_common_config(self, config: Dict[str, Any]) -> Dict[str, Any]:
config['db_url'] = constants.DEFAULT_DB_PROD_URL
logger.info('Dry run is disabled')

if config.get('forcebuy_enable', False):
logger.warning('`forcebuy` RPC message enabled.')

logger.info(f'Using DB: "{config["db_url"]}"')

# Check if the exchange set by the user is supported
Expand Down
13 changes: 13 additions & 0 deletions freqtrade/tests/test_configuration.py
Expand Up @@ -455,5 +455,18 @@ def test_set_loggers() -> None:
assert logging.getLogger('telegram').level is logging.INFO


def test_load_config_warn_forcebuy(default_conf, mocker, caplog) -> None:
default_conf['forcebuy_enable'] = True
mocker.patch('freqtrade.configuration.open', mocker.mock_open(
read_data=json.dumps(default_conf)
))

args = Arguments([], '').get_parsed_arg()
configuration = Configuration(args)
validated_conf = configuration.load_config()

assert validated_conf.get('forcebuy_enable')
assert log_has('`forcebuy` RPC message enabled.', caplog.record_tuples)

def test_validate_default_conf(default_conf) -> None:
validate(default_conf, constants.CONF_SCHEMA)

0 comments on commit 9d219f9

Please sign in to comment.