def re_calc_qfq_and_overwrite(code, start, end): start = MIN_START_DATE end = date_time_utils.Date().as_str() stock_data = SECURITY_DATA_READ_SERVICE.read_security_data_for_single( code, start, end) qfq_data = stock_to_qfq(stock_data) DB_CLIENT.replace_data_by_codes(qfq_data, DAY_QFQ_REPO)
def update_for_single_code(self, code, start, end): data = SECURITY_DATA_READ_SERVICE.read_qfq_security_data_for_single(code, start, end) if data is not None and len(data) > 1: data = dummy_appender.append_dummy_rows(data, 1) data = self.indicator_func(data) if data is None or data.shape[0] < 1: pass else: df_without_dummy = dummy_appender.exclude_dummy_rows(data) DB_CLIENT.update_data_append_newer(df_without_dummy, self.repo_name_for_backtest()) df_with_dummy_for_trade = data.tail(self.dummy_rows) min_start_date = date_time_utils.Date.from_str(end). \ get_before(days=MasterIndicatorDB.MAX_CALENDAR_DAYS_TO_KEEP) df_with_dummy_for_trade = df_with_dummy_for_trade.reset_index(level=0) df_with_dummy_for_trade = df_with_dummy_for_trade.loc[df_with_dummy_for_trade.date > min_start_date.as_str()] DB_CLIENT.replace_data_by_codes(df_with_dummy_for_trade, self.repo_name_for_trade())
def update_code_list(self): data = self.fetcher.fetch_security_list() DB_CLIENT.replace_data_by_codes(data, REPO_SECURITY_LIST)