def get_stock_data(self): df = pd.read_csv(self.csv_file_name) report_date = datetime.strptime(self.report_date, "%Y-%m-%d") report_date_n_days_ago = report_date - timedelta(days=self.trendfac) report_date = report_date.strftime("%Y-%m-%d") report_date_n_days_ago = report_date_n_days_ago.strftime("%Y-%m-%d") fulldata = pd.DataFrame() for stock in df['stock']: data = pseapi.get_stock_data(stock, report_date_n_days_ago, report_date) data = data.round(2) fulldata = fulldata.append(data, ignore_index=True) keys = pseapi.get_uniq_stock_keys(fulldata) filtered_df_score = self.get_whitesoldier_score( fulldata, keys, self.trendfac, self.resfac, self.supfac, self.pc_fac, self.volfac1, self.volfac2, self.volfac3, self.netffac, self.pc_crit, self.volfac_crit, self.res_crit, self.sup_crit) filtered_keys = pseapi.get_uniq_stock_keys(filtered_df_score) filtered_df = self.get_whitesoldier_stocks(fulldata, filtered_keys, self.trendfac) return filtered_df, filtered_df_score
def get_stock_data(self): df = pd.read_csv(self.csv_file_name) report_date = datetime.strptime(self.report_date, "%Y-%m-%d") report_date_n_days_ago = report_date - timedelta(days=self.trendfac) report_date = report_date.strftime("%Y-%m-%d") report_date_n_days_ago = report_date_n_days_ago.strftime("%Y-%m-%d") fulldata = pd.DataFrame() for stock in df['stock']: data = pseapi.get_stock_data(stock, report_date_n_days_ago, self.report_date) data = data.round(2) fulldata = fulldata.append(data, ignore_index=True) return fulldata