def check_kline(cls, strategy='kline_min5'): dt = Calendar.today() # pre_date = Calendar.calc(dt, -10) dt = Calendar.calc(dt, -1)['date'] # sql = analyzer('date = {}'.format(str(dt.year * 10000 + dt.month * 100 + dt.day))) # model_list['check_data'].remove(sql) # print(pre_date) sql = analyzer("date >= {} and date <= {}".format( str(20180111), str(dt.year * 10000 + dt.month * 100 + dt.day))) print("____________________" + strategy) print(sql) print('稍等几秒') cursor = model_list[strategy].query(sql) print(cursor) all_count = cursor.count() print(all_count) day_count = cls.number_of_branches(strategy) print(day_count) dic = { 'date': dt, 'strategy': strategy, 'all_count': all_count, 'day_count': day_count, 'result': all_count % day_count == 0 } print('insert') model_list['check_data'].insert(dic) if all_count % day_count == 0: return strategy + ' is true' print("____________________") else: return strategy + "有问题"
def self_check(cls, date=Calendar.today()): date = Calendar.calc(date=date, offset=-1)['date'] sql = analyzer('date = {}'.format(date.year * 10000 + date.month * 100 + date.day)) print(sql) result = list(model_list['check_data'].query(sql)) data = pd.DataFrame(result) all_count = list(data['all_count']) for i in range(0, len(all_count) - 1): if i != 4: if all_count[i] % all_count[i + 1] != 0: print(all_count[i], all_count[i + 1]) return False print(data) return True
with open(pf) as f: sl = f.read().split('\n') num = 30 aa = (lambda a: map(lambda b: a[b:b + num], range(0, len(a), num)) )(sl) for a in aa: for k in cc: s.append( dict(market=m, category=k, stock_code_list=a, start_date=sd, end_date=ed)) dql = analyzer('date >= {} and date <= {}'.format( Calendar.to(str, Calendar.calc(sd, -1)['date']), Calendar.to(str, Calendar.calc(ed, -1)['date']))) for m in mm: for c in cc: model_list['{}_kline_{}'.format(m, c)].remove(dql) # exit() print(s) st = datetime.now() freeze_support() pool = Pool(7) pool.map(gt_ex, s) pool.close() pool.join() # for i in s:
result = list(model_list['check_data'].query(sql)) data = pd.DataFrame(result) all_count = list(data['all_count']) for i in range(0, len(all_count) - 1): if i != 4: if all_count[i] % all_count[i + 1] != 0: print(all_count[i], all_count[i + 1]) return False print(data) return True dt = Calendar.today() # pre_date = Calendar.calc(dt, -10) dt = Calendar.calc(dt, -1)['date'] sql = analyzer('date = {}'.format( str(dt.year * 10000 + dt.month * 100 + dt.day))) model_list['check_data'].remove(sql) print(Check_Data.check_kline('kline_min5')) print(Check_Data.check_kline('kline_min15')) print(Check_Data.check_kline('kline_min30')) print(Check_Data.check_kline('kline_min60')) print(Check_Data.check_kline('kline_day')) print(Check_Data.check_kline('index_min5')) print(Check_Data.check_kline('index_min15')) print(Check_Data.check_kline('index_min30')) print(Check_Data.check_kline('index_min60')) print(Check_Data.check_kline('index_day')) # # a = Check_Data.self_check()
# -*- coding: utf-8 -*- from app.actions import f_zjh_ttm_a, f_zybk_ttm_a, f_zz_ttm_a from app.models import model_list, Calendar from app.query_str_analyzer import analyzer def change_date(t): print(t.year * 10000 + t.month * 100 + t.day) return t.year * 10000 + t.month * 100 + t.day if __name__ == '__main__': t = Calendar.today() print('t', t) t2 = Calendar.calc(t, -1)['date'] print('t2', t2) sd = change_date(t2) ed = change_date(t) dql = analyzer('date >= {} and date <= {}'.format(sd, ed)) for i in ['fund_zz_ttm', 'fund_zjh_ttm', 'fund_zybk_ttm']: model_list[i].remove(dql) f_zz_ttm_a(start_date=sd, end_date=ed) f_zjh_ttm_a(p_type='zjh', start_date=sd, end_date=ed) f_zybk_ttm_a(start_date=sd, end_date=ed)