predictlist = [] outputlist = [] money = 1000000#所持金 filepath = "./stockdata/%s" % f #株価データの読み込み _time,_open,_max,_min,_close,_volume,_keisu,_shihon = md.readfile(filepath) try: iday = _time.index(START_TEST_DAY) except: print 'can not find START_TEST_DAY' continue train, test = md.getTeacherDataMultiTech(f,START_TEST_DAY,NEXT_DAY,input_num,stride=1,u_vol=u_vol,u_ema=u_ema,u_rsi=u_rsi,u_macd=u_macd,u_stoch=u_stoch,u_wil=u_wil) if (train == -1) or (test == -1): print 'skip',f continue for row in test: inputlist = row[:-output_num-2] output = row[-output_num-2] inputlist = np.array([inputlist]).astype(np.float32) y = model.predict(xp.asarray(inputlist)) outputlist.append(output) predictlist.append(y.data[0,0])
for row in test: inputlist = row[:-output_num-2] output = row[-output_num-2] inputlist = np.array([inputlist]).astype(np.float32) y = model_3.predict(xp.asarray(inputlist)) if y.data.argmax() == output: rec_3.append(1) elif y.data.argmax() != output: rec_3.append(0) elif args.mode == 1: print 'regression' #model_1 train, test = md.getTeacherDataMultiTech(file,START_TEST_DAY,NEXT_DAY,args.input_num,stride=1,u_vol=True,u_ema=True) for row in test: inputlist = row[:-output_num-2] output = row[-output_num-2] inputlist = np.array([inputlist]).astype(np.float32) y = model_1.predict(xp.asarray(inputlist)) rec_1.append((output - y.data[0,0])*(output - y.data[0,0])) #model_2 train, test = md.getTeacherDataMultiTech(file,START_TEST_DAY,NEXT_DAY,args.input_num,stride=1,u_vol=True,u_rsi=True,u_stoch=True) for row in test: inputlist = row[:-output_num-2] output = row[-output_num-2] inputlist = np.array([inputlist]).astype(np.float32)