def do_update_xdxr(self, code): df = self.fetcher.fetch_xdxr(code) if len(df) > 0: DB_CLIENT.update_data_append_newer(df, REPO_XDXR)
def recreate_for_codes(self, codes, start_date, end): DB_CLIENT.remove_by_codes_from(self.repo_name_for_backtest(), codes) DB_CLIENT.remove_by_codes_from(self.repo_name_for_trade(), codes) start = date_time_utils.Date.from_str(start_date) end = date_time_utils.Date.from_str(end) executor.execute_tasks(codes, self.update_for_single_code, start.as_str(), end.as_str())
def drop_bar_repo(self, typ: SeType, freq: SeFreq): DB_CLIENT.drop(typ.repo_name(freq))
def read_for_trade(self): return DB_CLIENT.read_all_data( self.repo_name_for_trade() )
def read_all_codes(self): return DB_CLIENT.read_codes_from_db(self.repo_name_for_backtest())
def read_test_for_backtest(self, codes, start, end): return DB_CLIENT.read_data_by_codes_and_date( self.repo_name_for_backtest(), codes, start, end=end, extra_filter={'train': False} )
def read_for_backtest(self, codes, start, end): return DB_CLIENT.read_data_by_codes_and_date( self.repo_name_for_backtest(), codes, start, end=end )
def remove_all(self, codes): DB_CLIENT.remove_all_from(self.repo_name(), query={'code': { '$in': codes }})
def collect_baseline(self): for repo_name in self.repos_to_monitor: cnt = DB_CLIENT.count_of(repo_name) self.baseline[repo_name] = cnt
def read_all_codes(self): repo_name = self.repo_name() return DB_CLIENT.read_codes_from_db(repo_name)
def read_by_dates(self, codes, start='all', end=None): repo_name = self.repo_name() return DB_CLIENT.read_data_by_codes_and_date(repo_name, codes, start, end=end)
def save(self, data): DB_CLIENT.create_index(self.repo_name(), self.freq.keys_to_index()) if data is not None and len(data) > 0: repo_name = self.repo_name() DB_CLIENT.update_data_append_newer(data, repo_name)
def replace_by_dates(self, data, code, start, end): DB_CLIENT.delete_by_code_and_dates(self.repo_name(), code, start, end) if data is not None and len(data) > 0: DB_CLIENT.create_index(self.repo_name(), self.freq.keys_to_index()) repo_name = self.repo_name() DB_CLIENT.replace_data_by_date_range(data, repo_name, start, end)
def save(self, data): if data is not None and len(data) > 0: repo_name = self.repo_name() df = data.drop(columns=['open', 'low', 'high', 'amount', 'vol'], axis=1) DB_CLIENT.update_data_append_newer(df, repo_name)