iterativv / NostalgiaForInfinity

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

KeyError: btc_pct_close_max_72_5m #257

Closed IamBusy closed 1 year ago

IamBusy commented 1 year ago

I got the error message when backtesing this strategy. How can I resolved it?

2022-11-07 14:37:44,761 - freqtrade.data.history.idatahandler - INFO - Price jump in BTCST/USDT, 1d, spot between two candles of 90.00% detected.
2022-11-07 14:37:44,913 - freqtrade.data.history.idatahandler - INFO - Price jump in BTCST/USDT, 1h, spot between two candles of 90.00% detected.
2022-11-07 14:37:45,312 - freqtrade.data.history.idatahandler - INFO - Price jump in BTCST/USDT, 15m, spot between two candles of 90.00% detected.
2022-11-07 14:46:57,793 - freqtrade.optimize.backtesting - INFO - Backtesting with data from 2018-01-06 00:00:00 up to 2022-11-06 22:00:00 (1765 days).
2022-11-07 14:46:59,675 - freqtrade - ERROR - Fatal exception!
Traceback (most recent call last):
  File "/Users/william/development/python/py3.8/lib/python3.8/site-packages/pandas/core/indexes/base.py", line 3803, in get_loc
    return self._engine.get_loc(casted_key)
  File "pandas/_libs/index.pyx", line 138, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/index.pyx", line 165, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/hashtable_class_helper.pxi", line 5745, in pandas._libs.hashtable.PyObjectHashTable.get_item
  File "pandas/_libs/hashtable_class_helper.pxi", line 5753, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'btc_pct_close_max_72_5m'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/william/repository/freqtrade/freqtrade/freqtrade/main.py", line 39, in main
    return_code = args['func'](args)
  File "/Users/william/repository/freqtrade/freqtrade/freqtrade/commands/optimize_commands.py", line 58, in start_backtesting
    backtesting.start()
  File "/Users/william/repository/freqtrade/freqtrade/freqtrade/optimize/backtesting.py", line 1327, in start
    min_date, max_date = self.backtest_one_strategy(strat, data, timerange)
  File "/Users/william/repository/freqtrade/freqtrade/freqtrade/optimize/backtesting.py", line 1243, in backtest_one_strategy
    results = self.backtest(
  File "/Users/william/repository/freqtrade/freqtrade/freqtrade/optimize/backtesting.py", line 1162, in backtest
    data: Dict = self._get_ohlcv_as_lists(processed)
  File "/Users/william/repository/freqtrade/freqtrade/freqtrade/optimize/backtesting.py", line 356, in _get_ohlcv_as_lists
    self.strategy.advise_entry(pair_data, {'pair': pair}),
  File "/Users/william/repository/freqtrade/freqtrade/freqtrade/strategy/interface.py", line 1235, in advise_entry
    df = self.populate_entry_trend(dataframe, metadata)
  File "/Users/william/repository/freqtrade/freqtrade/user_data/strategies/NostalgiaForInfinityX.py", line 10402, in populate_entry_trend
    & (dataframe['btc_pct_close_max_72_5m'] < 1.03)
  File "/Users/william/development/python/py3.8/lib/python3.8/site-packages/pandas/core/frame.py", line 3804, in __getitem__
    indexer = self.columns.get_loc(key)
  File "/Users/william/development/python/py3.8/lib/python3.8/site-packages/pandas/core/indexes/base.py", line 3805, in get_loc
    raise KeyError(key) from err
KeyError: 'btc_pct_close_max_72_5m'

Process finished with exit code 1
iterativv commented 1 year ago

Hi. Backtests require candle data for 5m, 15m, 1h, 1d timeframes, INCLUDING for BTC. You will have to add BTC/USDT in your list. Also, check if you are testing in a different tf than 5m, that is likely to not work either.

IamBusy commented 1 year ago

Hi. Backtests require candle data for 5m, 15m, 1h, 1d timeframes, INCLUDING for BTC. You will have to add BTC/USDT in your list. Also, check if you are testing in a different tf than 5m, that is likely to not work either.

BTC/USDT is in my pairs_lists. But I test the strategy with 15m. I try it with 5m again.