def get_result_path(): cur_dir = get_root_path() dir_path = 'datas/' + MyCode.get() + '/' cur_dir += '/' cur_dir += dir_path agl.createDir(cur_dir) return cur_dir
def save_result(df): fname = get_result_mid_csv_path() cur_dir = os.path.dirname(fname) print(cur_dir) agl.createDir(cur_dir) assert(os.path.exists(cur_dir)) df.to_csv(fname)
def main(): code = stock.get_codes(stock.myenum.randn, 1)[0] points = [] df_result = pd.DataFrame([]) for i, df in enumerate(mydata(code)): df_result, sign = find_trade_pos(df, df_result, code, i) if sign: points.append(i) #print(points) fname = 'out/myadx_%s.csv' % (code) agl.createDir(os.path.dirname(os.path.abspath(fname))) df_result.to_csv(fname) #查看信号出现的概率 x = np.arange(len(mydata(code))) y = np.zeros(len(x)) y[points] = 1 pl.scatter(x, y) pl.show() #统计出现的概率 print(len(points) / len(x)) count = 0 for i in range(1, len(points)): if points[i] - points[i - 1] > 1: count += 1 print(count)
def genImgToFile(code): """产生图形到文件 """ datas = load_data() # indexs: list 数据偏移索引 df = pd.read_csv(get_result_csv_path(), index_col=0) indexs = df['datas_index'].values cur_dir = get_root_path() fname = cur_dir + '/img_labels/imgs' if not os.path.exists(fname): agl.createDir(fname) for i in indexs: i = int(i) fname1 =fname + '/%s_%d.png'%(code, i) print(fname1) pl.figure draw(datas[i]) pl.savefig(fname1) pl.close()