edate = dt.datetime.strptime(edate_str, "%d-%m-%Y") # %% if (load_data): ######## CREATE THE OBJECT AND LOAD THE DATA ########## # Tell which company and which period we want timeData = CTD.CTimeData(symbols[0], periods[0]) timeData.set_csv(storage_folder, file_name) # Load the data into the model if (preprocessing_data): timeData = tut.preprocess_data(timeData, sdate, edate) ## Get the valid trading days sorted days_keys, day_dict = timeData.get_indexDictByDay() Ndays = len(days_keys) timeData_daily = tut.get_daily_timedata(timeData, symbols[0]) H, L, O, C, V = np.array( timeData_daily.TD[["High", "Low", "Open", "Close", "Volume"]][:]).T if (extract_features): """ Create the target for the regressing and classifier systems """ Target = bMl.diff(C).flatten() # Continuous target .Target[0] = NaN Target_bin = np.zeros(Target.shape) # Binarized target Target_bin[np.where(Target >= 0)] = 1 data_df = None ## Create Pandas Data Frame for the information of the ML problem data_df = pd.DataFrame({ 'Time': days_keys,
edate = dt.datetime.strptime(edate_str, "%d-%m-%Y") if (load_data): ######## CREATE THE OBJECT AND LOAD THE DATA ########## # Tell which company and which period we want timeData = CTD.CTimeData(symbols[0],periods[0]) timeData.set_csv(storage_folder,file_name) # Load the data into the model if (preprocessing_data): timeData = tut.preprocess_data(timeData, sdate,edate) ## Get the valid trading days sorted days_keys, day_dict = timeData.get_indexDictByDay() Ndays = len(days_keys) timeData_daily = tut.get_daily_timedata(timeData, symbols[0]) H,L,O,C,V = np.array(timeData_daily.TD[["High","Low","Open","Close","Volume"]][:]).T """ Create the target for the classifier: """ Target = bMl.diff(C).flatten() # Continuous target Target[0] = NaN Target_bin = np.zeros(Target.shape) # Binarized Target_bin[np.where(Target >=0)] = 1 ## Create Pandas Data Frame for the information of the ML problem data_df = pd.DataFrame({'Time': days_keys, 'Target_clas': Target_bin, 'Target_reg': Target}) # 'Current_diff': Target} data_df.set_index('Time',inplace = True)