def label_data(): p = excel_reader.get_data(DATA_FROM, DATA_TO) np.random.seed(int(time.time())) #plt.plot(p) b, s = init_b_s_lognormal(p) index = comp_index_matrix(p) comp_loss(b, s, index) plt.plot(p / 4000 - 1) db, ds = grad_b_s(b, s, index) #plt.plot(ds * 10) #plt.show() lb, ls = gradient_descent(b, s, index, STEPS, LEARNING_RATE) plt.plot(lb) plt.show()
def label_data(): p = excel_reader.get_data(DATA_FROM, DATA_TO, 'D:\python\projdata\data\\1m.xlsx') log_price = np.log(p) #plt.plot(p) #plt.show() #plt.plot(log_price) minutes1d = range(DATA_LENGTH) minutes = np.array([minutes1d]).reshape(-1, 1) am, bm = linear_regression(minutes, log_price) a = am[0, 0] b = bm[0] minute_line = range(DATA_LENGTH) minute_line = np.array([minutes1d]).reshape(-1, 1) line = minute_line * a + b #plt.plot(line) #plt.show() lin_reg = log_price - line lin_reg = lin_reg[:, 0] plt.plot(lin_reg) #conv_array = np.ones((43200,), dtype=float)/43200. conv_array = np.ones((40960, ), dtype=float) / 40960. ma = np.convolve(lin_reg, conv_array, 'same') plt.plot(ma) plt.show() without_month_avg = lin_reg - ma plt.plot(without_month_avg) plt.show() convolutions_long(without_month_avg) conv_array_10k = np.ones((10240, ), dtype=float) / 10240. ma10k = np.convolve(without_month_avg, conv_array_10k, 'same') without_10d_avg = without_month_avg - ma10k plt.plot(without_10d_avg) plt.show() convolutions_short(without_10d_avg) #plt.plot(ma) #convolutions(lin_reg) #min - 7000 - 0.16 #min - 22000 - 0.16 #0 - 38000 #+ - 80000 #0 - 118000 #+ - 70000 #0 - 188000 #+ - 60000 #0 - 248000 #semi-period - 70000 period = 125000.0 amplitude = 0.18 zero = 238000.0
def generate(): p = excel_reader.get_data(DATA_FROM, DATA_TO, 'D:\python\projdata\data\\1m.xlsx') log_price = np.log(p) plt.plot(p) plt.show() plt.plot(log_price) plt.show() features, out = generate_features(log_price, DATA_FROM + 1921, DATA_TO - 60) features_mean = np.mean(features, axis=0) print('means:', features_mean) print(features) print(out) plt.plot(features) plt.show() plt.plot(out) plt.show()
def label_data(): p = excel_reader.get_data(DATA_FROM, DATA_TO, 'D:\python\projdata\data\\1m.xlsx') log_price = np.log(p) #plt.plot(p) topology = [14, 100, 100, 50, 20, 2] nn = NeuralNet(topology) #nn = nn_factory.read('net_11_7d') #index = comp_index_matrix(p) #b, s = comp_b_s(nn, p, index) #plt.plot(index[0,:]) #comp_loss(b, s, index) #plt.plot(p / 4000 - 1) #db, ds = grad_b_s(b, s, index) #plt.plot(ds * 10) #plt.show() lb, ls = gradient_descent(nn, p, log_price, STEPS, LEARNING_RATE) plt.plot(lb) plt.show() nn.save('net_final')
ma_320, ma_640, ma_1280, ma_2560, ma_5120, )) features = (features - log_price[i, 0]) * 400.0 return features DATA_FROM, DATA_TO = 0, 100000 TRAINING_LENGTH = DATA_TO - DATA_FROM nn = nn_factory.read('net_batch_32') #nn = nn_factory.read('D://python/TorgovecNets/net_w_c_loss_-40') #p = excel_reader.get_data(DATA_FROM, DATA_TO, 'D:\python\projdata\data\\btc30m.xlsx') p = excel_reader.get_data(DATA_FROM, DATA_TO, 'D:\python\projdata\data\\1m_short.xlsx') #index = comp_index_matrix(p) log_price = np.log(p) inf_prices = 181 print('TEST') wallet_btc = 1.0 wallet_usd = 0.0 sell_flag = True trades_btc = 0 trades_usd = 0 activations = np.zeros((TRAINING_LENGTH, 2)) hold_btc = 0 hold_usd = 0 sell_btc = np.zeros((TRAINING_LENGTH, 1)) buy_btc = np.zeros((TRAINING_LENGTH, 1)) #treshhold = random.random()