示例#1
0
 def test_order_book(self):
     api = Binance(os.path.join(config.APIKEY_DIR, config.BINANCE_KEYFILE),
                   asyncio.new_event_loop(), [False])
     time.sleep(5)
     self.assertTrue(api is not None)
     log.ok("Connected to Binance: " + str(api))
     for idx in range(10):
         book = api.get_depth("XRP", "BTC")
         self.assertTrue(len(book['bids']) == 10)
         self.assertTrue(len(book['asks']) == 10)
         log.info("Highest bid: %.4g, Lowest ask: %.4g" %
                  (book['bids'][0].p, book['asks'][0].p))
     log.ok("Binance order book processed succesfully: %d bids, %d asks" %
            (len(book['bids']), len(book['asks'])))
 def test_api(self):
     api = self.bitfinex
     time.sleep(5)
     for idx in range(10):
         book = api.get_depth("XRP", "BTC")
         self.assertTrue(len(book['bids']) > 10)
         self.assertTrue(len(book['asks']) > 10)
         book = api.get_depth("IOTA", "BTC")
         self.assertTrue(len(book['bids']) > 10)
         self.assertTrue(len(book['asks']) > 10)
         book = api.get_depth("DASH", "BTC")
         self.assertTrue(len(book['bids']) > 10)
         self.assertTrue(len(book['asks']) > 10)
         log.info("Highest bid: %.4g, Lowest ask: %.4g" %
                  (book['bids'][0].p, book['asks'][0].p))
     log.ok("Bitfinex order book processed succesfully: %d bids, %d asks" %
            (len(book['bids']), len(book['asks'])))
示例#3
0
 def test_order_book(self):
     api = Hitbtc(os.path.join(config.APIKEY_DIR, config.HITBTC_KEYFILE),
                  asyncio.new_event_loop(), [False])
     time.sleep(5)
     self.assertTrue(api is not None)
     log.ok(api)
     time.sleep(5)
     bal = api.get_all_balances()
     log.ok(bal)
     ord = api.query_active_orders()
     log.ok(ord)
     time.sleep(15)
     for idx in range(10):
         book = api.get_depth("XRP", "BTC")
         self.assertTrue(len(book['bids']) == 10)
         self.assertTrue(len(book['asks']) == 10)
         log.info("Highest bid: %.4g, Lowest ask: %.4g" %
                  (book['bids'][0].p, book['asks'][0].p))
     log.ok("Hitbtc order book processed succesfully: %d bids, %d asks" %
            (len(book['bids']), len(book['asks'])))
     api.stop()
示例#4
0
 def test_order_book(self):
     api = Bittrex(os.path.join(config.APIKEY_DIR, config.BITTREX_KEYFILE),
                   asyncio.new_event_loop(), [False])
     time.sleep(2)
     self.assertTrue(api is not None)
     log.ok(api)
     tickers = api.get_ticker()
     log.ok(tickers)
     bal = api.get_all_balances()
     log.ok(bal)
     ord = api.query_active_orders()
     log.ok(ord)
     time.sleep(2)
     for idx in range(10):
         book = api.get_depth("XRP", "BTC")
         log.info("Highest bid: %.4g, Lowest ask: %.4g" %
                  (book['bids'][0].p, book['asks'][0].p))
     self.assertTrue(len(book['bids']) >= 1)
     self.assertTrue(len(book['asks']) >= 1)
     log.ok("Bittrex order book processed succesfully")
     api.stop()