def fun(stocks): # print(os.getpid(), stocks) kline = 'index_min30' pixel = 56 n = 4 count = 2 interval = KlineInfo.get_interval(kline=kline) detal = KlineInfo.get_detal(kline=kline) table_name = 'A_MACD_left_right_' + kline + '_version6' print(table_name) for sc in stocks: end_time = dt.datetime(2018, 8, 10) start_time = dt.datetime(2016, 1, 1) data = KlineData.read_data(code=sc, start_date=Calendar.calc(start_time, -203)['date'], end_date=end_time, kline=kline, timemerge=True) if len(data) <= 200: continue data = CalMacd.cal_macd(data=data, interval=interval, detal=detal) data = data.dropna() d = data.date.iloc[-1] data = data[data.date <= dt.datetime(d.year, d.month, d.day, 10, 0)] print(sc) while end_time > start_time: # print(sc,dt.datetime.now()) data0 = data.tail(pixel) data0 = data0.reset_index(drop=True) profit = data0['profit'] profit_self = data0['profit_self'] date = data0['date'] if len(data0) < pixel: break date1 = date.iloc[pixel - 1] date2 = date.iloc[pixel - 2] data0 = CalMacd.data_normalization(data0, pixel=pixel + n * count) profit = profit.iloc[pixel - 1] profitself = profit_self.iloc[pixel - 1] profit_relative = 0 if 'min' in kline: if 'A' in table_name: if date1.hour != 10 and date1.minute != 0: data = data[data.date <= dt.datetime( date2.year, date2.month, date2.day, 10, 0)] break if abs(profit) > 0.11 or abs(profitself) > 0.097: data = data[data.date <= dt.datetime( date2.year, date2.month, date2.day, 10, 0)] continue else: if abs(profit) > 0.1 * interval: data = data[data.date <= dt.datetime( date2.year, date2.month, date2.day, 10, 0)] continue if 'A' in table_name: if abs(profitself) > 0.097: data = data[data.date <= dt.datetime( date2.year, date2.month, date2.day, 10, 0)] print(sc, str(profitself) + '_' + str(date)) continue try: visualization.draw_macd_line4(data=data0, profits=profit, date=date1, code=sc, table_name=table_name, pixel=pixel, n=n, profit_relative=profit_relative, count=count) pass except Exception as e: print(e) pass data = data[data.date <= dt.datetime(date2.year, date2.month, date2.day, 10, 0)] end_time = date2 # break return 1
def fun(stocks): # print(os.getpid(), stocks) kline = 'hk_kline_min30' pixel = 64 table_name = 'MACD_' + kline print(table_name) interval = KlineInfo.get_interval(kline=kline) # detal= KlineInfo.get_detal(kline=kline) # path = "//DESKTOP-4JKCMO0/zjf1/H_macd_kline_day" # path = "f:/zjf/image/macd_kline_day_test" # File.check_file(path=path) for sc in stocks: end_time = dt.datetime(2018, 6, 20) start_time = dt.datetime(2015, 1, 1) data = KlineData.read_data(code=sc, start_date=Calendar.calc(start_time, -203)['date'], end_date=end_time, kline=kline, timemerge=True) if len(data) <= 200: continue data = CalMacd.cal_macd(data, interval) data = data.sort_values(by=['date'], ascending=True) data = data.dropna() # data = data[0:len(data) - interval] print(sc) while end_time > dt.datetime(2016, 1, 5): # print(sc,dt.datetime.now()) data0 = data.tail(pixel) data0 = data0.reset_index(drop=True) profit = data0['profit'] date = data0['date'] data0 = CalMacd.data_normalization(data0, pixel=pixel) # print(sc, dt.datetime.now()) data0['date'] = date data0['profit'] = profit if len(data0) < pixel: break data0 = data0.reset_index(drop=True) profit = data0.profit.iloc[pixel - 1] date = data0.date.iloc[pixel - 1] if 'min' in kline: if abs(profit) > 0.11: data = data[data.date < dt.datetime( date.year, date.month, date.day)] end_time = date continue else: if abs(profit) > 0.1 * interval: data = data[data.date < dt.datetime( date.year, date.month, date.day)] end_time = date continue # print(sc, dt.datetime.now()) try: visualization.draw_macd_line(data=data0, profits=profit, date=date, code=sc, table_name=table_name, pixel=pixel) # pass except Exception as e: print(e) pass # data = data[0:len(data) - detal] data = data[ data.date < dt.datetime(date.year, date.month, date.day)] end_time = date return 1
def fun(data): stocks = data['stocks'] kline = data['kline'] pixel = 64 interval = KlineInfo.get_interval(kline=kline) detal = KlineInfo.get_detal(kline=kline) table_name = 'MACD_A_' + kline day_interval = KlineInfo.get_day_interval(kline) print(table_name) for sc in stocks: # end_time = dt.datetime(2018, 8, 1) # start_time = dt.datetime(2018, 7, 16) end_time = Calendar.today() start_time = Calendar.calc(end_time, -day_interval)['date'] data = KlineData.read_data(code=sc, start_date=Calendar.calc(start_time, -203)['date'], end_date=end_time, kline=kline, timemerge=True) if len(data) <= 200: continue data = CalMacd.cal_macd(data=data, interval=interval, detal=detal) data = data.dropna() # data = data[0:len(data) - interval] print(sc) while end_time > start_time: # print(sc,dt.datetime.now()) data0 = data.tail(pixel) data0 = data0.reset_index(drop=True) profit = data0['profit'] profit_self = data0['profit_self'] date = data0['date'] data0 = CalMacd.data_normalization(data0, pixel=pixel) # print(sc, dt.datetime.now()) data0['date'] = date data0['profit'] = profit data0['profit_self'] = profit_self # print(len(data0)) if len(data0) < pixel: break data0 = data0.reset_index(drop=True) profit = data0.profit.iloc[pixel - 1] profitself = data0.profit_self.iloc[pixel - 1] date = data0.date.iloc[pixel - 1] if 'min' in kline: if 'A' in table_name: if date.hour != 15: data = data[data.date < dt.datetime( date.year, date.month, date.day)] break if abs(profit) > 0.11 or abs(profitself) > 0.097: data = data[data.date < dt.datetime( date.year, date.month, date.day)] continue else: if abs(profit) > 0.1 * interval: data = data[data.date < dt.datetime( date.year, date.month, date.day)] continue if 'A' in table_name: if abs(profitself) > 0.097: data = data[data.date < dt.datetime( date.year, date.month, date.day)] print(sc, str(profitself) + '_' + str(date)) continue try: visualization.draw_macd_line(data=data0, profits=profit, date=date, code=sc, table_name=table_name, pixel=pixel) pass except Exception as e: print(e) pass data = data[ data.date < dt.datetime(date.year, date.month, date.day)] end_time = date return 1