Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Zayonx-0 opened this issue Aug 20, 2023 · 4 comments

Comments

@Zayonx-0
Copy link

Zayonx-0 commented Aug 20, 2023

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
Copy link
Owner

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

@aroundm3
Copy link

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

how i can fix this :/

@iterativv
Copy link
Owner

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

how i can fix this :/

Still issues with testing ?

@1156230954
Copy link

I also got the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants