def initiate_exchange():
    exchange = ccxt.okcoinusd()  # default id
    okcoin1 = ccxt.okcoinusd({'id': 'okcoin1'})
    okcoin2 = ccxt.okcoinusd({'id': 'okcoin2'})
    id = 'btcchina'
    btcchina = eval('ccxt.%s ()' % id)
    gdax = getattr(ccxt, 'gdax')()
Example #2
0
def get_market(market=OKEX):
    mk = ccxt.okcoinusd()
    if market == HUOBI:
        mk = ccxt.huobipro()
    if market == CRY:
        mk = ccxt.cryptopia()
    if market == BIN:
        mk = ccxt.binance()
    if market == PLX:
        mk = ccxt.poloniex()
    return mk
Example #3
0
    def test_ccxt(self):
        #print(ccxt.markets)  # print a list of all available market classes
        hitbtc = ccxt.hitbtc({'verbose': True})
        bitmex = ccxt.bitmex()
        huobi = ccxt.huobi()
        bitfinex = ccxt.bitfinex({
            'apiKey': 'YOUR-API-KEY',
            'secret': 'YOUR-API-KEY',
        })
        okcoinusd = ccxt.okcoinusd({
            'apiKey': 'YOUR-API-KEY',
            'secret': 'YOUR-API-KEY',
        })

        trade_amount = 0.1
        market = 'ETH_USD'
        ticker = okcoinusd.fetch_ticker(market)
        print(ticker)
        print('debug %s' % okcoinusd.create_limit_buy_order(
            market, trade_amount, ticker['ask'] + 1))
Example #4
0
def fetch_exchange_data(exchange_name):
    bitstamp = ccxt.bitstamp()
    bitmex = ccxt.bitmex()
    bitfinex = ccxt.bitfinex2()
    bittrex = ccxt.bittrex()
    okcoin = ccxt.okcoinusd()
    kraken = ccxt.kraken()
    binance = ccxt.binance()
    coss = ccxt.coss()
    kucoin = ccxt.kucoin2()
    poloniex = ccxt.poloniex()
    # theocean = ccxt.theocean()
    upbit = ccxt.upbit()
    dict_of_exchanges = {
        'kraken': kraken,
        'bitmex': bitmex,
        'bittrex': bittrex,
        'bitstamp': bitstamp,
        'bitfinex': bitfinex,
        'okcoin': okcoin,
        'binance': binance,
        'coss': coss,
        'kucoin': kucoin,
        'poloniex': poloniex,
        # 'theocean': theocean,
        'upbit': upbit
    }
    try:
        return dict(
            dict_of_exchanges[exchange_name].fetch_order_book('BTC/USD'))
        # return dict(dict_of_exchanges[exchange_name].fetch_order_book('XRP/USD'))
        # return dict(dict_of_exchanges[exchange_name].fetch_order_book('LTC/USD'))
        # add BitcoinCash
        # return dict(dict_of_exchanges[exchange_name].fetch_order_book('ETH/USD'))
    except Exception as ex:
        print('%s - erro: %s' % (exchange_name, ex))
        return {}
