diff --git a/config_examples/config_binance.example.json b/config_examples/config_binance.example.json index 8e622eeae..ad8862afa 100644 --- a/config_examples/config_binance.example.json +++ b/config_examples/config_binance.example.json @@ -90,7 +90,7 @@ }, "bot_name": "freqtrade", "initial_state": "running", - "forcebuy_enable": false, + "force_enter_enable": false, "internals": { "process_throttle_secs": 5 } diff --git a/config_examples/config_bittrex.example.json b/config_examples/config_bittrex.example.json index d40ea6c5a..a0a5071dd 100644 --- a/config_examples/config_bittrex.example.json +++ b/config_examples/config_bittrex.example.json @@ -87,7 +87,7 @@ }, "bot_name": "freqtrade", "initial_state": "running", - "forcebuy_enable": false, + "force_entry_enable": false, "internals": { "process_throttle_secs": 5 } diff --git a/config_examples/config_ftx.example.json b/config_examples/config_ftx.example.json index f86da8ea0..c49898277 100644 --- a/config_examples/config_ftx.example.json +++ b/config_examples/config_ftx.example.json @@ -89,7 +89,7 @@ }, "bot_name": "freqtrade", "initial_state": "running", - "forcebuy_enable": false, + "force_entry_enable": false, "internals": { "process_throttle_secs": 5 } diff --git a/config_examples/config_full.example.json b/config_examples/config_full.example.json index 04837089f..915db6c44 100644 --- a/config_examples/config_full.example.json +++ b/config_examples/config_full.example.json @@ -174,7 +174,7 @@ "bot_name": "freqtrade", "db_url": "sqlite:///tradesv3.sqlite", "initial_state": "running", - "forcebuy_enable": false, + "force_entry_enable": false, "internals": { "process_throttle_secs": 5, "heartbeat_interval": 60 diff --git a/config_examples/config_kraken.example.json b/config_examples/config_kraken.example.json index 69b00719a..c55dea6ba 100644 --- a/config_examples/config_kraken.example.json +++ b/config_examples/config_kraken.example.json @@ -95,7 +95,7 @@ }, "bot_name": "freqtrade", "initial_state": "running", - "forcebuy_enable": false, + "force_entry_enable": false, "internals": { "process_throttle_secs": 5 }, diff --git a/docs/configuration.md b/docs/configuration.md index ad5b073be..49a59c070 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -166,7 +166,7 @@ Mandatory parameters are marked as **Required**, which means that they are requi | `bot_name` | Name of the bot. Passed via API to a client - can be shown to distinguish / name bots.
*Defaults to `freqtrade`*
**Datatype:** String | `db_url` | Declares database URL to use. NOTE: This defaults to `sqlite:///tradesv3.dryrun.sqlite` if `dry_run` is `true`, and to `sqlite:///tradesv3.sqlite` for production instances.
**Datatype:** String, SQLAlchemy connect string | `initial_state` | Defines the initial application state. If set to stopped, then the bot has to be explicitly started via `/start` RPC command.
*Defaults to `stopped`.*
**Datatype:** Enum, either `stopped` or `running` -| `forcebuy_enable` | Enables the RPC Commands to force a buy. More information below.
**Datatype:** Boolean +| `force_entry_enable` | Enables the RPC Commands to force a Trade entry. More information below.
**Datatype:** Boolean | `disable_dataframe_checks` | Disable checking the OHLCV dataframe returned from the strategy methods for correctness. Only use when intentionally changing the dataframe and understand what you are doing. [Strategy Override](#parameters-in-the-strategy).
*Defaults to `False`*.
**Datatype:** Boolean | `strategy` | **Required** Defines Strategy class to use. Recommended to be set via `--strategy NAME`.
**Datatype:** ClassName | `strategy_path` | Adds an additional strategy lookup path (must be a directory).
**Datatype:** String @@ -345,9 +345,9 @@ If it is not set in either Strategy or Configuration, a default of 1000% `{"0": !!! Note "Special case to forceexit after a specific time" A special case presents using `"": -1` as ROI. This forces the bot to exit a trade after N Minutes, no matter if it's positive or negative, so represents a time-limited force-exit. -### Understand forcebuy_enable +### Understand force_entry_enable -The `forcebuy_enable` configuration parameter enables the usage of forceenter commands via Telegram and REST API. +The `force_entry_enable` configuration parameter enables the usage of force-enter (`/forcelong`, `/forceshort`) commands via Telegram and REST API. For security reasons, it's disabled by default, and freqtrade will show a warning message on startup if enabled. For example, you can send `/forceenter ETH/BTC` to the bot, which will result in freqtrade buying the pair and holds it until a regular exit-signal (ROI, stoploss, /forceexit) appears. diff --git a/docs/rest-api.md b/docs/rest-api.md index e3f9ff53d..1ec9b6c12 100644 --- a/docs/rest-api.md +++ b/docs/rest-api.md @@ -147,8 +147,8 @@ python3 scripts/rest_client.py --config rest_config.json [optional par | `profit` | Display a summary of your profit/loss from close trades and some stats about your performance. | `forceexit ` | Instantly exits the given trade (Ignoring `minimum_roi`). | `forceexit all` | Instantly exits all open trades (Ignoring `minimum_roi`). -| `forceenter [rate]` | Instantly enters the given pair. Rate is optional. (`forcebuy_enable` must be set to True) -| `forceenter [rate]` | Instantly longs or shorts the given pair. Rate is optional. (`forcebuy_enable` must be set to True) +| `forceenter [rate]` | Instantly enters the given pair. Rate is optional. (`force_entry_enable` must be set to True) +| `forceenter [rate]` | Instantly longs or shorts the given pair. Rate is optional. (`force_entry_enable` must be set to True) | `performance` | Show performance of each finished trade grouped by pair. | `balance` | Show account balance per currency. | `daily ` | Shows profit or loss per day, over the last n days (n defaults to 7). diff --git a/docs/strategy_migration.md b/docs/strategy_migration.md index 57e453298..eb1729ba7 100644 --- a/docs/strategy_migration.md +++ b/docs/strategy_migration.md @@ -68,6 +68,7 @@ Note : `force_exit`, `force_enter`, `emergency_exit` are changed to `force_exit` * `sell_profit_only` -> `exit_profit_only` * `sell_profit_offset` -> `exit_profit_offset` * `ignore_roi_if_buy_signal` -> `ignore_roi_if_entry_signal` + * `forcebuy_enable` -> `force_entry_enable` ## Extensive explanation diff --git a/docs/telegram-usage.md b/docs/telegram-usage.md index 4c0296f65..a5709059a 100644 --- a/docs/telegram-usage.md +++ b/docs/telegram-usage.md @@ -174,8 +174,8 @@ official commands. You can ask at any moment for help with `/help`. | `/forceexit ` | Instantly exits the given trade (Ignoring `minimum_roi`). | `/forceexit all` | Instantly exits all open trades (Ignoring `minimum_roi`). | `/fx` | alias for `/forceexit` -| `/forcelong [rate]` | Instantly buys the given pair. Rate is optional and only applies to limit orders. (`forcebuy_enable` must be set to True) -| `/forceshort [rate]` | Instantly shorts the given pair. Rate is optional and only applies to limit orders. This will only work on non-spot markets. (`forcebuy_enable` must be set to True) +| `/forcelong [rate]` | Instantly buys the given pair. Rate is optional and only applies to limit orders. (`force_entry_enable` must be set to True) +| `/forceshort [rate]` | Instantly shorts the given pair. Rate is optional and only applies to limit orders. This will only work on non-spot markets. (`force_entry_enable` must be set to True) | `/performance` | Show performance of each finished trade grouped by pair | `/balance` | Show account balance per currency | `/daily ` | Shows profit or loss per day, over the last n days (n defaults to 7) @@ -290,9 +290,9 @@ Trades created through `/forcelong` will have the buy-tag of `force_entry`. ![Telegram force-buy screenshot](assets/telegram_forcebuy.png) -Note that for this to work, `forcebuy_enable` needs to be set to true. +Note that for this to work, `force_entry_enable` needs to be set to true. -[More details](configuration.md#understand-forcebuy_enable) +[More details](configuration.md#understand-force_entry_enable) ### /performance diff --git a/freqtrade/configuration/configuration.py b/freqtrade/configuration/configuration.py index 12f833174..331901920 100644 --- a/freqtrade/configuration/configuration.py +++ b/freqtrade/configuration/configuration.py @@ -147,8 +147,8 @@ class Configuration: config.update({'db_url': self.args['db_url']}) logger.info('Parameter --db-url detected ...') - if config.get('forcebuy_enable', False): - logger.warning('`forcebuy` RPC message enabled.') + if config.get('force_entry_enable', False): + logger.warning('`force_entry_enable` RPC message enabled.') # Support for sd_notify if 'sd_notify' in self.args and self.args['sd_notify']: diff --git a/freqtrade/configuration/deprecated_settings.py b/freqtrade/configuration/deprecated_settings.py index a00465109..70d29e2bd 100644 --- a/freqtrade/configuration/deprecated_settings.py +++ b/freqtrade/configuration/deprecated_settings.py @@ -55,10 +55,11 @@ def process_deprecated_setting(config: Dict[str, Any], section_old_config = config.get(section_old, {}) if section_old else config if name_old in section_old_config: + section_1 = f"{section_old}.{name_old}" if section_old else f"{name_old}" section_2 = f"{section_new}.{name_new}" if section_new else f"{name_new}" logger.warning( "DEPRECATED: " - f"The `{section_old}.{name_old}` setting is deprecated and " + f"The `{section_1}` setting is deprecated and " "will be removed in the next versions of Freqtrade. " f"Please use the `{section_2}` setting in your configuration instead." ) @@ -76,6 +77,9 @@ def process_temporary_deprecated_settings(config: Dict[str, Any]) -> None: process_deprecated_setting(config, 'ask_strategy', 'ignore_buying_expired_candle_after', None, 'ignore_buying_expired_candle_after') + + process_deprecated_setting(config, None, 'forcebuy_enable', None, 'force_entry_enable') + # New settings if config.get('telegram'): process_deprecated_setting(config['telegram'], 'notification_settings', 'sell', diff --git a/freqtrade/constants.py b/freqtrade/constants.py index b508fd807..8067c1f6a 100644 --- a/freqtrade/constants.py +++ b/freqtrade/constants.py @@ -358,7 +358,7 @@ CONF_SCHEMA = { 'export': {'type': 'string', 'enum': EXPORT_OPTIONS, 'default': 'trades'}, 'disableparamexport': {'type': 'boolean'}, 'initial_state': {'type': 'string', 'enum': ['running', 'stopped']}, - 'forcebuy_enable': {'type': 'boolean'}, + 'force_entry_enable': {'type': 'boolean'}, 'disable_dataframe_checks': {'type': 'boolean'}, 'internals': { 'type': 'object', diff --git a/freqtrade/rpc/api_server/api_schemas.py b/freqtrade/rpc/api_server/api_schemas.py index dc8e0cd23..03049e0f4 100644 --- a/freqtrade/rpc/api_server/api_schemas.py +++ b/freqtrade/rpc/api_server/api_schemas.py @@ -174,7 +174,7 @@ class ShowConfig(BaseModel): timeframe_min: int exchange: str strategy: Optional[str] - forcebuy_enabled: bool + force_entry_enable: bool exit_pricing: Dict[str, Any] entry_pricing: Dict[str, Any] bot_name: str diff --git a/freqtrade/rpc/rpc.py b/freqtrade/rpc/rpc.py index d3e20eaf1..258754b90 100644 --- a/freqtrade/rpc/rpc.py +++ b/freqtrade/rpc/rpc.py @@ -136,7 +136,7 @@ class RPC: ) if 'timeframe' in config else 0, 'exchange': config['exchange']['name'], 'strategy': config['strategy'], - 'forcebuy_enabled': config.get('forcebuy_enable', False), + 'force_entry_enable': config.get('force_entry_enable', False), 'exit_pricing': config.get('exit_pricing', {}), 'entry_pricing': config.get('entry_pricing', {}), 'state': str(botstate), @@ -750,7 +750,7 @@ class RPC: Buys a pair trade at the given or current price """ - if not self._freqtrade.config.get('forcebuy_enable', False): + if not self._freqtrade.config.get('force_entry_enable', False): raise RPCException('Force_entry not enabled.') if self._freqtrade.state != State.RUNNING: diff --git a/freqtrade/rpc/telegram.py b/freqtrade/rpc/telegram.py index ca34515f3..e13e46395 100644 --- a/freqtrade/rpc/telegram.py +++ b/freqtrade/rpc/telegram.py @@ -1377,7 +1377,7 @@ class Telegram(RPCHandler): "*/forceexit |all:* `Instantly exits the given trade or all trades, " "regardless of profit`\n" "*/fe |all:* `Alias to /forceexit`" - f"{force_enter_text if self._config.get('forcebuy_enable', False) else ''}" + f"{force_enter_text if self._config.get('force_entry_enable', False) else ''}" "*/delete :* `Instantly delete the given trade in the database`\n" "*/whitelist:* `Show current whitelist` \n" "*/blacklist [pair]:* `Show current blacklist, or adds one or more pairs " diff --git a/freqtrade/templates/base_config.json.j2 b/freqtrade/templates/base_config.json.j2 index f1f611a45..914aa964b 100644 --- a/freqtrade/templates/base_config.json.j2 +++ b/freqtrade/templates/base_config.json.j2 @@ -72,7 +72,7 @@ }, "bot_name": "freqtrade", "initial_state": "running", - "forcebuy_enable": false, + "force_entry_enable": false, "internals": { "process_throttle_secs": 5 } diff --git a/tests/rpc/test_rpc.py b/tests/rpc/test_rpc.py index a9e887be9..8bdb81072 100644 --- a/tests/rpc/test_rpc.py +++ b/tests/rpc/test_rpc.py @@ -1183,7 +1183,7 @@ def test_rpc_count(mocker, default_conf, ticker, fee) -> None: def test_rpc_force_entry(mocker, default_conf, ticker, fee, limit_buy_order_open) -> None: - default_conf['forcebuy_enable'] = True + default_conf['force_entry_enable'] = True mocker.patch('freqtrade.rpc.telegram.Telegram', MagicMock()) buy_mm = MagicMock(return_value=limit_buy_order_open) mocker.patch.multiple( @@ -1235,7 +1235,7 @@ def test_rpc_force_entry(mocker, default_conf, ticker, fee, limit_buy_order_open def test_rpc_force_entry_stopped(mocker, default_conf) -> None: - default_conf['forcebuy_enable'] = True + default_conf['force_entry_enable'] = True default_conf['initial_state'] = 'stopped' mocker.patch('freqtrade.rpc.telegram.Telegram', MagicMock()) @@ -1259,7 +1259,7 @@ def test_rpc_force_entry_disabled(mocker, default_conf) -> None: def test_rpc_force_entry_wrong_mode(mocker, default_conf) -> None: - default_conf['forcebuy_enable'] = True + default_conf['force_entry_enable'] = True mocker.patch('freqtrade.rpc.telegram.Telegram', MagicMock()) freqtradebot = get_patched_freqtradebot(mocker, default_conf) diff --git a/tests/rpc/test_rpc_apiserver.py b/tests/rpc/test_rpc_apiserver.py index 992e4edf7..3e1710c8e 100644 --- a/tests/rpc/test_rpc_apiserver.py +++ b/tests/rpc/test_rpc_apiserver.py @@ -1086,7 +1086,7 @@ def test_api_force_entry(botclient, mocker, fee, endpoint): assert rc.json() == {"error": f"Error querying /api/v1/{endpoint}: Force_entry not enabled."} # enable forcebuy - ftbot.config['forcebuy_enable'] = True + ftbot.config['force_entry_enable'] = True fbuy_mock = MagicMock(return_value=None) mocker.patch("freqtrade.rpc.RPC._rpc_force_entry", fbuy_mock) diff --git a/tests/test_configuration.py b/tests/test_configuration.py index 64a0446fa..19355b9eb 100644 --- a/tests/test_configuration.py +++ b/tests/test_configuration.py @@ -772,15 +772,15 @@ def test_set_logfile(default_conf, mocker, tmpdir): def test_load_config_warn_forcebuy(default_conf, mocker, caplog) -> None: - default_conf['forcebuy_enable'] = True + default_conf['force_entry_enable'] = True patched_configuration_load_config_file(mocker, default_conf) args = Arguments(['trade']).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) + assert validated_conf.get('force_entry_enable') + assert log_has('`force_entry_enable` RPC message enabled.', caplog) def test_validate_default_conf(default_conf) -> None: diff --git a/tests/test_integration.py b/tests/test_integration.py index c73157afd..8f56c1fea 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -139,7 +139,7 @@ def test_forcebuy_last_unlimited(default_conf, ticker, fee, mocker, balance_rati one trade was sold at a loss. """ default_conf['max_open_trades'] = 5 - default_conf['forcebuy_enable'] = True + default_conf['force_entry_enable'] = True default_conf['stake_amount'] = 'unlimited' default_conf['tradable_balance_ratio'] = balance_ratio default_conf['dry_run_wallet'] = 1000