def get_tickers(self): logger.info('Ready to fetch tickers tasks....\n' + date_utils.current(Y_M_D_H_M_S)) exchanges = [ ccxt.bitfinex2({'userAgent': USER_AGENT}), ccxt.bittrex({'userAgent': USER_AGENT}), ccxt.poloniex({'userAgent': USER_AGENT}), ccxt.hitbtc2({'userAgent': USER_AGENT}), ccxt.cryptopia({'userAgent': USER_AGENT}), ccxt.livecoin({'userAgent': USER_AGENT}), ccxt.kucoin({'userAgent': USER_AGENT}), ccxt.okex({'userAgent': USER_AGENT}), ccxt.coinexchange({'userAgent': USER_AGENT}), ccxt.binance({'userAgent': USER_AGENT}), ccxt.bithumb({'userAgent': USER_AGENT}), ccxt.kraken({'userAgent': USER_AGENT}) ] tasks = [] for i in range(len(exchanges)): task = self.fetch_tickers_task(exchanges[i]) tasks.append(asyncio.ensure_future(task)) loop = asyncio.get_event_loop() loop.run_until_complete(asyncio.wait(tasks)) loop.close() self.spider_repository.close()
async def test_gdax(): exchange = ccxt.poloniex({ # # ↓ The "proxy" property setting below is for CORS-proxying only! # Do not use it if you don't know what a CORS proxy is. # https://github.com/ccxt/ccxt/wiki/Install#cors-access-control-allow-origin # You should only use the "proxy" setting if you're having a problem with Access-Control-Allow-Origin # In Python you rarely need to use it, if ever at all. # # 'proxy': 'https://cors-anywhere.herokuapp.com/', # # ↓ The "aiohttp_proxy" setting is for HTTP(S)-proxying (SOCKS, etc...) # It is a standard method of sending your requests through your proxies # This gets passed to the `asyncio` and `aiohttp` implementation directly # You can use this setting as documented here: # https://docs.aiohttp.org/en/stable/client_advanced.html#proxy-support # This is the setting you should be using with async version of ccxt in Python 3.5+ # 'aiohttp_proxy': 'http://proxy.com', # 'aiohttp_proxy': 'http://*****:*****@some.proxy.com', # 'aiohttp_proxy': 'http://10.10.1.10:3128', }) # your code goes here... ticker = await exchange.fetch_ticker('ETH/BTC') # don't forget to free the used resources, when you don't need them anymore await exchange.close() return ticker
okcoinusd = ccxt.okcoinusd({ 'enableRateLimit': True, 'rateLimit': 1000, "apiKey": "63f1b985-88fe-48c1-bb91-2f6f1f086ce5", "secret": "896AE910647BB0911BDF27949508E065", }) okex = ccxt.okex({ 'enableRateLimit': True, 'rateLimit': 1000, "apiKey": "7f10be5e-afd4-41a9-9c3c-fa9602996447", "secret": "71B22F85C687D223954FE4432B2A61B9", }) paymium = ccxt.paymium() poloniex = ccxt.poloniex({ 'enableRateLimit': True, 'rateLimit': 1000, "apiKey": "OQDZM5YM-OKX5QEUE-Z3IDJZG2-NEHLDQKS", "secret": "b36baf9613ab1fec64c549c2472e7b7c2b63b4f16667feb576a0601331fdd24bb1b22dda3c867e89b7beb5b2854cf66b6f2cd011d1adb8634ddeb3f7310337e1", }) qryptos = ccxt.qryptos({ 'enableRateLimit': True, 'rateLimit': 1000, }) quadrigacx = ccxt.quadrigacx({ 'enableRateLimit': True, 'rateLimit': 1000, }) quoinex = ccxt.quoinex({ 'enableRateLimit': True, 'rateLimit': 1000, }) southxchange = ccxt.southxchange({
import ccxt. async as ccxt from bot_crawler import BotCrawler from helper import NoInternetException if __name__ == '__main__': # initialize exchangers instances gateways = [ ccxt.cex(), ccxt.poloniex(), ccxt.binance(), ccxt.kraken(), ccxt.bitfinex2(), ccxt.okex() ] # define pairs for analysis pairs = ['XRP/BTC', 'XLM/BTC'] # run the bot crawler = BotCrawler(gateways, pairs, 10.3) try: crawler.run(5) except KeyboardInterrupt: print('stop.') except NoInternetException: print('Connect to the Internet to run the program!')
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)
log = logging.getLogger(__name__) log_format = '%(asctime)s %(levelname)-5.5s [%(name)s-%(funcName)s:%(lineno)d][%(threadName)s] %(message)s' log_filename = datetime.now().strftime('SpreadFinder.%Y%m%d-%H%M%S.log') logfile = logdir + log_filename logging.basicConfig(format='%(asctime)s %(levelname)s:%(message)s', filename=logfile, level=logging.INFO) starttime = time.time() hitbtc = ccxt.hitbtc({'apiKey': '', 'secret': ''}) kucoin = ccxt.kucoin({'apiKey': '', 'secret': ''}) binance = ccxt.binance({'apiKey': '', 'secret': ''}) poloniex = ccxt.poloniex({'apiKey': '', 'secret': ''}) okex = ccxt.okex() okex.name = 'okex' huobi = ccxt.huobi() symbol = 'NEO/ETH' exchanges = [hitbtc, binance, kucoin, okex] ioloop = asyncio.get_event_loop() bids_df = pd.DataFrame() asks_df = pd.DataFrame() bids_filename = savedir + datetime.now().strftime( 'SpreadFinder_BID.%Y%m%d-%H%M%S.csv') asks_filename = savedir + datetime.now().strftime(
# -*- coding: utf-8 -*- import asyncio import os import sys root = os.path.dirname( os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) sys.path.append(root + '/python') import ccxt. async as ccxt # noqa: E402 exchange = ccxt.poloniex({ 'enableRateLimit': True, # don't remove this line or they might ban you: https://github.com/ccxt/ccxt/wiki/Manual#rate-limit }) async def poll(): while True: yield await exchange.fetch_ticker('ETH/BTC') async def main(): async for ticker in poll(): print(ticker) asyncio.get_event_loop().run_until_complete(main())