Example #5
0
def exchangeObject(exchange_in):
    exchanges = [
        ccxt.acx(),
        ccxt.bitbay(),
        ccxt.bitfinex(),
        ccxt.bitflyer(),
        ccxt.bithumb(),
        ccxt.bitlish(),
        ccxt.bitmarket(),
        ccxt.bitmex(),
        ccxt.bitso(),
        ccxt.bitstamp(),
        ccxt.bitstamp1(),
        ccxt.bittrex(),
        ccxt.bl3p(),
        ccxt.bleutrade(),
        ccxt.btcbox(),
        ccxt.btcchina(),
        ccxt.btcexchange(),
        ccxt.btcmarkets(),
        ccxt.btctradeua(),
        ccxt.btcturk(),
        ccxt.bxinth(),
        ccxt.ccex(),
        ccxt.cex(),
        ccxt.chbtc(),
        ccxt.chilebit(),
        ccxt.coincheck(),
        ccxt.coinfloor(),
        ccxt.coingi(),
        ccxt.coinmarketcap(),
        ccxt.coinmate(),
        ccxt.coinspot(),
        ccxt.cryptopia(),
        ccxt.dsx(),
        ccxt.exmo(),
        ccxt.flowbtc(),
        ccxt.foxbit(),
        ccxt.fybse(),
        ccxt.fybsg(),
        ccxt.gatecoin(),
        ccxt.gateio(),
        ccxt.gdax(),
        ccxt.gemini(),
        ccxt.getbtc(),
        ccxt.hitbtc(),
        ccxt.independentreserve(),
        ccxt.itbit(),
        ccxt.jubi(),
        ccxt.kraken(),
        ccxt.kucoin(),
        ccxt.kuna(),
        ccxt.lakebtc(),
        ccxt.liqui(),
        ccxt.livecoin(),
        ccxt.luno(),
        ccxt.mercado(),
        ccxt.mixcoins(),
        ccxt.nova(),
        ccxt.okcoincny(),
        ccxt.okcoinusd(),
        ccxt.okex(),
        ccxt.paymium(),
        ccxt.poloniex(),
        ccxt.qryptos(),
        ccxt.quadrigacx(),
        ccxt.southxchange(),
        ccxt.surbitcoin(),
        ccxt.therock(),
        ccxt.tidex(),
        ccxt.urdubit(),
        ccxt.vaultoro(),
        ccxt.vbtc(),
        ccxt.virwox(),
        ccxt.wex(),
        ccxt.xbtce(),
        ccxt.yobit(),
        ccxt.yunbi(),
        ccxt.zaif(),
        ccxt.zb()
    ]

    for count, exchange in enumerate([str(x) for x in exchanges]):
        if exchange_in.lower() in exchange:
            return exchanges[count]
            break
Example #6
0
def main():

    exchange = []

    exchange.append(ccxt.wex({'verbose': False}))
    exchange.append(ccxt.okcoinusd({'verbose': False}))

    if len(sys.argv) > 1:
        filter = str(sys.argv[1]).upper()
    else:
        filter = ''

    while True:
        for ex in exchange:
            try:
                ex.loadMarkets()
            except KeyboardInterrupt:
                return 1
            except:
                err = sys.exc_info()[1]
                print(err.args[0])
                continue

            print(
                '===> begin {:<12}'.format(ex.id),
                '<========================================================================================================'
            )
            print(
                '  market   spread %        bid price          bid vol     ask price           ask vol        spread            datetime'
            )
            print(
                "---------------------------------------------------------------------------------------------------------------------------------"
            )

            for market in ex.markets:
                if len(filter) != 0 and (ex.markets[market]['quote'] != filter
                                         and
                                         ex.markets[market]['base'] != filter):
                    continue
                try:
                    orderbook = ex.fetch_order_book(market)
                    ticker = ex.fetch_ticker(market)
                    quoteVolume = ticker['quoteVolume']
                    baseVolume = ticker['baseVolume']

                    if type(quoteVolume) != float:
                        quoteVolume = 0

                except KeyboardInterrupt:
                    return 1
                except:
                    err = sys.exc_info()[1]
                    print(err.args[0])
                    continue

                bid = max(orderbook['bids'], key=lambda item: item[0])
                if bid[0] < 1:
                    continue
                ask = min(orderbook['asks'], key=lambda item: item[0])

                spread = (ask[0] - bid[0])
                spread_percent = spread / ask[0] * 100

                print('{:>10}'.format(market),
                      '{0:>5.2f}%'.format(spread_percent), '\t',
                      '{0:>10.2f}'.format(bid[0]), '\t',
                      '{0:>12.2f}'.format(baseVolume), '\t',
                      '{0:>10.2f}'.format(ask[0]), '\t',
                      '{0:>12.2f}'.format(quoteVolume), '\t',
                      '{0:>10.2f}'.format(spread), '\t',
                      '{:<.16}'.format(orderbook['datetime']))

            print(
                '===> end', '{:<12}'.format(ex.id),
                '<==========================================================================================================\n'
            )

        print('***')
        sleep(30)
