From b3dafb378e32c39e6eba60e61b2acfc8ea79bf08 Mon Sep 17 00:00:00 2001 From: axel Date: Tue, 3 Aug 2021 16:54:28 -0400 Subject: [PATCH] remove use_custom_entry_price as a config option --- freqtrade/freqtradebot.py | 11 +++++------ freqtrade/resolvers/strategy_resolver.py | 1 - freqtrade/rpc/api_server/api_schemas.py | 1 - freqtrade/rpc/rpc.py | 1 - freqtrade/strategy/interface.py | 23 ++++++++++------------- tests/test_freqtradebot.py | 1 - 6 files changed, 15 insertions(+), 23 deletions(-) diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index ffe223899..ad8d0b9c4 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -480,13 +480,12 @@ class FreqtradeBot(LoggingMixin): else: # Calculate price buy_limit_requested = self.exchange.get_rate(pair, refresh=True, side="buy") - if self.config.get('use_custom_entry_price', False): - custom_entry_price = strategy_safe_wrapper(self.strategy.custom_entry_price, - default_retval=stake_amount)( - pair=pair, current_time=datetime.now(timezone.utc), - current_rate=buy_limit_requested) + custom_entry_price = strategy_safe_wrapper(self.strategy.custom_entry_price, + default_retval=stake_amount)( + pair=pair, current_time=datetime.now(timezone.utc), + current_rate=buy_limit_requested) - buy_limit_requested = custom_entry_price + buy_limit_requested = custom_entry_price if not buy_limit_requested: raise PricingError('Could not determine buy price.') diff --git a/freqtrade/resolvers/strategy_resolver.py b/freqtrade/resolvers/strategy_resolver.py index 3248ed385..1239b78b3 100644 --- a/freqtrade/resolvers/strategy_resolver.py +++ b/freqtrade/resolvers/strategy_resolver.py @@ -79,7 +79,6 @@ class StrategyResolver(IResolver): ("trailing_stop_positive_offset", 0.0), ("trailing_only_offset_is_reached", None), ("use_custom_stoploss", None), - ("use_custom_entry_price", None), ("process_only_new_candles", None), ("order_types", None), ("order_time_in_force", None), diff --git a/freqtrade/rpc/api_server/api_schemas.py b/freqtrade/rpc/api_server/api_schemas.py index c66a01490..318762136 100644 --- a/freqtrade/rpc/api_server/api_schemas.py +++ b/freqtrade/rpc/api_server/api_schemas.py @@ -129,7 +129,6 @@ class ShowConfig(BaseModel): trailing_stop_positive_offset: Optional[float] trailing_only_offset_is_reached: Optional[bool] use_custom_stoploss: Optional[bool] - use_custom_entry_price: Optional[bool] timeframe: Optional[str] timeframe_ms: int timeframe_min: int diff --git a/freqtrade/rpc/rpc.py b/freqtrade/rpc/rpc.py index 2983c1dfa..902975fde 100644 --- a/freqtrade/rpc/rpc.py +++ b/freqtrade/rpc/rpc.py @@ -116,7 +116,6 @@ class RPC: 'trailing_stop_positive_offset': config.get('trailing_stop_positive_offset'), 'trailing_only_offset_is_reached': config.get('trailing_only_offset_is_reached'), 'use_custom_stoploss': config.get('use_custom_stoploss'), - 'use_custom_entry_price': config.get('use_custom_entry_price'), 'bot_name': config.get('bot_name', 'freqtrade'), 'timeframe': config.get('timeframe'), 'timeframe_ms': timeframe_to_msecs(config['timeframe'] diff --git a/freqtrade/strategy/interface.py b/freqtrade/strategy/interface.py index 750f6f39b..d04524687 100644 --- a/freqtrade/strategy/interface.py +++ b/freqtrade/strategy/interface.py @@ -288,7 +288,6 @@ class IStrategy(ABC, HyperStrategyMixin): For full documentation please go to https://www.freqtrade.io/en/latest/strategy-advanced/ When not implemented by a strategy, returns None, orderbook is used to set entry price - Only called when use_custom_entry_price is set to True. :param pair: Pair that's currently analyzed :param current_time: datetime object, containing the current datetime @@ -662,21 +661,19 @@ class IStrategy(ABC, HyperStrategyMixin): :param low: Low value of this candle, only set in backtesting :param high: High value of this candle, only set in backtesting """ + entry_price_value = strategy_safe_wrapper(self.custom_entry_price, default_retval=None)( + pair=pair, + current_time=current_time, + current_rate=current_rate) - if self.use_custom_entry_price: - entry_price_value = strategy_safe_wrapper(self.custom_entry_price, default_retval=None)( - pair=pair, - current_time=current_time, - current_rate=current_rate) - - if entry_price_value is not None: - if entry_price_value > low: - return True - else: - return False + if entry_price_value is not None: + if entry_price_value > low: + return True else: - logger.warning("CustomEntryPrice function did not return valid entry price") return False + else: + logger.warning("CustomEntryPrice function did not return valid entry price") + return False def stop_loss_reached(self, current_rate: float, trade: Trade, current_time: datetime, current_profit: float, diff --git a/tests/test_freqtradebot.py b/tests/test_freqtradebot.py index 6aaa17094..08e02cffb 100644 --- a/tests/test_freqtradebot.py +++ b/tests/test_freqtradebot.py @@ -908,7 +908,6 @@ def test_execute_buy(mocker, default_conf, fee, limit_buy_order, limit_buy_order def test_execute_buy_custom_entry_price(mocker, default_conf, fee, limit_buy_order_open) -> None: patch_RPCManager(mocker) patch_exchange(mocker) - default_conf.update({'use_custom_entry_price': True}) freqtrade = FreqtradeBot(default_conf) freqtrade.strategy.confirm_trade_entry = MagicMock(return_value=False) stake_amount = 3