def SvcDoRun(self): try: self.ReportServiceStatus(win32service.SERVICE_RUNNING) log.ok("Running %s Gemini version %s" % (config.MODE, pkg_resources.get_distribution("gemini").version,)) bot_thread = GeminiThread(Gemini(config)) bot_thread.start() win32event.WaitForSingleObject(self.hWaitStop, win32event.INFINITE) bot_thread.stop() except Exception as exc: log.error("SvcDoRun exception: %s" % (traceback.format_exc(),))
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_order_book(self): loop = asyncio.new_event_loop() api = CEX(os.path.join(config.APIKEY_DIR, config.CEX_KEYFILE), loop, [False]) time.sleep(2) self.assertTrue(api is not None) log.ok("Connected to CEX: " + str(api)) for idx in range(10): loop.run_until_complete(asyncio.sleep(1)) book = api.get_depth("XRP", "BTC") self.assertTrue(len(book['bids']) == 10) self.assertTrue(len(book['asks']) == 10) api.stop() log.ok("CEX 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'])))
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()
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()
def test_order_book(self): keyhandler = KeyHandler( os.path.join(config.APIKEY_DIR, "bitfinex_key.txt")) key = list(keyhandler.getKeys())[0] secret = keyhandler.getSecret(key) public_api = Client() self.assertTrue(public_api is not None) log.ok(public_api) trade_api = TradeClient(key, secret) self.assertTrue(trade_api is not None) log.ok(trade_api) book = public_api.order_book("xrpbtc", { 'limit_asks': 10, 'limit_bids': 10 }) self.assertTrue(len(book['bids']) == 10) self.assertTrue(len(book['asks']) == 10) log.ok(book)
def test_active_orders(self): api = CEX(os.path.join(config.APIKEY_DIR, config.CEX_KEYFILE), asyncio.new_event_loop(), [False]) ord = api.query_active_orders() log.ok(ord)
def test_balance(self): api = CEX(os.path.join(config.APIKEY_DIR, config.CEX_KEYFILE), asyncio.new_event_loop(), [False]) bal = api.get_all_balances() log.ok(bal)
def test_ticker(self): api = CEX(os.path.join(config.APIKEY_DIR, config.CEX_KEYFILE), asyncio.new_event_loop(), [False]) tickers = api.get_ticker() log.ok(tickers)
def test_ticker(self): api = self.bitfinex tickers = api.get_ticker() log.ok(tickers)
def __init__(self, *args, **kwargs): super(TestMethods, self).__init__(*args, **kwargs) self.bitfinex = DummyBitfinexExchange(self, []) self.assertTrue(self.bitfinex is not None) log.ok("Connected to Bitfinex: " + str(self.bitfinex))
def test_active_orders(self): api = self.bitfinex ord = api.query_active_orders() log.ok(ord)
def test_balance(self): api = self.bitfinex bal = api.get_all_balances() log.ok(bal)
def SvcStop(self): self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) win32event.SetEvent(self.hWaitStop) log.ok("Stopped %s Gemini version %s" % (config.MODE, pkg_resources.get_distribution("gemini").version,))
def run(): distrib = pkg_resources.get_distribution("gemini") log.ok("Running %s Gemini version %s" % (config.MODE, distrib.version if distrib else "UNVERSIONED")) bot = Gemini(config) bot.start()