iterativv / NostalgiaForInfinity

Trading strategy for the Freqtrade crypto bot
GNU General Public License v3.0
1.93k stars 483 forks source link

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

Open Zayonx-0 opened 11 months ago

Zayonx-0 commented 11 months ago

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'
iterativv commented 11 months ago

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

aroundm3 commented 11 months ago

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

how i can fix this :/

iterativv commented 11 months ago

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

how i can fix this :/

Still issues with testing ?

1156230954 commented 10 months ago

I also got the same issue.