Exemplo n.º 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()
Exemplo n.º 2
0
def main() -> int:
    dotenv_path = os.path.join(os.path.dirname(__file__), '../.env')
    dotenv.load_dotenv(dotenv_path)
    cs = ['XRP', 'JPY', 'BTC']
    hitbtc2 = ccxt.hitbtc2({
        'apiKey': os.environ.get('hitbtc2_key'),
        'secret': os.environ.get('hitbtc2_secret')
    })
    bitbank = ccxt.bitbank({
        'apiKey': os.environ.get('bitbank_key'),
        'secret': os.environ.get('bitbank_secret')
    })
    bitflyer = ccxt.bitflyer({
        'apiKey': os.environ.get('bitflyer_key'),
        'secret': os.environ.get('bitflyer_secret')
    })
    ts = [hitbtc2, bitbank, bitflyer]
    el = asyncio.get_event_loop()
    bs = el.run_until_complete(asyncio.gather(*[t.fetch_balance()
                                                for t in ts]))
    cbs = [sum([b['total'].get(c, 0) for b in bs]) for c in cs]
    lightning = el.run_until_complete(
        bitflyer.fetch2(path='getcollateral', api='private', method='GET'))
    el.run_until_complete(asyncio.gather(*[t.close() for t in ts]))
    added = [
        cbs[0],
        cbs[1] + lightning['collateral'] + lightning['open_position_pnl'],
        cbs[2]
    ]
    print(' '.join([str(x) for x in added]))
    return 0
Exemplo n.º 3
0
def init():
    """apiなど初期化."""
    hitbtc2 = ccxt.hitbtc2({
        'apiKey': os.environ.get('hitbtc2_key'),
        'secret': os.environ.get('hitbtc2_secret')})
    bitbank = ccxt.bitbank({
        'apiKey': os.environ.get('bitbank_key'),
        'secret': os.environ.get('bitbank_secret')})
    bitbank2 = ccxt.bitbank({
        'apiKey': os.environ.get('bitbank_key2'),
        'secret': os.environ.get('bitbank_secret2')})
    el = asyncio.get_event_loop()
    (hitbtc2Markets, bitbankMarkets) = el.run_until_complete(asyncio.gather(
        hitbtc2.load_markets(),
        bitbank.load_markets()))
    return {'hitbtc2': hitbtc2, 'bitbank': bitbank,
            'bitbank2': bitbank2}
Exemplo n.º 4
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))
Exemplo n.º 5
0
def main() -> int:
    """main."""
    dotenv_path = os.path.join(os.path.dirname(__file__), '../.env')
    dotenv.load_dotenv(dotenv_path)
    logger = initLogger(slackUrl=os.environ.get('slack_url'))
    cs = ['XRP', 'JPY', 'BTC']
    hitbtc2 = ccxt.hitbtc2({
        'apiKey': os.environ.get('hitbtc2_key'),
        'secret': os.environ.get('hitbtc2_secret')})
    bitbank = ccxt.bitbank({
        'apiKey': os.environ.get('bitbank_key'),
        'secret': os.environ.get('bitbank_secret')})
    bitflyer = ccxt.bitflyer({
        'apiKey': os.environ.get('bitflyer_key'),
        'secret': os.environ.get('bitflyer_secret')})
    ts = [hitbtc2, bitbank, bitflyer]
    el = asyncio.get_event_loop()
    bs = el.run_until_complete(
        asyncio.gather(*[t.fetch_balance() for t in ts]))
    cbs = [sum([b['total'].get(c, 0) for b in bs]) for c in cs]
    lightning = el.run_until_complete(bitflyer.fetch2(
        path='getcollateral', api='private', method='GET'))
    val = el.run_until_complete(asyncio.gather(
        bitbank.fetch_order_book('XRP/JPY', limit=1),
        bitbank.fetch_order_book('BTC/JPY', limit=1)))
    el.run_until_complete(asyncio.gather(*[t.close() for t in ts]))
    added = [
        cbs[0],
        cbs[1] + lightning['collateral'] + lightning['open_position_pnl'],
        cbs[2]]
    p = (
        added[0] * val[0]['bids'][0][0] +
        added[1] +
        added[2] * val[1]['bids'][0][0])
    logger.info(p)
    return 0
Exemplo n.º 6
0
    '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",
    "secret": "568e6d454ea9897b183c4ba2ff4bf598",
})
huobi = ccxt.huobi({
    'enableRateLimit': True,
    'rateLimit': 1000,
    "apiKey": "a3a1ee7f-2e64f1bb-925f3e37-3fe72",
    "secret": "05c371ab-0d9d012f-39d3f12d-a6c68",
})
huobicny = ccxt.huobicny({
    'enableRateLimit': True,
    'rateLimit': 1000,
    "apiKey": "a3a1ee7f-2e64f1bb-925f3e37-3fe72",
    "secret": "05c371ab-0d9d012f-39d3f12d-a6c68",
})
huobipro = ccxt.huobipro({