hugocen/freqtrade-gym

AttributeError: 'IndicatorforRL' object has no attribute 'ohlcvdata_to_dataframe'

sn3fru opened this issue · 5 comments

I'm trying to use it for the first time and it's giving me this error. Do you know if anything has changed in the structure of the project?

C:\Users\marco\anaconda3\envs\rl\lib\site-packages\stable_baselines_init_.py:33: UserWarning: stable-baselines is in maintenance mode, please use Stable-Baselines3 (SB3) for an up-to-date version. You can find a migration guide in SB3 documentation.
"stable-baselines is in maintenance mode, please use Stable-Baselines3 (SB3) for an up-to-date version. You can find a migration guide in SB3 documentation."
Add {
"method": "AgeFilter",
"min_days_listed": 30
},
to your pairlists in config (Under StaticPairList)
Traceback (most recent call last):
File "deep_rl.py", line 14, in
env = TradingEnv(config)
File "C:\Users\marco\trade\freqtrade\freqtradegym.py", line 44, in init
preprocessed = self.strategy.ohlcvdata_to_dataframe(data)
AttributeError: 'IndicatorforRL' object has no attribute 'ohlcvdata_to_dataframe'

so i am, 😘 i cpy/paste this code lines bit not sure it is yhe best way but it works

def ohlcvdata_to_dataframe(self, data: Dict[str, DataFrame]) -> Dict[str, DataFrame]:
"""
Creates a dataframe and populates indicators for given candle (OHLCV) data
Used by optimize operations only, not during dry / live runs.
Using .copy() to get a fresh copy of the dataframe for every strategy run.
Has positive effects on memory usage for whatever reason - also when
using only one strategy.
"""
return {pair: self.advise_indicators(pair_data.copy(), {'pair': pair})
for pair, pair_data in data.items()}

@brusand @sn3fru @hugocen @i am facing same issue, can you please tell me how exactly did you solve it?

it is showing me error in freqtradegym.py when I run rllib_example.py

File "/home/user/Desktop/freqtrade/freqtrade/freqtradegym.py", line 45, in __init__ preprocessed = self.strategy.ohlcvdata_to_dataframe(data) AttributeError: 'IndicatorforRL' object has no attribute 'ohlcvdata_to_dataframe'

Apreciate your help! Thanks

The same issue. @harshadvekariya What is your tf version? Mine is 1.12

@pnmice
I am using the latest one 2.7.0

@pnmice
I got it working by getting the preprocessing without calling function. We are basically converting json data into a dataframe, so it should be straightforward as follow.

Edit the line no 45 in freqtradegym.py to follow
preprocessed = {pair: self.strategy.advise_indicators(pair_data.copy(), {'pair': pair}) for pair, pair_data in data.items()}

Let me know if you know a better way of doing this. Thanks @brusand for the solution!