예제 #1
0
 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_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)
예제 #3
0
 def read_security_data_for_list(self,
                                 codes,
                                 start,
                                 end,
                                 typ: SeType = SeType.Stock,
                                 freq: SeFreq = SeFreq.DAY):
     return DB_CLIENT.read_data_by_codes_and_date(typ.repo_name(freq),
                                                  codes, start, end)
예제 #4
0
 def read_qfq_security_data_for_single(self,
                                       code,
                                       start,
                                       end,
                                       typ: SeType = SeType.Stock,
                                       freq: SeFreq = SeFreq.DAY):
     codes = [code]
     data = DB_CLIENT.read_data_by_codes_and_date(
         typ.repo_name(freq) + REPO_QFQ_SUFFIX, codes, start, end)
     if data is None:
         return None
     return data[data.vol > 1]
예제 #5
0
 def compare_basic_data_of_repos(self, code, start, end, repo1, repo2, cols):
     df1 = DB_CLIENT.read_data_by_codes_and_date(repo1, [code], start, end)
     if df1 is None:
         print("no data from {} for {}".format(repo1, code))
         return None
     df1 = df1[cols]
     df2 = DB_CLIENT.read_data_by_codes_and_date(repo2, [code], start, end)
     if df2 is None:
         print("no data from {} for {}".format(repo2, code))
         return None
     df2 = df2[cols]
     res = self.do_compare(df1, df2, cols)
     if res is None:
         print("Something is wrong")
         return
     l, r, d = res
     if len(l) > 0:
         print("### {} Left only ###: \n".format(code), l)
     if len(r) > 0:
         print('### {} Right only ###: \n'.format(code), r)
     if len(d) > 0:
         print('### {} Not matched ###: \n'.format(code), d)
     if len(l) == 0 and len(r) == 0 and len(d) == 0:
         print("{} All matched".format(code))
예제 #6
0
 def read_security_data_for_single(self,
                                   code,
                                   start,
                                   end,
                                   typ: SeType = SeType.Stock,
                                   freq: SeFreq = SeFreq.DAY):
     codes = [code]
     data = DB_CLIENT.read_data_by_codes_and_date(typ.repo_name(freq),
                                                  codes, start, end)
     if data is None:
         return None
     if 'vol' in data.columns:
         return data[data.vol > 1]
     else:
         return data
예제 #7
0
 def read_fq_info(self, code, start, end):
     data = DB_CLIENT.read_data_by_codes_and_date(
         REPO_XDXR, [code], start, end=end, extra_filter={'category': 1})
     return data
예제 #8
0
 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
     )