Beispiel #1
0
    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 poll(tickers):
    i = 0
    kraken = ccxt.kraken()
    while True:
        symbol = tickers[i % len(tickers)]
        yield (symbol, await kraken.fetch_ticker(symbol))
        i += 1
        await asyncio.sleep(kraken.rateLimit / 1000)
Beispiel #3
0
async def poll(tickers):
    i = 0
    kraken = ccxt.kraken()
    while True:
        symbol = tickers[i % len(tickers)]
        yield (symbol, await kraken.fetch_ticker(symbol))
        i += 1
        await asyncio.sleep(kraken.rateLimit / 1000)
Beispiel #4
0
    def background_job(self):

        self.ob_constant = OD_TICK_TIMER
        self.bl_constant = BALANCE_TICK_TIMER
        self.trade_constant = TRADE_TICK_TIMER

        self.stop_tick_time = datetime.datetime.now() + datetime.timedelta(
            seconds=TICK_TIMER)
        self.orderbook_tick_time = datetime.datetime.now(
        ) + datetime.timedelta(seconds=self.ob_constant)
        self.balance_tick_time = datetime.datetime.now() + datetime.timedelta(
            seconds=self.bl_constant)
        self.trade_tick_time = datetime.datetime.now() + datetime.timedelta(
            seconds=self.trade_constant)
        self.info_tick_time = datetime.datetime.now() + datetime.timedelta(
            seconds=INFO_TIMER)

        self.ccxt_in_queue = self.config['in_queue']
        self.ccxt_out_queue = self.config['out_queue']

        auth = {}
        if 'auth' in self.config.keys():
            auth = self.config['auth']
            self.is_auth = True
            self.name = '[ccxt %s %s*]' % (self.exhange, auth['apiKey'][:4])

        loop = asyncio.new_event_loop()
        asyncio.set_event_loop(loop)

        if self.exhange == 'hitbtc':
            loop.create_task(self.run_loop(ccxt.hitbtc(auth)))
        elif self.exhange == 'coinmarketcap':
            loop.create_task(self.run_loop(ccxt.coinmarketcap()))
        elif self.exhange == 'binance':
            loop.create_task(self.run_loop(ccxt.binance(auth)))
        elif self.exhange == 'bitmex':
            loop.create_task(self.run_loop(ccxt.bitmex(auth)))
        elif self.exhange == 'huobipro':
            loop.create_task(self.run_loop(ccxt.huobipro()))
        elif self.exhange == 'liqui':
            loop.create_task(self.run_loop(ccxt.liqui(auth)))
        elif self.exhange == 'bitfinex2':
            loop.create_task(self.run_loop(ccxt.bitfinex2(auth)))
        elif self.exhange == 'bitfinex':
            loop.create_task(self.run_loop(ccxt.bitfinex(auth)))
        elif self.exhange == 'okex':
            loop.create_task(self.run_loop(ccxt.okex(auth)))
        elif self.exhange == 'kucoin':
            loop.create_task(self.run_loop(ccxt.kucoin(auth)))
        elif self.exhange == 'bittrex':
            loop.create_task(self.run_loop(ccxt.bittrex(auth)))
        elif self.exhange == 'qryptos':
            loop.create_task(self.run_loop(ccxt.qryptos(auth)))
        elif self.exhange == 'kraken':
            loop.create_task(self.run_loop(ccxt.kraken(auth)))

        loop.run_forever()
Beispiel #5
0
def main():

    exchanges = [
        ccxt.gdax(),
        ccxt.kraken(),
        ccxt.hitbtc2(),
        ccxt.huobipro(),
        ccxt.bitstamp()
    ]
    symbols = ['BTC/USD', 'BTC/USD', 'BTC/USDT', 'BTC/USDT', 'BTC/USD']
    tasks = []
    for i in range(len(exchanges)):
        task = get_exchange_tickerDepth(exchanges[i], symbols[i])
        tasks.append(asyncio.ensure_future(task))

    loop = asyncio.get_event_loop()

    loop.run_until_complete(asyncio.wait(tasks))
