def test_recenttrades(self): bts = self.bts m = Market(u'BEX:BBD', dpay_instance=bts) recenttrades = m.recent_trades(limit=10) recenttrades_raw = m.recent_trades(limit=10, raw_data=True) self.assertEqual(len(recenttrades), 10) self.assertEqual(len(recenttrades_raw), 10)
def test_sell(self): bts = self.bts bts.txbuffer.clear() m = Market(u'BEX:BBD', dpay_instance=bts) tx = m.sell(5, 0.1, account="test") self.assertEqual((tx["operations"][0][0]), "limit_order_create") op = tx["operations"][0][1] self.assertIn("test", op["owner"]) self.assertEqual(str(Amount('0.500 BBD', dpay_instance=bts)), op["min_to_receive"]) self.assertEqual(str(Amount('0.100 BEX', dpay_instance=bts)), op["amount_to_sell"]) p = Price(5, u"BBD:BEX") tx = m.sell(p, 0.1, account="test") op = tx["operations"][0][1] self.assertEqual(str(Amount('0.500 BBD', dpay_instance=bts)), op["min_to_receive"]) self.assertEqual(str(Amount('0.100 BEX', dpay_instance=bts)), op["amount_to_sell"]) p = Price(5, u"BBD:BEX", dpay_instance=bts) a = Amount(0.1, "BEX", dpay_instance=bts) tx = m.sell(p, a, account="test") op = tx["operations"][0][1] self.assertEqual(str(Amount('0.500 BBD', dpay_instance=bts)), op["min_to_receive"]) self.assertEqual(str(Amount('0.100 BEX', dpay_instance=bts)), op["amount_to_sell"])
def test_ticker(self): bts = self.bts m = Market(u'BEX:BBD', dpay_instance=bts) ticker = m.ticker() self.assertEqual(len(ticker), 6) self.assertEqual(ticker['dpay_volume']["symbol"], u'BEX') self.assertEqual(ticker['bbd_volume']["symbol"], u'BBD')
def test_orderbook(self): bts = self.bts m = Market(u'BEX:BBD', dpay_instance=bts) orderbook = m.orderbook(limit=10) self.assertEqual(len(orderbook['asks_date']), 10) self.assertEqual(len(orderbook['asks']), 10) self.assertEqual(len(orderbook['bids_date']), 10) self.assertEqual(len(orderbook['bids']), 10)
def test_cancel(self): bts = self.bts bts.txbuffer.clear() m = Market(u'BEX:BBD', dpay_instance=bts) tx = m.cancel(5, account="test") self.assertEqual((tx["operations"][0][0]), "limit_order_cancel") op = tx["operations"][0][1] self.assertIn("test", op["owner"])
def test_trades(self): bts = self.bts m = Market(u'BEX:BBD', dpay_instance=bts) trades = m.trades(limit=10) trades_raw = m.trades(limit=10, raw_data=True) trades_history = m.trade_history(limit=10) self.assertEqual(len(trades), 10) self.assertTrue(len(trades_history) > 0) self.assertEqual(len(trades_raw), 10)
def test_market(self, node_param): if node_param == "instance": set_shared_dpay_instance(self.bts) o = Market() self.assertIn(o.dpay.rpc.url, self.urls) with self.assertRaises(RPCConnection): Market(dpay_instance=DPay( node="https://abc.d", autoconnect=False, num_retries=1)) else: set_shared_dpay_instance( DPay(node="https://abc.d", autoconnect=False, num_retries=1)) stm = self.bts o = Market(dpay_instance=stm) self.assertIn(o.dpay.rpc.url, self.urls) with self.assertRaises(RPCConnection): Market()
def test_market_history(self): bts = self.bts m = Market(u'BEX:BBD', dpay_instance=bts) buckets = m.market_history_buckets() history = m.market_history(buckets[2]) self.assertTrue(len(history) > 0)
def test_volume(self): bts = self.bts m = Market(u'BEX:BBD', dpay_instance=bts) volume = m.volume24h() self.assertEqual(volume['BEX']["symbol"], u'BEX') self.assertEqual(volume['BBD']["symbol"], u'BBD')
def test_market(self): bts = self.bts m1 = Market(u'BEX', u'BBD', dpay_instance=bts) self.assertEqual(m1.get_string(), u'BBD:BEX') m2 = Market(dpay_instance=bts) self.assertEqual(m2.get_string(), u'BBD:BEX') m3 = Market(u'BEX:BBD', dpay_instance=bts) self.assertEqual(m3.get_string(), u'BEX:BBD') self.assertTrue(m1 == m2) base = Asset("BBD", dpay_instance=bts) quote = Asset("BEX", dpay_instance=bts) m = Market(base, quote, dpay_instance=bts) self.assertEqual(m.get_string(), u'BEX:BBD')
def test_dpay_usb_impied(self): bts = self.bts m = Market(u'BEX:BBD', dpay_instance=bts) dpay_usd = m.dpay_usd_implied() self.assertGreater(dpay_usd, 0)
def test_accountopenorders(self): bts = self.bts m = Market(u'BEX:BBD', dpay_instance=bts) openOrder = m.accountopenorders("test") self.assertTrue(isinstance(openOrder, list))