def __init__(self, ticker_len, start_amount, histdepth, base_sym): self.trade_hist = {} self.polo = Poloniex() self.hd = histdepth self.ticker_len = ticker_len self.end_ts = datetime.now() + timedelta(seconds=(ticker_len * 24)) self.start_amount = start_amount self.hs = HistWorker() self.hs.combine_live_usd_frames() print(self.hs.currentHists.keys()) self.end_idx = len(self.hs.hist_shaped[0]) - 1 self.but_target = .1 self.inputs = self.hs.hist_shaped.shape[0] * ( self.hs.hist_shaped[0].shape[1]) self.outputs = self.hs.hist_shaped.shape[0] self.folio = CryptoFolio(start_amount, list(self.hs.currentHists.keys()), base_sym) self.base_sym = base_sym sign = 1 for ix in range(1, self.outputs + 1): sign = sign * -1 self.out_shapes.append((0.0 - (sign * .005 * ix), 0.0, -1.0)) for ix2 in range(1, (self.inputs // self.outputs) + 1): self.in_shapes.append( (0.0 + (sign * .01 * ix2), 0.0 - (sign * .01 * ix2), 0.0)) self.subStrate = Substrate(self.in_shapes, self.out_shapes) self.load_net() print(self.hs.coin_dict) self.poloTrader()
def __init__(self, ticker_len, start_amount, histdepth): self.in_shapes = [] self.out_shapes = [] self.trade_hist = {} self.polo = Poloniex() self.hist_depth = histdepth self.ticker_len = ticker_len self.end_ts = datetime.now()+timedelta(seconds=(ticker_len*24)) self.start_amount = start_amount self.hs = HistWorker() self.refresh_data() self.inputs = self.hs.hist_shaped.shape[0]*(self.hs.hist_shaped[0].shape[1]) self.outputs = self.hs.hist_shaped.shape[0] #self.make_shapes() self.folio = CryptoFolio(start_amount, list(self.hs.currentHists.keys())) self.leaf_names = [] for ix in range(1,self.inputs+1): sign = sign *-1 self.in_shapes.append((0.0-(sign*.005*ix), -1.0, 0.0+(sign*.005*ix))) self.out_shapes.append((0.0, 1.0, 0.0)) self.subStrate = Substrate(self.in_shapes, self.out_shapes) for l in range(len(self.in_shapes[0])): self.leaf_names.append('leaf_one_'+str(l)) self.leaf_names.append('leaf_two_'+str(l)) self.load_net() print(self.hs.coin_dict) self.poloTrader()
def __init__(self, hist_depth): self.hs = HistWorker() self.hs.combine_binance_frames() self.hd = hist_depth print(self.hs.currentHists.keys()) self.end_idx = len(self.hs.hist_shaped[0]) self.but_target = .1 self.inputs = self.hs.hist_shaped.shape[0] * ( self.hs.hist_shaped[0].shape[1]) self.outputs = self.hs.hist_shaped.shape[0] sign = 1 for ix in range(1, self.outputs + 1): sign = sign * -1 self.out_shapes.append((0.0 - (sign * .005 * ix), -1.0, -1.0)) for ix2 in range(1, (self.inputs // self.outputs) + 1): self.in_shapes.append( (0.0 + (sign * .01 * ix2), 0.0 - (sign * .01 * ix2), 1.0)) self.subStrate = Substrate(self.in_shapes, self.out_shapes) self.epoch_len = 144 #self.node_names = ['x1', 'y1', 'z1', 'x2', 'y2', 'z2', 'weight'] self.leaf_names = [] #num_leafs = 2**(len(self.node_names)-1)//2 for l in range(len(self.in_shapes[0])): self.leaf_names.append('leaf_one_' + str(l)) self.leaf_names.append('leaf_two_' + str(l))
def __init__(self, hist_depth): self.hs = HistWorker() self.hd = hist_depth self.end_idx = len(self.hs.currentHists["XCP"]) self.but_target = .1 self.inputs = self.hs.hist_shaped.shape[0]*(self.hs.hist_shaped[0].shape[1]-1) self.outputs = self.hs.hist_shaped.shape[0] sign = 1 for ix in range(1,self.outputs+1): sign = sign *-1 self.out_shapes.append((sign/ix, .0, 1.0*sign)) for ix2 in range(1,len(self.hs.hist_shaped[0][0])): self.in_shapes.append((-sign/ix, (sign/ix2), 1.0*sign)) self.subStrate = Substrate(self.in_shapes, self.out_shapes) self.epoch_len = 360
def __init__(self, hist_depth): self.hs = HistWorker() self.hd = hist_depth self.end_idx = len(self.hs.currentHists["DASH"]) self.but_target = .1 self.inputs = self.hs.hist_shaped.shape[0]*(self.hs.hist_shaped[0].shape[1]-1) * self.hd self.outputs = self.hs.hist_shaped.shape[0] sign = 1 for ix in range(self.outputs): sign = sign *-1 self.out_shapes.append((sign*ix, 1)) for ix2 in range(len(self.hs.hist_shaped[0][0])-1): for ix3 in range(self.hd): self.in_shapes.append((sign*ix, ((1+ix2)*.1))) self.subStrate = Substrate(self.in_shapes, self.out_shapes) self.epoch_len = 55
def __init__(self, hist_depth): self.hs = HistWorker() self.hs.combine_binance_frames_vol_sorted(3) self.hd = hist_depth print(self.hs.currentHists.keys()) self.end_idx = len(self.hs.hist_shaped[0]) self.but_target = .1 self.inputs = self.hs.hist_shaped.shape[0] * ( self.hs.hist_shaped[0].shape[1]) self.outputs = self.hs.hist_shaped.shape[0] self.leaf_names = [] #num_leafs = 2**(len(self.node_names)-1)//2 #self.tree = nDimensionGoldenTree((0.0, 0.0, 0.0), 1.0, 1) #self.tree.divide_childrens() self.set_substrate() self.set_leaf_names() self.epoch_len = hist_depth
def __init__(self, hist_depth): self.hs = HistWorker() self.hs.combine_binance_frames_vol_sorted(21) self.hd = hist_depth print(self.hs.currentHists.keys()) self.end_idx = len(self.hs.hist_shaped[0]) self.but_target = .1 self.inputs = self.hs.hist_shaped.shape[0]*(self.hs.hist_shaped[0].shape[1]) self.outputs = len(self.hs.coin_dict) print(self.inputs, self.outputs) self.epoch_len = 144 #self.node_names = ['x1', 'y1', 'z1', 'x2', 'y2', 'z2', 'weight'] self.leaf_names = [] #num_leafs = 2**(len(self.node_names)-1)//2 self.tree = nDimensionTree((0.0, 0.0, 0.0), 1.0, 1) self.tree.divide_childrens() self.set_substrate() self.set_leaf_names()
def refresh(self): self.in_shapes = [] self.out_shapes = [(0.0, -1.0, -1.0)] self.hs = HistWorker() self.hs.get_binance_train() print(self.hs.currentHists.keys()) self.end_idx = len(self.hs.hist_shaped[0]) self.but_target = .1 print(self.hs.hist_shaped.shape) self.num_syms = self.hs.hist_shaped.shape[0] self.inputs = self.hs.hist_shaped[0].shape[1] + 1 self.outputs = 1 sign = 1 for ix2 in range(1,self.inputs+1): sign *= -1 self.in_shapes.append((0.0+(sign*.01*ix2), 0.0-(sign*.01*ix2), 0.0)) self.substrate = Substrate(self.in_shapes, self.out_shapes) self.set_leaf_names()
def refresh(self): self.in_shapes = [] self.out_shapes = [] self.hs = HistWorker() self.hs.get_kraken_train() print(self.hs.currentHists.keys()) self.end_idx = len(self.hs.hist_shaped[0]) self.but_target = .1 self.inputs = self.hs.hist_shaped.shape[0] * ( self.hs.hist_shaped[0].shape[1]) self.outputs = self.hs.hist_shaped.shape[0] sign = 1 for ix in range(1, self.outputs + 1): sign = sign * -1 self.out_shapes.append((0.0 - (sign * .005 * ix), 0.0, -1.0)) for ix2 in range(1, (self.inputs // self.outputs) + 1): self.in_shapes.append( (0.0 + (sign * .01 * ix2), 0.0 - (sign * .01 * ix2), 0.0)) self.subStrate = Substrate(self.in_shapes, self.out_shapes)
def refresh(self, reload_data=False): print("refreshing") self.in_shapes = [] self.out_shapes = [] self.hs = HistWorker() if(reload_data != False): self.hs.pull_robinhood_train_data() self.hs.get_robinhood_train() print(self.hs.currentHists.keys()) self.end_idx = len(self.hs.hist_shaped[0]) self.but_target = 1.0 self.inputs = self.hs.hist_shaped.shape[0]*(self.hs.hist_shaped[0].shape[1]) self.outputs = self.hs.hist_shaped.shape[0] sign = 1 for ix in range(1,self.outputs+1): sign = sign *-1 self.out_shapes.append((0.0-(sign*.005*ix), 0.0, -1.0)) for ix2 in range(1,(self.inputs//self.outputs)+1): self.in_shapes.append((0.0+(sign*.01*ix2), 0.0-(sign*.01*ix2), 0.0)) self.subStrate = Substrate(self.in_shapes, self.out_shapes)
def refresh(self): self.in_shapes = [] self.out_shapes = [(0.0, -1.0, -1.0)] self.hs = HistWorker() self.hs.get_kraken_train() print(self.hs.currentHists.keys()) self.end_idx = len(self.hs.hist_shaped[0]) self.but_target = .1 print(self.hs.hist_shaped.shape) self.num_syms = self.hs.hist_shaped.shape[0] # add one to number of symbols to account for current position size # input we pass for context self.inputs = self.hs.hist_shaped[0].shape[1] + 1 self.outputs = 1 sign = 1 for ix2 in range(1,self.inputs+1): sign *= -1 self.in_shapes.append((0.0+(sign*.01*ix2), 0.0-(sign*.01*ix2), 0.0)) self.substrate = Substrate(self.in_shapes, self.out_shapes) self.set_leaf_names()
def __init__(self, ticker_len, target_percent, hd, base_sym="BTC"): self.base_sym = base_sym self.load_polo_client() self.hd = hd self.target_percent = target_percent self.ticker_len = ticker_len self.end_ts = datetime.now() + timedelta(seconds=(ticker_len * 55)) self.hs = HistWorker() self.refresh_data() self.tickers = self.polo.returnTicker() self.refresh_balances() self.sellCoins() self.set_target() self.inputs = self.hs.hist_shaped.shape[0] * ( self.hs.hist_shaped[0].shape[1]) self.outputs = self.hs.hist_shaped.shape[0] self.end_idx = len(self.hs.hist_shaped[0]) - 1 self.make_shapes() self.load_net() self.poloTrader()
def __init__(self, ticker_len, target_percent, hd): self.polo = Poloniex(key, secret) self.hist_depth = hd self.target_percent = target_percent self.ticker_len = ticker_len self.end_ts = datetime.now()+timedelta(seconds=(ticker_len*55)) self.hs = HistWorker() self.refresh_data() self.tickers = self.polo.returnTicker() self.bal = self.polo.returnBalances() self.sellCoins() self.set_target() self.inputs = self.hs.hist_shaped.shape[0]*(self.hs.hist_shaped[0].shape[1]) self.outputs = self.hs.hist_shaped.shape[0] self.make_shapes() self.leaf_names = [] for l in range(len(self.in_shapes[0])): self.leaf_names.append('leaf_one_'+str(l)) self.leaf_names.append('leaf_two_'+str(l)) #self.load_net() self.poloTrader()
def __init__(self, hist_depth): self.hs = HistWorker() self.hs.combine_polo_usd_frames() self.hd = hist_depth print(self.hs.currentHists.keys()) self.end_idx = len(self.hs.hist_shaped[0]) self.but_target = .1 self.inputs = self.hs.hist_shaped.shape[0] * ( self.hs.hist_shaped[0].shape[1]) self.outputs = len(self.hs.coin_dict) print(self.inputs, self.outputs) self.epoch_len = 144 #self.node_names = ['x1', 'y1', 'z1', 'x2', 'y2', 'z2', 'weight'] self.leaf_names = [] #num_leafs = 2**(len(self.node_names)-1)//2 self.initial_depth_tree = nDimensionTree([0.0, 0.0, 0.0], 1.0, 0) self.divide_to_depth(self.initial_depth_tree, self.initial_depth_tree.lvl, self.params["initial_depth"]) self.set_substrate() self.set_leaf_names()
def __init__(self, ticker_len, start_amount, histdepth): self.trade_hist = {} self.polo = Poloniex() self.hist_depth = histdepth self.ticker_len = ticker_len self.end_ts = datetime.now()+timedelta(seconds=(ticker_len*89)) self.start_amount = start_amount self.hs = HistWorker() self.refresh_data() self.folio = CryptoFolio(start_amount, list(self.hs.currentHists.keys())) self.inputs = self.hs.hist_shaped.shape[0]*(self.hs.hist_shaped[0].shape[1]) self.outputs = self.hs.hist_shaped.shape[0] self.leaf_names = [] #num_leafs = 2**(len(self.node_names)-1)//2 self.tree = nDimensionGoldenTree((0.0, 0.0, 0.0), 1.0, 1) self.tree.divide_childrens() self.set_substrate() self.set_leaf_names() self.epoch_len = histdepth self.load_net() print(self.hs.coin_dict) self.db.purge() self.poloTrader()
def __init__(self): self.hs = HistWorker() self.end_idx = len(self.hs.currentHists["DASH"]) self.but_target = .1 self.inputs = self.hs.hist_shaped.shape[0]*self.hs.hist_shaped[0].shape[1] self.outputs = self.hs.hist_shaped.shape[0] # times by three for buy | sell | hodl(pass)
from hist_service import HistWorker hs = HistWorker() hs.pull_polo() #hs.write_binance_training_files()