Example #1
0
def initExchange(logger):
    """Return set of exchange."""
    bitflyer = ccxt.bitflyer({
        'apiKey': os.environ.get('bitflyer_key'),
        'secret': os.environ.get('bitflyer_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')})
    return {'bitflyer': bitflyer, 'bitbank': bitbank, 'bitbank2': bitbank2}
Example #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
Example #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}
Example #4
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
Example #5
0
import asyncio
import time

import ccxt.async as ccxt
import pandas as pd
from IPython.display import display

gateio = ccxt.gateio()
gdax = ccxt.gdax()
binance = ccxt.binance()
bitbank = ccxt.bitbank()
bit2c = ccxt.bit2c()
bitbay = ccxt.bitbay()


exchanges = {
    gateio: ['ETH/BTC', 'LTC/BTC'],
    gdax: ['ETH/BTC', 'LTC/BTC', 'BTC/USD'],
    binance: ['ETH/BTC', 'LTC/BTC'],
    bitbank: ['ETH/BTC', 'LTC/BTC'],
    bit2c: ['BTC/NIS', 'LTC/NIS'],
    bitbay: ['ETH/BTC', 'LTC/BTC']
}


async def get_top_of_book(top_bids, top_asks, exchange, symbol):
    book = await exchange.fetch_order_book(symbol)
    top_bids[exchange.name][symbol] = float(book['bids'][0][0])
    top_bids[exchange.name]["taker"] = exchange.fees['trading']['taker']
    top_asks[exchange.name][symbol] = float(book['asks'][0][0])