def test_create_pair_table(self): """ tests initialization of pair table """ pair_table = Models.Pair() self.assertEqual(pair_table.__tablename__, 'pair') self.assertEqual(pair_table.id, None) self.assertEqual(pair_table.bot_id, None) self.assertEqual(pair_table.symbol, None) self.assertEqual(pair_table.active, None) self.assertEqual(pair_table.current_order_id, None) self.assertEqual(pair_table.profit_loss, None)
def setUp(self): """Create a bot with 2 pairs and 1 open orders""" # define bot params self.bot_name = 'ada_test_bot' self.bot_id = 1 self.starting_balance = 2 self.current_balance = 3 self.profit_target = 4 self.test_run = True self.quote_asset = 'BTC' # define pair params self.pair_id_ada = 2 self.symbol_ada = 'ADABTC' self.profit_loss_ada = 5 self.pair_id_eth = 3 self.symbol_eth = 'ETHBTC' self.profit_loss_eth = 6 # define order params self.order_id = 1 self.order_symbol = self.symbol_eth self.entry_price = 2 self.original_quantity = 3 self.executed_quantity = 4 self.status = 'NEW' self.side = 'BUY' self.is_test = True self.session = get_session() self.assertEqual(len(self.session.query(Models.Bot).all()), 0) # Create bot bot = Models.Bot( id=self.bot_id, name=self.bot_name, quote_asset=self.quote_asset, starting_balance=self.starting_balance, current_balance=self.current_balance, profit_target=self.profit_target, test_run=self.test_run, ) # TODO Should check if pair contains the quote asset saved in bot. # Create ETHBTC pair ethpair = Models.Pair( id=self.pair_id_eth, bot_id=self.bot_id, symbol=self.symbol_eth, profit_loss=self.profit_loss_eth, ) # Create ADABTC pair adapair = Models.Pair( id=self.pair_id_ada, bot_id=self.bot_id, symbol=self.symbol_ada, profit_loss=self.profit_loss_ada, ) # Create ethereum buy order ethorder = Models.Order( id=self.order_id, bot_id=self.bot_id, symbol=self.order_symbol, entry_price=self.entry_price, original_quantity=self.original_quantity, executed_quantity=self.executed_quantity, status=self.status, side=self.side, is_test=self.is_test, ) self.session.add(bot) self.session.add(adapair) self.session.add(ethpair) self.session.add(ethorder) self.session.commit() self.bot = self.session.query(Models.Bot).filter_by(name=self.bot_name).first()