예제 #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 animate(i):
    btcusd = (asyncio.get_event_loop().run_until_complete(ccxt.bittrex().fetch_ticker('BTC/USDT')))
    print(btcusd)
    print(btcusd['bid'])
    print(btcusd['ask'])

#    try:
#        startdate
#    except NameError:
#        startdate = mdate.epoch2num(btcusd['timestamp'] / 1000)

    xaxis = mdate.epoch2num(btcusd['timestamp'] / 1000)
    yaxis = btcusd['bid']
#    x = datetime.datetime.fromtimestamp(btcusd['timestamp'].astype(str))
    ######ax1.clear()
    #ax1.set_xticklabels(xs)
    #ax1.axis([0, 20, 0, 20])
    ##ax1.plot_date(x, btcusd['bid'])
    #####ax1.plot_date(x = xaxis, y = yaxis, lw=1, linestyle = 'solid') #fmt = '.r-') #, linestyle='solid', marker='None') #, fmt='-', linewidth=2)
    ax1.plot_date(xaxis, yaxis, ls='-', marker='.')

    ##ax1.yaxis.set_major_formatter(FormatStrFormatter('%.8f'))
    plt.axes().tick_params(labelsize=6)
    plt.axes().yaxis.set_major_formatter(FormatStrFormatter('%.2f'))
    ### ETH/BTC plt.axes().yaxis.set_major_formatter(FormatStrFormatter('%.8f'))
    plt.axes().xaxis.set_major_formatter(mdate.DateFormatter('%Y-%m-%d %H:%M:%S'))
    plt.axes().xaxis_date()
    plt.setp(plt.gca().get_xticklabels(), rotation=45, horizontalalignment='center')

    #ax1.plot(btcusd['bid'])
    plt.xlim(mdate.epoch2num((btcusd['timestamp'] / 1000) - 300), mdate.epoch2num((btcusd['timestamp'] / 1000) + 300))
    ##plt.xlim(startdate, datetime.date.today())
    # ETC/BTC plt.ylim(btcusd['bid'] - 0.0000001, btcusd['bid'] + 0.0000001)
    plt.ylim(btcusd['bid'] - 50, btcusd['bid'] + 50)
예제 #3
0
파일: async-balance.py 프로젝트: zsyh/ccxt
async def test():
    bittrex = ccxt.bittrex({
        'apiKey': "YOUR_API_KEY",
        'secret': "YOUR_SECRET",
        'verbose': True,  # switch it to False if you don't want the HTTP log
    })
    print(await bittrex.fetch_balance())
    await bittrex.close()
예제 #4
0
async def test(loop):
    exchange = ccxt.bittrex({
        'asyncio_loop': loop,
        'enableRateLimit':
        True,  # as required by https://github.com/ccxt/ccxt/wiki/Manual#rate-limit
    })
    print(await exchange.fetch_ticker('ETH/BTC'))
    await exchange.close()
예제 #5
0
    async def test_get_kline_price(self):
        # kline_price = await self.get_kline_price()
        client = bittrex()
        await client.fetch_markets()
        kline_price = [
            (await client.fetch_ohlcv(TestBittrexRealExchangeTester.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()
예제 #6
0
async def poll():
    exchange = ccxt.bittrex()
    while True:
        yield await exchange.fetch_order_book('BTC/USDT')
        await asyncio.sleep(exchange.rateLimit / 1000)
예제 #7
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_support 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
    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()
예제 #9
0
async def test(loop):
    exchange = ccxt.bittrex({
        'asyncio_loop': loop,
    })
    print(await exchange.fetch_ticker('ETH/BTC'))
    await exchange.close()