示例#1
0
async def test():
    bittrex = ccxt.bittrex({
        'apiKey': "c5af1d0ceeaa4729ad87da1b05d9dfc3",
        'secret': "d055d8e47fdf4c3bbd0ec6c289ea8ffd",
        'verbose': True,  # switch it to False if you don't want the HTTP log
    })
    print(await bittrex.fetch_balance())
示例#2
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()
示例#3
0
async def test():
    bittrex = ccxt.bittrex({
        'apiKey': "c5af1d0ceeaa4729ad87da1b05d9dfc3",
        'secret': "d055d8e47fdf4c3bbd0ec6c289ea8ffd",
        'verbose': True,  # switch it to False if you don't want the HTTP log
    })
    print(await bittrex.fetch_balance())
示例#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()
示例#5
0
loggers = {}
for ex in participants:
    existance[ex] = []
    loggers[ex] = setup_logger('%s' % ex, '%s.log' % ex)

fees = {
    'binance': 0.05 / 100,
    'bitfinex': 0.1 / 100,
    'bittrex': 0.25 / 100,
    'huobi': 0.04 / 100
}

exs = {
    'binance': ccxt.binance(),
    'bitfinex': ccxt.bitfinex(),
    'bittrex': ccxt.bittrex(),
    'huobi': ccxt.huobipro()
}

datas = {}
universe = pd.read_excel('binance/backtest_fee0.2&volumefilter.xlsx')
loop = asyncio.get_event_loop()

k = 0.5
target_vol = 0.25
fee = 0.2 / 100
window = 500
min_volume = {'USDT': 5000000, 'BTC': 500, 'ETH': 10000, 'BNB': 500000}
pairs = []
info = {}
示例#6
0
    "secret": "spMNDyhaRhEtCyQTGPSMKOwW9YIM8LYV0daWOm4ZiNSleRew",
})
bitso = ccxt.bitso({
    'enableRateLimit': True,
    'rateLimit': 1000,
})
bitstamp = ccxt.bitstamp({
    'enableRateLimit': True,
    'rateLimit': 1000,
})
bitstamp1 = ccxt.bitstamp1({
    'enableRateLimit': True,
    'rateLimit': 1000,
})
bittrex = ccxt.bittrex({
    'enableRateLimit': True,
    'rateLimit': 1000,
})
bitz = ccxt.bitz({
    'enableRateLimit': True,
    'rateLimit': 1000,
    "apiKey": "c1cf93a1182e5a38bb8a8c3458310396",
    "secret": "a7a55512ee789d6519fd005345644133",
})
bl3p = ccxt.bl3p({
    'enableRateLimit': True,
    'rateLimit': 1000,
})
bleutrade = ccxt.bleutrade({
    'enableRateLimit': True,
    'rateLimit': 1000,
})
# -*- 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.bittrex()


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


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


asyncio.get_event_loop().run_until_complete(main())
示例#8
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)
# -*- 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.bittrex()


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


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


asyncio.get_event_loop().run_until_complete(main())
示例#10
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()