Beispiel #6
0
    "secret": "05c371ab-0d9d012f-39d3f12d-a6c68",
})
independentreserve = ccxt.independentreserve({
    'enableRateLimit': True,
    'rateLimit': 1000,
})
itbit = ccxt.itbit({
    'enableRateLimit': True,
    'rateLimit': 1000,
})
jubi = ccxt.jubi({
    'enableRateLimit': True,
    'rateLimit': 1000,
})
kraken = ccxt.kraken({
    'enableRateLimit': True,
    'rateLimit': 1000,
})
kucoin = ccxt.kucoin({
    'enableRateLimit': True,
    'rateLimit': 1000,
    "apiKey": "5a92a5e003d644701f1a9c56",
    "secret": "400e8874-e3cf-43f1-8765-63e4b7f535a5",
})
kuna = ccxt.kuna({
    'enableRateLimit': True,
    'rateLimit': 1000,
})
lakebtc = ccxt.lakebtc({
    'enableRateLimit': True,
    'rateLimit': 1000,
})
import sys

#------------------------------------------------------------------------------

root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
sys.path.append(root)

#------------------------------------------------------------------------------

import ccxt.async as ccxt  # noqa: E402

#------------------------------------------------------------------------------

kraken = ccxt.kraken({
    'apiKey': "hEvQNMDIeoCJbr7W/ZBb5CGOrx3G0lWF5B3zqa1JBxdZlEaL8EK+D0Mw",
    'secret': "JaE9wI6Nwgh5oRxiHcVxurwzwBxwc05W/qv/k1srGg4s3EYuXPpNkLLM5NYbbWpM8rCyijIeDavRuqWbU0ZV9A==",
    # 'verbose': True, # switch it to False if you don't want the HTTP log
})

#------------------------------------------------------------------------------

async def poll():
    while True:
        yield await kraken.fetch_ticker('BTC/USD')
        await asyncio.sleep(kraken.rateLimit / 1000)

#------------------------------------------------------------------------------

async def main():
    async for ticker in poll():
        print(ticker)
import os
import sys

root = os.path.dirname(
    os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
sys.path.append(root)

import ccxt. async as ccxt  # noqa: E402


async def test(exchange):
    print(await exchange.fetch_balance())


kraken = ccxt.kraken({
    'apiKey': "hEvQNMDIeoCJbr7W/ZBb5CGOrx3G0lWF5B3zqa1JBxdZlEaL8EK+D0Mw",
    'secret':
    "JaE9wI6Nwgh5oRxiHcVxurwzwBxwc05W/qv/k1srGg4s3EYuXPpNkLLM5NYbbWpM8rCyijIeDavRuqWbU0ZV9A==",
    'verbose': True,  # switch it to False if you don't want the HTTP log
})
bitfinex = ccxt.bitfinex({
    'apiKey': "4FlEDtxDl35gdEiobnfZ72vJeZteE4Bb7JdvqzjIjHq",
    'secret': "D4DXM8DZdHuAq9YptUsb42aWT1XBnGlIJgLi8a7tzFH",
    'verbose': True,  # switch it to False if you don't want the HTTP log
})

[asyncio.ensure_future(test(exchange)) for exchange in [kraken, bitfinex]]
pending = asyncio.Task.all_tasks()
loop = asyncio.get_event_loop()
loop.run_until_complete(asyncio.gather(*pending))
Beispiel #9
0
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!')
Beispiel #10
0
    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)
Beispiel #11
0
# -*- 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

exchange = ccxt.kraken()


async def poll():
    while True:
        yield await exchange.fetch_order_book('BTC/USD')
        await asyncio.sleep(exchange.rateLimit / 1000)


async def main():
    async for orderbook in poll():
        print(orderbook['bids'][0], orderbook['asks'][0],
              orderbook['timestamp'])


asyncio.get_event_loop().run_until_complete(main())
Beispiel #12
0
import ccxt.async as ccxt
from bot_speculator import BotSpeculator
from helper import NoInternetException