Example #7
0
            print(type(e).__name__, str(e))
            print('Failed.')

    else:

        print('Exchange ' + id + ' not found')
        print_supported_exchanges()

except Exception as e:
    print('[' + type(e).__name__ + ']', str(e))
    print('Usage: python ' + sys.argv[0] + ' id')
    print_supported_exchanges()

# print(ccxt.exchanges)

exchange = ccxt.okcoinusd()
okcoin1 = ccxt.okcoinusd({"id": "okcoin1"})
okcoin2 = ccxt.okcoinusd({"id": "okcoin2"})

id = "btcchina"
btcchina = eval('ccxt.%s ()' % id)
gdax = getattr(ccxt, 'gdax')()

# exchange_id = 'binance'
# exchange_class = getattr(ccxt, exchange_id)

okcoin = ccxt.binance()
marketse = okcoin.load_markets()
print(okcoin.id, marketse)
Example #8
0
import ccxt

okcoin = ccxt.okcoinusd()
markets = okcoin.load_markets()
print(okcoin.id, okcoin.symbols)
pair = 'BTC/USD'

#a = okcoin.markets['BTC/USD']
#print(a)

print(okcoin.fetch_ticker(pair))
print("\n====================\n")
print(okcoin.fetch_trades(pair))
Example #9
0
 ccxt.jubi(),
 ccxt.kraken(),
 ccxt.kucoin(),
 ccxt.kuna(),
 ccxt.lakebtc(),
 ccxt.lbank(),
 ccxt.liqui(),
 ccxt.livecoin(),
 ccxt.luno(),
 ccxt.lykke(),
 ccxt.mercado(),
 ccxt.mixcoins(),
 ccxt.negociecoins(),
 ccxt.nova(),
 ccxt.okcoincny(),
 ccxt.okcoinusd(),
 ccxt.okex(),
 ccxt.paymium(),
 ccxt.poloniex(),
 ccxt.qryptos(),
 ccxt.quadrigacx(),
 ccxt.quoinex(),
 ccxt.southxchange(),
 ccxt.surbitcoin(),
 ccxt.therock(),
 ccxt.tidex(),
 ccxt.urdubit(),
 ccxt.vaultoro(),
 ccxt.vbtc(),
 ccxt.virwox(),
 ccxt.wex(),
def okcoin_example():
    okcoin = ccxt.okcoinusd()
    markets = okcoin.load_markets()
    print(okcoin.id, "\n", markets)
Example #11
0
for exchange in exchanges:

    #engine = create_engine('postgresql+psycopg2://postgres:password@localhost/'+exchange+'_dev')

    #conn = engine.connect()
    #sql_db = pd.io.sql.SQLDatabase(engine)

    if exchange == 'bitfinex':
        exchange_ccxt = ccxt.bitfinex()
    if exchange == 'binance':
        exchange_ccxt = ccxt.binance()
    if exchange == 'okex':
        exchange_ccxt = ccxt.okex()
    if exchange == 'okcoinusd':
        exchange_ccxt = ccxt.okcoinusd()
        exchange = 'okcoin'
    #if exchange=='bibox':
    #   exchange_ccxt = ccxt.bibox()

    exchange_ccxt_markets = exchange_ccxt.load_markets()

    time_base_sans_apostrophe = time_base.replace("'", "")
    print('time_base_sans_apostrophe', time_base_sans_apostrophe)

    time_base_annee, time_base_mois, time_base_jour = re.split(
        "[-]", time_base_sans_apostrophe)
    dt = datetime.datetime(int(time_base_annee), int(time_base_mois),
                           int(time_base_jour))
    dt = dt + timedelta(days=nb_lignes + 1)