def test_load_from_db_and_save_to_file(self): end_time = self.calc_end_time() t = end_time board = PriceBoardDB.load_from_db(t) board.save("/tmp/board")
def _load_from_db_one_rec_with_time(self, time): board = PriceBoardDB.load_from_db(time) sell_board = board.sell_order max_x, max_y = sell_board.shape print(max_x, max_y) for x in range(1, max_x): line = False for y in range(1, max_y): if sell_board[x, y]: line = True break; if line is False: print("error", x, y) self.assertFalse("empty line in order book") break; for x in range(0, max_x): print(time - x, ' ', end='') for y in range(0, max_y): if sell_board[x, y]: print('X', end='') else: print('.', end='') print('', end='\n') print(board) return board
def test_load_from_db_one(self): end_time = self.calc_end_time() t = end_time writer = PriceBoardDB.get_tf_writer('/tmp/onedata.tfrecords') board = PriceBoardDB.load_from_db(t) board.save_tf_to_writer(writer) writer.close()
def test_load_from_db_normalize3(self): end_time = self.calc_end_time() t = end_time while True: board = PriceBoardDB.load_from_db(t) print("time->", t) if not board: break t = t+1
def test_load_from_db_normalize(self): end_time = self.calc_end_time() print("time->", end_time) t = end_time board = PriceBoardDB.load_from_db(t) plt.imshow(board.buy_order, vmin=0, vmax=200) plt.figure() plt.imshow(board.sell_order, vmin=0, vmax=200) plt.figure() plt.imshow(board.buy_trade, vmin=0, vmax=200) plt.figure() plt.imshow(board.sell_trade, vmin=0, vmax=200) plt.figure() plt.show()
def test_load_from_db(self): end_time = self.calc_end_time() t = end_time t = 1553302179 # ba = 1 #t = 1553276602 # ba = 2 #t = 1553301395 # ba = 3 # t = 1552695458 board = PriceBoardDB.load_from_db(t) fig = plt.figure() fig.text(0.1, 0.1, board.best_action) array = board.buy_order sub = fig.add_subplot(2, 2, 1) sub.matshow(array, vmin=0, vmax=255) array = board.sell_order sub = fig.add_subplot(2, 2, 2) sub.matshow(array, vmin=0, vmax=255) array = board.buy_trade sub = fig.add_subplot(2, 2, 3) sub.matshow(array, vmin=0, vmax=100) array = board.sell_trade sub = fig.add_subplot(2, 2, 4) sub.matshow(array, vmin=0, vmax=100) fig.show() print(board.best_action)
def test_load_from_db_normalize2(self): end_time = self.calc_end_time() t = end_time board = PriceBoardDB.load_from_db(t)