简体   繁体   中英

__init__() got multiple values for argument 'use_technical_indicator' - error

I can't figure out why I am getting this error. If you can figure it out, I'd appreciate it. If you can provide specific instruction, I'd appreciate it. This code is in one module; there are 7 modules total. 在此处输入图像描述 Python 3.7, Mac OS, code from www.finrl.org

# Perform Feature Engineering:
df = FeatureEngineer(df.copy(),
                    use_technical_indicator=True,
                    use_turbulence=False).preprocess_data()


# add covariance matrix as states
df=df.sort_values(['date','tic'],ignore_index=True)
df.index = df.date.factorize()[0]

cov_list = []
# look back is one year
lookback=252
for i in range(lookback,len(df.index.unique())):
  data_lookback = df.loc[i-lookback:i,:]
  price_lookback=data_lookback.pivot_table(index = 'date',columns = 'tic', values = 'close')
  return_lookback = price_lookback.pct_change().dropna()
  covs = return_lookback.cov().values 
  cov_list.append(covs)
  
df_cov = pd.DataFrame({'date':df.date.unique()[lookback:],'cov_list':cov_list})
df = df.merge(df_cov, on='date')
df = df.sort_values(['date','tic']).reset_index(drop=True)
df.head() 

The function definition statement for FeatureEngineer.__init__ is :

 def __init__(
        self,
        use_technical_indicator=True,
        tech_indicator_list=config.TECHNICAL_INDICATORS_LIST,
        use_turbulence=False,
        user_defined_feature=False,
    ):

As you can see there is no argument (other than self which you should not provide) before use_technical_indicator , so you should remove the df.copy() from before the use_techincal_indicator in your line 2.

Checking the current FeatureEngineer class , you must to provide the df.copy() parameter to the preprocess_data() method.

So, your code have to look like:

# Perform Feature Engineering:
df = FeatureEngineer(use_technical_indicator=True,
                  tech_indicator_list = config.TECHNICAL_INDICATORS_LIST,
                  use_turbulence=True,
                  user_defined_feature = False).preprocess_data(df.copy())

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM