perf: remove redundant signal clearing in strategy analysis

When `process_only_new_candles` is enabled and no new candle is detected,
`_analyze_ticker_internal` previously called `remove_entry_exit_signals` to
clear signal columns. Since the dataframe is a fresh copy from `dp.ohlcv`
(which only contains OHLCV data) and the return value is only used for
basic validation (length, close price, date) in `analyze_pair`, this
operation was redundant.

Removing this call saves approximately 1.3ms per pair per iteration loop
(when skipping analysis), avoiding unnecessary pandas column assignments.

The test `test__analyze_ticker_internal_skip_analyze` was updated to
reflect that signal columns are no longer added in this scenario.
Consumers of analyzed data (e.g. `freqtradebot`) rely on `DataProvider`
cache, which retains the previously analyzed (populated) dataframe.

Co-authored-by: Corax-CoLAB <239841157+Corax-CoLAB@users.noreply.github.com>
pull/12809/head
google-labs-jules[bot] 3 weeks ago
parent 9ed6a15464
commit ea0cce77f7

@ -30,7 +30,6 @@ from freqtrade.enums import (
from freqtrade.exceptions import OperationalException, StrategyError
from freqtrade.exchange import timeframe_to_minutes, timeframe_to_next_date, timeframe_to_seconds
from freqtrade.ft_types import AnnotationType
from freqtrade.misc import remove_entry_exit_signals
from freqtrade.persistence import Order, PairLocks, Trade
from freqtrade.strategy.hyper import HyperStrategyMixin
from freqtrade.strategy.informative_decorator import (
@ -1224,7 +1223,6 @@ class IStrategy(ABC, HyperStrategyMixin):
else:
logger.debug("Skipping TA Analysis for already analyzed candle")
dataframe = remove_entry_exit_signals(dataframe)
logger.debug("Loop Analysis Launched")

@ -846,11 +846,9 @@ def test__analyze_ticker_internal_skip_analyze(ohlcv_history, mocker, caplog) ->
assert ind_mock.call_count == 1
assert entry_mock.call_count == 1
assert entry_mock.call_count == 1
# only skipped analyze adds buy and sell columns, otherwise it's all mocked
assert "enter_long" in ret.columns
assert "exit_long" in ret.columns
assert ret["enter_long"].sum() == 0
assert ret["exit_long"].sum() == 0
# skipped analysis does NOT add buy and sell columns
assert "enter_long" not in ret.columns
assert "exit_long" not in ret.columns
assert not log_has("TA Analysis Launched", caplog)
assert log_has("Skipping TA Analysis for already analyzed candle", caplog)

Loading…
Cancel
Save