diff --git a/docs/strategy-advanced.md b/docs/strategy-advanced.md index babcc5e7b..a0ae7201f 100644 --- a/docs/strategy-advanced.md +++ b/docs/strategy-advanced.md @@ -398,10 +398,10 @@ class AwesomeStrategy(IStrategy): ``` !!! Warning - Modifying entry and exit prices will only work for limit orders. Depending on the price chosen, this can result in a lot of unfilled orders. By default the maximum allowed distance between the current price and the custom price is 2%, this value can be changed in config with the `custom_price_max_distance_percent` parameter. + Modifying entry and exit prices will only work for limit orders. Depending on the price chosen, this can result in a lot of unfilled orders. By default the maximum allowed distance between the current price and the custom price is 2%, this value can be changed in config with the `custom_price_max_distance_ratio` parameter. _Exemple_ -If the new_entryprice is 97, the proposed_rate is 100 and the `custom_price_max_distance_percent` is set to 2%, The retained valid custom entry price will be 98. +If the new_entryprice is 97, the proposed_rate is 100 and the `custom_price_max_distance_ratio` is set to 2%, The retained valid custom entry price will be 98. !!! Warning "No backtesting support" Custom entry-prices are currently not supported during backtesting. diff --git a/freqtrade/constants.py b/freqtrade/constants.py index 2f51f45f7..cde276ac0 100644 --- a/freqtrade/constants.py +++ b/freqtrade/constants.py @@ -191,7 +191,7 @@ CONF_SCHEMA = { }, 'required': ['price_side'] }, - 'custom_price_max_distance_percent': { + 'custom_price_max_distance_ratio': { 'type': 'number', 'minimum': 0.0 }, 'order_types': { diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index bd62934c5..caf201451 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -1407,9 +1407,9 @@ class FreqtradeBot(LoggingMixin): else: valid_custom_price = proposed_price - cust_p_max_dist_pct = self.config.get('custom_price_max_distance_percent', 2.0) - min_custom_price_allowed = proposed_price - ((proposed_price * cust_p_max_dist_pct) / 100) - max_custom_price_allowed = proposed_price + ((proposed_price * cust_p_max_dist_pct) / 100) + cust_p_max_dist_r = self.config.get('custom_price_max_distance_ratio', 0.02) + min_custom_price_allowed = proposed_price - (proposed_price * cust_p_max_dist_r) + max_custom_price_allowed = proposed_price + (proposed_price * cust_p_max_dist_r) if valid_custom_price > max_custom_price_allowed: valid_price = max_custom_price_allowed diff --git a/tests/test_freqtradebot.py b/tests/test_freqtradebot.py index 5b5e3ce28..21bad5c64 100644 --- a/tests/test_freqtradebot.py +++ b/tests/test_freqtradebot.py @@ -4595,7 +4595,7 @@ def test_get_valid_price(mocker, default_conf) -> None: patch_RPCManager(mocker) patch_exchange(mocker) freqtrade = FreqtradeBot(default_conf) - freqtrade.config['custom_price_max_distance_percent'] = 2.0 + freqtrade.config['custom_price_max_distance_ratio'] = 0.02 custom_price_string = "10" custom_price_badstring = "10abc"