hugocen / freqtrade-gym

A customized gym environment for developing and comparing reinforcement learning algorithms in crypto trading.
GNU General Public License v3.0
223 stars 45 forks source link

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

Open sn3fru opened 3 years ago

sn3fru commented 3 years ago

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'

brusand commented 3 years ago

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()}

harshadvekariya commented 2 years ago

@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

pnmice commented 2 years ago

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

harshadvekariya commented 2 years ago

@pnmice I am using the latest one 2.7.0

harshadvekariya commented 2 years ago

@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!