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)
Ejemplo n.º 2
0
async def poll():
    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
    })
    while True:
        yield await kraken.fetch_ticker('BTC/USD')
        await asyncio.sleep(kraken.rateLimit / 1000)
Ejemplo n.º 3
0
    async def test_get_kline_price(self):
        # kline_price = await self.get_kline_price()
        client = kraken()
        await client.fetch_markets()
        kline_price = [(await
                        client.fetch_ohlcv(TestKrakenRealExchangeTester.SYMBOL,
                                           TimeFrames.ONE_HOUR.value))[-1]]

        assert len(kline_price) == 1
        assert len(kline_price[0]) == 6
        kline_start_time = kline_price[0][PriceIndexes.IND_PRICE_TIME.value]
        # assert kline is the current candle
        assert kline_start_time >= self.get_time(
        ) - self.get_allowed_time_delta()
        await client.close()
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_support 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))
Ejemplo n.º 5
0
    ccxt.coinbasepro({
        'enableRateLimit':
        True,  # this option enables the built-in rate limiter
    }),
    "bitfinex2":
    ccxt.bitfinex2({
        'enableRateLimit':
        True,  # this option enables the built-in rate limiter
    }),
    "huobipro":
    ccxt.huobipro({
        'enableRateLimit':
        True,  # this option enables the built-in rate limiter
    }),
    "okex":
    ccxt.okex({
        'enableRateLimit':
        True,  # this option enables the built-in rate limiter
    }),
    "kraken":
    ccxt.kraken({
        'enableRateLimit':
        True,  # this option enables the built-in rate limiter
    }),
    "bitmex":
    ccxt.bitmex({
        'enableRateLimit':
        True,  # this option enables the built-in rate limiter
    })
}
Ejemplo n.º 6
0
    def __init__(self, loop, config):

        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.logger = None
        if 'logger' in self.config.keys():
            self.logger = self.config['logger']

        self.exhange = config['exchange']
        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_it_queue = self.config['ccxt_in_queue']
        self.ccxt_out_queue = self.config['ccxt_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])

        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()
Ejemplo n.º 7
0
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_support as ccxt  # noqa: E402


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


kraken = ccxt.kraken({
    'apiKey': "YOUR_API_KEY",
    'secret': "YOUR_SECRET",
    'verbose': True,  # switch it to False if you don't want the HTTP log
})
bitfinex = ccxt.bitfinex({
    'apiKey': "YOUR_API_KEY",
    'secret': "YOUR_SECRET",
    '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))
Ejemplo n.º 8
0
import datetime
import asyncio
import ccxt.async_support as ccxt
import dateutil.parser
from tinydb import TinyDB, Query

db = TinyDB('db.json')
signalDB = db.table('signal')
symbolsDb = db.table('symbols')
tradesDb = db.table('trades')
q = Query()

kraken = ccxt.kraken()


# Map trades from signal
# ------------------------------------------------------------------------------
async def run_map_trade(tickers):
    i = 0
    while True:
        symbol = tickers[i % len(tickers)]
        yield symbol, map_trade(symbol)
        i += 1
        await asyncio.sleep(5)


def map_trade(ticker):
    b = Query()
    # Get latest entry for symbol and timeframe
    signals = signalDB.search((b.ticker == ticker[0])
                              & (b.interval == str(ticker[1])))