def Account_Balance(exchange):
    factory = getattr(ccxt, exchange)()
    factory.apiKey = getattr(keychain, exchange).Christian('API')
    factory.secret = getattr(keychain, exchange).Christian('Secret')

    balances = factory.fetch_total_balance()

    usd_Balance = 0
    usdt_usd = ccxt.kraken().fetch_ticker('USDT/USD')['last']
    try:
        btc_usd = ccxt.bitmex().fetch_ticker('BTC/USD')['last']
    except:
        btc_usd = ccxt.coinbase().fetch_ticker('BTC/USD')['last']
    print(btc_usd)

    for currency in balances:
        if balances[currency] != 0:
            time.sleep(0.1)
            if currency == 'BTC':
                balance = balances[currency] * btc_usd
            elif currency == 'USDT':
                balance = balances[currency] * usdt_usd
            else:
                try:
                    btc_pair = factory.fetch_ticker(f'{currency}/BTC')['last']
                    balance = balances[currency] * btc_pair * btc_usd
                except Exception as e:
                    print(e)
            print(currency, balance)
            usd_Balance = usd_Balance + balance

    return [usd_Balance, btc_usd]
Esempio n. 2
0
def init_supported_exchanges():
    objects = {
        "binance": ccxt.binance(),
        "bitfinex": ccxt.bitfinex(),
        "bitflyer": ccxt.bitflyer(),
        "bitstamp": ccxt.bitstamp(),
        "bittrex": ccxt.bittrex(),
        "coinbase": ccxt.coinbase(),
        "kraken": ccxt.kraken(),
        "poloniex": ccxt.poloniex()
    }
    return objects
Esempio n. 3
0
class BtcRateTicker:
    bitmex = ccxt.bitmex()
    coinbase = ccxt.coinbase()
    kraken = ccxt.kraken()

    async def get_btc_usd_rates(self):
        symb = 'BTC/USD'
        bitmex_rates = self.bitmex.fetch_ticker(symb)['average']
        coinbase_rates = self.coinbase.fetch_ticker(
            symb)['info']['spot']['data']['amount']
        kraken_rates = self.kraken.fetch_ticker(symb)['ask']
        return bitmex_rates, coinbase_rates, kraken_rates
Esempio n. 4
0
import ccxt
import os
import random

from tabulate import tabulate, tabulate_formats


def get_random_table_format() -> str:
    return random.choice(tabulate_formats)


exchange = ccxt.coinbase({
    'apiKey': os.getenv('COINBASE_API_KEY'),
    'secret': os.getenv('COINBASE_API_SECRET'),
    'enableRateLimit': True
})
markets = exchange.load_markets()

monitor_symbols = ['BTC/EUR', 'ZRX/EUR']

prices = {}

try:
    while True:
        # for wanted_symbol in monitor_symbols:
        #     ticker = exchange.fetch_ticker(wanted_symbol)
        #     # print(f'{wanted_symbol} {ticker["close"]}')

        balance = exchange.fetch_balance()

        total_nonzero = {k: v for k, v in balance['total'].items() if v != 0}
 def buildApiObjects():
     Asset.coinbase = ccxt.coinbase()
     Asset.binanceus = ccxt.binanceus()
     Asset.kraken = ccxt.kraken()
     Asset.apiObjectsBuilt = True
import sys, time
import ccxt, yaml
import utils
from EpochPST import EpochPST

coinbase = ccxt.coinbase()
binanceus = ccxt.binanceus()
kraken = ccxt.kraken()


class Asset:
    def __init__(self, name, exchange, quantity, costBasis=0, setupApi=True):
        self.name = name
        self.quantity = quantity
        self.costBasis = costBasis
        self.lastPrice = 0
        if (setupApi):
            self.exchange = Asset.fetchApiObject(exchange)

    def buildApiObjects():
        Asset.coinbase = ccxt.coinbase()
        Asset.binanceus = ccxt.binanceus()
        Asset.kraken = ccxt.kraken()
        Asset.apiObjectsBuilt = True

    def fetchApiObject(exchange):
        if (exchange == "coinbase"):
            return Asset.coinbase
        if (exchange == "binanceus"):
            return Asset.binanceus
        if (exchange == "kraken"):
Esempio n. 7
0
bitfinex = ccxt.bitfinex({
    'enableRateLimit': True,
})
# enter your API public/secret keys here:
bitfinex.apiKey = API_keys.bitfinex.apiKey
bitfinex.secret = API_keys.bitfinex.secret

bittrex = ccxt.bittrex({
    'enableRateLimit': True,
})
# enter your API public/secret keys here:
bittrex.apiKey = API_keys.bittrex.apiKey
bittrex.secret = API_keys.bittrex.secret

coinbase = ccxt.coinbase({
    'enableRateLimit': True,
})
# enter your API public/secret keys here:
coinbase.apiKey = API_keys.coinbase.apiKey
coinbase.secret = API_keys.coinbase.secret

