NostalgiaForInfinity icon indicating copy to clipboard operation
NostalgiaForInfinity copied to clipboard

Backtest failed with unsupported operand type(s) for -: 'numpy.ndarray' and 'Timedelta'.

Open Zayonx-0 opened this issue 1 year ago • 4 comments

Hello there ! When trying to run a backtest on freqtrade using the strategy NostalgiaForInfinityX3, or X4 i get the error Backtest failed with unsupported operand type(s) for -: 'numpy.ndarray' and 'Timedelta'.

What I have done to install the strategy : Download and move the NostalgiaForInfinityX3.py file into the strategies folder. Then tried running the strategy in the webUI and got the error.

Running on Windows 10 with the latest stable version of freqtrade installed via Docker. Same issue when tested on the developper version of freqtrade.

  File "/freqtrade/freqtrade/rpc/api_server/api_backtest.py", line 81, in __run_backtest_bg
    min_date, max_date = ApiBG.bt['bt'].backtest_one_strategy(
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/freqtrade/freqtrade/optimize/backtesting.py", line 1273, in backtest_one_strategy
    preprocessed = self.strategy.advise_all_indicators(data)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/freqtrade/freqtrade/strategy/interface.py", line 1322, in advise_all_indicators
    return {pair: self.advise_indicators(pair_data.copy(), {'pair': pair}).copy()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/freqtrade/freqtrade/strategy/interface.py", line 1322, in <dictcomp>
    return {pair: self.advise_indicators(pair_data.copy(), {'pair': pair}).copy()
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/freqtrade/freqtrade/strategy/interface.py", line 1354, in advise_indicators
    return self.populate_indicators(dataframe, metadata)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/freqtrade/user_data/strategies/NostalgiaForInfinityX3.py", line 2347, in populate_indicators
    dataframe = merge_informative_pair(dataframe, btc_informative, self.timeframe, btc_info_timeframe, ffill=True)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/freqtrade/freqtrade/strategy/strategy_helper.py", line 49, in merge_informative_pair
    informative[date_column] + pd.to_timedelta(minutes_inf, 'm') -
  File "/home/ftuser/.local/lib/python3.11/site-packages/pandas/core/ops/common.py", line 81, in new_method
    return method(self, other)
           ^^^^^^^^^^^^^^^^^^^
  File "/home/ftuser/.local/lib/python3.11/site-packages/pandas/core/arraylike.py", line 194, in __sub__
    return self._arith_method(other, operator.sub)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ftuser/.local/lib/python3.11/site-packages/pandas/core/series.py", line 6112, in _arith_method
    return base.IndexOpsMixin._arith_method(self, other, op)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ftuser/.local/lib/python3.11/site-packages/pandas/core/base.py", line 1348, in _arith_method
    result = ops.arithmetic_op(lvalues, rvalues, op)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ftuser/.local/lib/python3.11/site-packages/pandas/core/ops/array_ops.py", line 224, in arithmetic_op
    res_values = op(left, right)
                 ^^^^^^^^^^^^^^^
TypeError: unsupported operand type(s) for -: 'numpy.ndarray' and 'Timedelta'

Zayonx-0 avatar Aug 20 '23 16:08 Zayonx-0

We are looking into it. I generally test via console only.

iterativv avatar Aug 21 '23 14:08 iterativv

We are looking into it. I generally test via console only.

how i can fix this :/

aroundm3 avatar Aug 23 '23 06:08 aroundm3

We are looking into it. I generally test via console only.

how i can fix this :/

Still issues with testing ?

iterativv avatar Aug 24 '23 05:08 iterativv

I also got the same issue.

1156230954 avatar Aug 26 '23 08:08 1156230954