def test_monitor_full_book_stream(self): exchanges = [ccxt.binance(), ccxt.gemini(), ccxt.bitmex()] loop = asyncio.get_event_loop() t1 = ManageThread(SYMBOL, 'fetchOrderBook', exchanges, 5000, loop=loop) t1.daemon = True t1.start() def pass_test(m): if 'bids' in m: return True return False ub = UnifiedOrderBook(SYMBOL, exchanges[0]) ub.monitor_full_book_stream() t1.join() self.assertEqual(2 + 2, 4)
def test_manage_ticker(self): exchanges = [ccxt.binance(), ccxt.gemini(), ccxt.bitmex()] loop = asyncio.get_event_loop() uam = UnifiedAPIManager(SYMBOL, 'fetchTicker', exchanges, 5000) loop.run_until_complete(uam.filter_exchanges()) def pass_test(m): if 'high' in m: return True return False t2 = ConsumeThread(SYMBOL.replace('/', '_') + '_ticker', pass_test) t2.start() loop.run_until_complete( uam.manage(stop_at=datetime.datetime.utcnow() + datetime.timedelta(seconds=2))) t2.join() self.assertEqual(2 + 2, 4)
'enableRateLimit': True, 'rateLimit': 1000, }) gateio = ccxt.gateio({ 'enableRateLimit': True, 'rateLimit': 1000, }) gdax = ccxt.gdax({ 'enableRateLimit': True, 'rateLimit': 1000, 'apiKey': "GnFmvkkPinzOXSWM", 'secret': "", 'password': '******', }) gemini = ccxt.gemini({ 'enableRateLimit': True, 'rateLimit': 1000, }) getbtc = ccxt.getbtc({ 'enableRateLimit': True, 'rateLimit': 1000, }) hitbtc = ccxt.hitbtc({ 'enableRateLimit': True, 'rateLimit': 1000, "apiKey": "00c576eec474fab35709aeb546dcf577", "secret": "568e6d454ea9897b183c4ba2ff4bf598", }) hitbtc2 = ccxt.hitbtc2({ 'enableRateLimit': True, 'rateLimit': 1000, "apiKey": "00c576eec474fab35709aeb546dcf577",
async def print_complex_arbs_task(self): while True: self.print_arbs(self.complex_arbs()) await asyncio.sleep(1) async def populate_task(self, exchange): while True: try: await self.exchange_rates.populate( exchange, blacklisted=self.blacklisted) except (TimeoutError, RequestTimeout, ExchangeError) as e: logging.error(e) await asyncio.sleep(5) if __name__ == "__main__": EXCHANGES = { ccxt.bittrex({'enableRateLimit': True}), ccxt.gdax({'enableRateLimit': True}), ccxt.kraken({'enableRateLimit': True}), ccxt.poloniex({'enableRateLimit': True}), FastCryptopia({'enableRateLimit': True}), ccxt.gemini({'enableRateLimit': True}), ccxt.kucoin({'enableRateLimit': True}), ccxt.binance({'enableRateLimit': True}) } logging.basicConfig(level=logging.INFO) start_with = ("ETH", 10) arbs = Sharpshooter(EXCHANGES, start_with).run_once() Sharpshooter.print_arbs(arbs)
import unittest import time import math import networkx as nx import matplotlib.pyplot as plt import numpy as np import ccxt. async as ccxt from thorn.models import ArbitrageGraph from thorn.models import bellman_ford, find_opportunities pairs = [{ 'exchange': ccxt.gemini(), 'pair': 'ETH/BTC', 'price': 0.0873 }, { 'exchange': ccxt.gemini(), 'pair': 'BTC/USD', 'price': 10420.000 }, { 'exchange': ccxt.gemini(), 'pair': 'ETH/USD', 'price': 924.99, 'ts': 1518996767361 }] pairs2 = [ { 'exchange': ccxt.gemini(), 'pair': 'ETH/BTC', 'price': .01
import asyncio import ccxt. async as ccxt SYMBOL = 'ETH/BTC' from thorn.api import UnifiedAPIManager from thorn.api import config from thorn.utils import read_private_api_info keys = read_private_api_info(config.KEY_CONFIG['api_key_location'], config.KEY_CONFIG['api_key_name']) exchange_name = 'gemini' exchange = ccxt.gemini({ 'apiKey': keys[exchange_name]['api_key'], 'secret': keys[exchange_name]['secret'] }) asyncio.get_event_loop().run_until_complete(exchange.load_markets()) # try: # exchange.urls['api'] = exchange.urls['test'] # print('API has sandbox') # except KeyError: # print('Exchange does not contain sandbox url') # sys.exit() class ManageThread(threading.Thread): def __init__(self, symbol, function, exchanges, delay, loop=None): uam = UnifiedAPIManager(symbol, function, exchanges, delay, loop=loop)