if __name__ == '__main__':
    # initialize exchangers instances

    kraken = ccxt.kraken({'apiKey': 'yourapikey',
                          'secret': 'yoursecrect'})
    binance = ccxt.binance({'apiKey': 'yourapikey',
                            'secret': 'yoursecrect'})
    # group them together
    gateways = [binance, kraken]  #[cex, binance, bittrex, poloniex, kraken]
    # define pairs for analysis
    pairs = ['XRP/BTC']
    # run the bot
    speculator = BotSpeculator(gateways, pairs, 10.3)
    try:
        speculator.run(5)
    except KeyboardInterrupt:
        print('stop.')
    except NoInternetException:
        print('Connect to the Internet to run the program!')
Beispiel #13
0
    def __init__(self, exchange_id, config):
        threading.Thread.__init__(self)

        self.ob_constant = OD_TICK_TIMER
        self.bl_constant = BALANCE_TICK_TIMER
        self.trade_constant = TRADE_TICK_TIMER

        self.stop_tick_time = datetime.datetime.now() + datetime.timedelta(
            seconds=TICK_TIMER)
        self.orderbook_tick_time = datetime.datetime.now(
        ) + datetime.timedelta(seconds=self.ob_constant)
        self.balance_tick_time = datetime.datetime.now() + datetime.timedelta(
            seconds=self.bl_constant)
        self.trade_tick_time = datetime.datetime.now() + datetime.timedelta(
            seconds=self.trade_constant)
        self.info_tick_time = datetime.datetime.now() + datetime.timedelta(
            seconds=INFO_TIMER)

        self.config = config
        self.orderbook_count = 0
        self.pair_info = dict()

        self.exhange = exchange_id
        self.is_auth = False
        self.name = '[ccxt %s]' % self.exhange
        self.pair_list = set()

        if self.exhange == 'liqui':
            self.ob_constant = 30
            self.bl_constant = 60

        self.ccxt_in_queue = self.config['in_queue']
        self.ccxt_out_queue = self.config['out_queue']

        #self.pair_list = self.config['pairs']

        # for i in self.config['pairs']:
        #     i['balance_tick'] = True
        #     self.pair_list.add( i['name'] )

        auth = {}
        if 'auth' in self.config.keys():
            auth = self.config['auth']
            self.is_auth = True
            self.name = '[ccxt %s %s*]' % (self.exhange, auth['apiKey'][:4])

        loop = asyncio.new_event_loop()
        asyncio.set_event_loop(loop)

        if self.exhange == 'hitbtc':
            loop.create_task(self.run_loop(ccxt.hitbtc(auth)))
        elif self.exhange == 'coinmarketcap':
            loop.create_task(self.run_loop(ccxt.coinmarketcap()))
        elif self.exhange == 'binance':
            loop.create_task(self.run_loop(ccxt.binance(auth)))
        elif self.exhange == 'bitmex':
            loop.create_task(self.run_loop(ccxt.bitmex(auth)))
        elif self.exhange == 'huobipro':
            loop.create_task(self.run_loop(ccxt.huobipro()))
        elif self.exhange == 'liqui':
            loop.create_task(self.run_loop(ccxt.liqui(auth)))
        elif self.exhange == 'bitfinex2':
            loop.create_task(self.run_loop(ccxt.bitfinex2(auth)))
        elif self.exhange == 'bitfinex':
            loop.create_task(self.run_loop(ccxt.bitfinex(auth)))
        elif self.exhange == 'okex':
            loop.create_task(self.run_loop(ccxt.okex(auth)))
        elif self.exhange == 'kucoin':
            loop.create_task(self.run_loop(ccxt.kucoin(auth)))
        elif self.exhange == 'bittrex':
            loop.create_task(self.run_loop(ccxt.bittrex(auth)))
        elif self.exhange == 'qryptos':
            loop.create_task(self.run_loop(ccxt.qryptos(auth)))
        elif self.exhange == 'kraken':
            loop.create_task(self.run_loop(ccxt.kraken(auth)))

        loop.run_forever()