#
# coindeal = ccxt.coindeal({
#         'enableRateLimit':True,
# })
# # enter your API public/secret keys here:
# coindeal.apiKey = my_API_keys.coindeal.apiKey
# coindeal.secret = my_API_keys.coindeal.secret

gemini = ccxt.gemini({
    'enableRateLimit': True,
Esempio n. 8
0
def init_supported_exchanges():
    objects = {
        "acx": ccxt.acx(),
        "aofex": ccxt.aofex(),
        "bequant": ccxt.bequant(),
        "bibox": ccxt.bibox(),
        "bigone": ccxt.bigone(),
        "binance": ccxt.binance(),
        "bitbank": ccxt.bitbank(),
        "bitbay": ccxt.bitbay(),
        "bitfinex": ccxt.bitfinex(),
        "bitflyer": ccxt.bitflyer(),
        "bitforex": ccxt.bitforex(),
        "bithumb": ccxt.bithumb(),
        "bitkk": ccxt.bitkk(),
        "bitmax": ccxt.bitmax(),
        "bitstamp": ccxt.bitstamp(),
        "bittrex": ccxt.bittrex(),
        "bitz": ccxt.bitz(),
        "bl3p": ccxt.bl3p(),
        "bleutrade": ccxt.bleutrade(),
        "braziliex": ccxt.braziliex(),
        "btcalpha": ccxt.btcalpha(),
        "btcbox": ccxt.btcbox(),
        "btcmarkets": ccxt.btcmarkets(),
        "btctradeua": ccxt.btctradeua(),
        "bw": ccxt.bw(),
        "bybit": ccxt.bybit(),
        "bytetrade": ccxt.bytetrade(),
        "cex": ccxt.cex(),
        "chilebit": ccxt.chilebit(),
        "coinbase": ccxt.coinbase(),
        "coinbasepro": ccxt.coinbasepro(),
        "coincheck": ccxt.coincheck(),
        "coinegg": ccxt.coinegg(),
        "coinex": ccxt.coinex(),
        "coinfalcon": ccxt.coinfalcon(),
        "coinfloor": ccxt.coinfloor(),
        "coinmate": ccxt.coinmate(),
        "coinone": ccxt.coinone(),
        "crex24": ccxt.crex24(),
        "currencycom": ccxt.currencycom(),
        "digifinex": ccxt.digifinex(),
        "dsx": ccxt.dsx(),
        "eterbase": ccxt.eterbase(),
        "exmo": ccxt.exmo(),
        "exx": ccxt.exx(),
        "foxbit": ccxt.foxbit(),
        "ftx": ccxt.ftx(),
        "gateio": ccxt.gateio(),
        "gemini": ccxt.gemini(),
        "hbtc": ccxt.hbtc(),
        "hitbtc": ccxt.hitbtc(),
        "hollaex": ccxt.hollaex(),
        "huobipro": ccxt.huobipro(),
        "ice3x": ccxt.ice3x(),
        "independentreserve": ccxt.independentreserve(),
        "indodax": ccxt.indodax(),
        "itbit": ccxt.itbit(),
        "kraken": ccxt.kraken(),
        "kucoin": ccxt.kucoin(),
        "lakebtc": ccxt.lakebtc(),
        "latoken": ccxt.latoken(),
        "lbank": ccxt.lbank(),
        "liquid": ccxt.liquid(),
        "livecoin": ccxt.livecoin(),
        "luno": ccxt.luno(),
        "lykke": ccxt.lykke(),
        "mercado": ccxt.mercado(),
        "oceanex": ccxt.oceanex(),
        "okcoin": ccxt.okcoin(),
        "okex": ccxt.okex(),
        "paymium": ccxt.paymium(),
        "poloniex": ccxt.poloniex(),
        "probit": ccxt.probit(),
        "southxchange": ccxt.southxchange(),
        "stex": ccxt.stex(),
        "surbitcoin": ccxt.surbitcoin(),
        "therock": ccxt.therock(),
        "tidebit": ccxt.tidebit(),
        "tidex": ccxt.tidex(),
        "upbit": ccxt.upbit(),
        "vbtc": ccxt.vbtc(),
        "wavesexchange": ccxt.wavesexchange(),
        "whitebit": ccxt.whitebit(),
        "yobit": ccxt.yobit(),
        "zaif": ccxt.zaif(),
        "zb": ccxt.zb()
    }
    return objects
from pycoingecko import CoinGeckoAPI

import pandas as pd
import datetime
import time
import ccxt
import _thread
#  Coinbase api
#  Remember to enter key and secret
coinbase = ccxt.coinbase({
    'apiKey': '',
    'secret': '',
})

# coin gecko api
cg = CoinGeckoAPI()


def convert_time(d):

    return (datetime.date.fromtimestamp(d / 1000.0))


def symbol_name_map():
    temp_dic = {}
    target = cg.get_coins_markets("usd")
    for item in target:
        k, v = item["symbol"], item["id"]
        temp_dic[k] = v
    return temp_dic
Esempio n. 10
0
 def build_market(self):
     self.binance = ccxt.binance()
     self.coinbase = ccxt.coinbase()
     self.kucoin = ccxt.kucoin()