def get_historical_data(exchange_id, from_datetime): if exchange_id == 'coinbasepro': exchange = ccxt.coinbasepro({ 'rateLimit': 3000, 'enableRateLimit': True, #'verbose': True, }) elif exchange_id == 'binance': exchange = ccxt.binance({ 'rateLimit': 3000, 'enableRateLimit': True, #'verbose': True, }) global now if to_datetime == None: now = exchange.milliseconds() else: now_datetime = to_datetime now = exchange.parse8601(now_datetime) print("User specified import Daterange is as follows:") print("From date = ", from_datetime) print("To date = ", to_datetime) global markets, market_pairs markets = exchange.load_markets() market_pairs = list(markets.keys()) #market_pairs = ['ATOM/BTC', 'KNC/BTC', 'ATOM/USD'] market_pairs = ['BTC/USD'] global batch_import_finished batch_import_finished = False initial = True get_last_starttime_from_sql(exchange_id, market_pairs) if to_datetime == None: now = exchange.milliseconds() else: now_datetime = to_datetime now = exchange.parse8601(now_datetime) while True: if initial: run_parallel_market_import(exchange) initial = False # run through this loop when current import phase is ongoing if batch_import_finished == True: # break this loop and start new import #time.sleep(10) batch_import_finished = False print("Now sleeping.") time.sleep(20) print("Resuming import of all market pairs.") get_last_starttime_from_sql(exchange_id, market_pairs) now = exchange.milliseconds() initial = True
def initialize_exchange(self): exchange = ccxt.coinbasepro({ "rateLimit": self.rate_limit, "apiKey": self.api_key, "secret": self.api_secret, "password": self.api_passphrase }) return exchange
def create_exchanges(): """ instantiate the markets to include more exchanges use this function. new exchanges need to be hand-coded here """ coinbasepro = ccxt.coinbasepro({ 'apiKey': api_keys.coinbasepro['apiKey'], 'secret': api_keys.coinbasepro['secret'], }) poloniex = ccxt.poloniex({ 'apiKey': api_keys.poloniex['apiKey'], 'secret': api_keys.poloniex['secret'], }) bittrex = ccxt.bittrex({ 'apiKey': api_keys.bittrex['apiKey'], 'secret': api_keys.bittrex['secret'], }) binance = ccxt.binance({ 'apiKey': api_keys.binance['apiKey'], 'secret': api_keys.binance['secret'], }) bitfinex = ccxt.bitfinex({ 'apiKey': api_keys.bitfinex['apiKey'], 'secret': api_keys.bitfinex['secret'], }) kraken = ccxt.kraken({ 'apiKey': api_keys.kraken['apiKey'], 'secret': api_keys.kraken['secret'], }) bitmex = ccxt.bitmex({ 'apiKey': api_keys.bitmex['apiKey'], 'secret': api_keys.bitmex['secret'], }) okex = ccxt.okex({ 'apiKey': api_keys.okex['apiKey'], 'secret': api_keys.okex['secret'], }) exchanges = [ coinbasepro, poloniex, bittrex, binance, bitfinex, kraken, bitmex, okex ] timing_limits = [.35, .35, 1, .35, 2, 1, 1, .35] # requesting period limit per exchange for exchange, timing in zip(exchanges, timing_limits): g_storage.timer[exchange.name] = [0, timing] # exchanges.pop(exchanges.index(kraken)) return exchanges
def api_connection( key: str, secret: str, password: str, ): """Establish API connection to Coinbase Pro.""" cbpro = ccxt.coinbasepro() cbpro.apiKey = key cbpro.secret = secret cbpro.password = password
def coinbase(): cb = ccxt.coinbasepro() params = {'level': 3} data = cb.fetch_order_book('BTC/USD', params=params) asks = data['asks'] bids = data['bids'] price = (asks[0][0]+bids[0][0])/2 bids_info = get_ratio_sum(bids, 'bids') asks_info = get_ratio_sum(asks, 'asks') res = {} res.update(bids_info) res.update(asks_info) res['price'] = price res['exchange'] = 'coinbase' return res
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
import pandas as pd import schedule import time import warnings warnings.filterwarnings('ignore') pd.set_option('display.max_rows', None) API_KEY = config.COINBASE_API_KEY API_PASSWORD = config.COINBASE_API_PASSWORD API_PASSPHRASE = config.COINBASE_API_SECRET exchange1 = ccxt.coinbasepro({ "apiKey": config.COINBASE_API_KEY, "secret": config.COINBASE_API_SECRET, "password": config.COINBASE_API_PASSWORD }) exchange = ccxt.binanceus() #units = exchange.fetch_balance() bars = exchange.fetch_ohlcv('BTC/USD', timeframe='15m', limit=100) df = pd.DataFrame( bars[:-1], columns=['timestamp', 'open', 'high', 'low', 'close', 'volume']) df['timestamp'] = pd.to_datetime(df['timestamp'], unit='ms') # here we are going to be computing an upper and lower band with the formulas as follows # It is going to be split up into two different sections #---------BASIC------------
from decimal import * import requests import json from pprint import pprint import datetime import time import os from pathlib import Path import csv with open('credentials.json') as cred_file: credentials = json.load(cred_file) coinbase_pro = ccxt.coinbasepro({ 'apiKey': credentials['coinbase']['apiKey'], 'secret': credentials['coinbase']['secret'], 'password': credentials['coinbase']['password'] }) binance = ccxt.binance({ 'apiKey': credentials['binance']['apiKey'], 'secret': credentials['binance']['secret'], }) exchanges = {'Coinbase Pro': coinbase_pro, 'Binance': binance} for exchange in exchanges: exchanges[exchange].enableRateLimit = True print("Rate limiter enabled for " + exchange)
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 # noqa: E402 ''' Example snippet to traverse CoinBase Pro pagination. Useful for reaching back more than 100 myTrades, the same works for fetchClosedOrders ''' exchange = ccxt.coinbasepro({ "apiKey": "123456", "secret": "/abcdefghijklmnop/w==", "password": "******", "enableRateLimit": True }) param_key = '' param_value = '' allMyTrades = [] while True: myTrades = exchange.fetch_my_trades(symbol='BTC/USD', params={param_key: param_value}) # Handle with pagination ... if exchange.last_response_headers._store.get('cb-after'): param_key = 'after' param_value = exchange.last_response_headers._store['cb-after'][1]
# -*- coding: utf-8 -*- 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 # noqa: E402 exchange = ccxt.coinbasepro({ 'apiKey': "YOUR_API_KEY", 'secret': "YOUR_SECRET", 'password': '******', 'verbose': True, # switch it to False if you don't want the HTTP log }) # move to sandbox exchange.urls['api'] = exchange.urls['test'] print(exchange.fetch_balance())
def create_exchanges(): """ instantiate the markets to include more exchanges use this function. new exchanges need to be hand-coded here """ coinbasepro = ccxt.coinbasepro({ 'apiKey': api_keys.coinbasepro['apiKey'], 'secret': api_keys.coinbasepro['secret'], 'enableRateLimit': True, }) cex = ccxt.cex({ 'apiKey': api_keys.cex['apiKey'], 'secret': api_keys.cex['secret'], 'enableRateLimit': True, }) poloniex = ccxt.poloniex({ 'apiKey': api_keys.poloniex['apiKey'], 'secret': api_keys.poloniex['secret'], 'enableRateLimit': True, }) bittrex = ccxt.bittrex({ 'apiKey': api_keys.bittrex['apiKey'], 'secret': api_keys.bittrex['secret'], 'enableRateLimit': True, }) binance = ccxt.binance({ 'apiKey': api_keys.binance['apiKey'], 'secret': api_keys.binance['secret'], 'enableRateLimit': True, }) bitfinex = ccxt.bitfinex({ 'apiKey': api_keys.bitfinex['apiKey'], 'secret': api_keys.bitfinex['secret'], 'enableRateLimit': True, }) kucoin = ccxt.kucoin({ 'apiKey': api_keys.kucoin['apiKey'], 'secret': api_keys.kucoin['secret'], 'enableRateLimit': True, }) kraken = ccxt.kraken({ 'apiKey': api_keys.kraken['apiKey'], 'secret': api_keys.kraken['secret'], 'enableRateLimit': True, 'options': { # ←--------------------- inside 'options' subkey 'fetchMinOrderAmounts': False, # ←---------- set to False } }) bitmex = ccxt.bitmex({ 'apiKey': api_keys.bitmex['apiKey'], 'secret': api_keys.bitmex['secret'], 'enableRateLimit': True, }) okex = ccxt.okex({ 'apiKey': api_keys.okex['apiKey'], 'secret': api_keys.okex['secret'], 'enableRateLimit': True, }) exchanges = [ coinbasepro, cex, poloniex, bittrex, binance, bitfinex, kucoin, kraken, okex, bitmex ] return exchanges
import asciichart # ----------------------------------------------------------------------------- this_folder = os.path.dirname(os.path.abspath(__file__)) root_folder = os.path.dirname(os.path.dirname(this_folder)) sys.path.append(root_folder + '/python') sys.path.append(this_folder) # ----------------------------------------------------------------------------- import ccxt # noqa: E402 # ----------------------------------------------------------------------------- binance = ccxt.coinbasepro() symbol = 'BTC/USD' timeframe = '1h' # each ohlcv candle is a list of [ timestamp, open, high, low, close, volume ] index = 4 # use close price from each ohlcv candle height = 15 length = 80 def print_chart(exchange, symbol, timeframe): print("\n" + exchange.name + ' ' + symbol + ' ' + timeframe + ' chart:') # get a list of ohlcv candles
from dateutil import parser # API KEYS ZONE BITMEX_API_KEY = '' BITMEX_API_SECRET = '' # SL & TP LEVELS SL_LEVEL = 200 TP_LEVEL = 500 SL2_LEVEL = 100 SL_OFFSET = 60 # TRADE SIZE TRADE_SIZE = 100 exchanges = {'binance': binance(), 'bitstamp': bitstamp(), 'bitfinex': bitfinex(), 'coinbase': coinbasepro(), 'bitmex': bitmex(), 'hitbtc': hitbtc2(), 'kraken': kraken(), 'bittrex': bittrex(), 'huobi': huobipro()} symbols = {'binance': 'BTC/USDC', 'bitstamp': 'BTC/USD', 'bitfinex': 'BTC/USD', 'coinbase': 'BTC/USD', 'bitmex': 'BTC/USD', 'hitbtc': 'BTC/USDT', 'kraken': 'BTC/USD', 'bittrex': 'BTC/USD', 'huobi': 'BTC/USDT'} btmx = bitmex({'apiKey': BITMEX_API_KEY, 'secret': BITMEX_API_SECRET}) new_signal = False hour_closed = False # uncomment for testnet # if 'test' in btmx.urls: # btmx.urls['api'] = btmx.urls['test'] # ←----- switch the base URL to testnet # exchanges['bitmex'].urls['api'] = exchanges['bitmex'].urls['test']
# -*- coding: utf-8 -*- 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 # noqa: E402 exchange = ccxt.coinbasepro({ 'apiKey': "a43edfe629bc5991acc83a536ac6358e", 'secret': "xOvq+iH8NT07TheFB/fmY3GcnMZMwP7Xct9zwWtAZxsCbJh8rxeEe/0BGxfbV2em7P9iqQD7/TJGqmsDO8B/kw==", 'password': '******', 'verbose': True, # switch it to False if you don't want the HTTP log }) # move to sandbox exchange.urls['api'] = exchange.urls['test'] print(exchange.fetch_balance())
MARKETCAP = 'MKTCAP' NPERIODS = 100 TIMEFRAME = 'Day' datetimeStringformat_to_csv = "%d-%m-%Y %H:%M" data_directory = '/Users/ankitaggarwal/Applications/Cryptocurrency Trading System/crypto-analysis/data/' CURR = 'BTC' EXCHANGE = 'CCCAGG' COIN = 'ETH' COIN_LIST = ['BTC', 'ETH'] EXCHANGES = ['Bittrex','Binance'] EXCHANGES = ['Binance'] bittrex_exchange = ccxt.bittrex() binance_exchange = ccxt.binance() coinbasePro = ccxt.coinbasepro() list_of_exchanges = [coinbasePro] def setupExchanges(list_of_exchanges): done = False i=0 #df_markets = pd.DataFrame(markets) #bittrex_market = bittrex_exchange.fetchMarkets() #binance_market = binance_exchange.fetchMarkets() #kucoin_market = kucoin_exchange.fetchMarkets() #list_of_markets = [#bittrex_market, #binance_market # kucoin_market #For kucoin the fetchMarkets function returns different dictionary keys # ] list_of_tuples = []
config.read('config.ini') secret = config['coinbasepro']['secret'] api_key = config['coinbasepro']['api_key'] password = config['coinbasepro']['password'] fiat = config['coinbasepro']['fiat'] crypto = config['coinbasepro']['crypto'] ticker = '{}/{}'.format(crypto, fiat) fee = float(config['coinbasepro']['fee']) delay = int(config['coinbasepro']['delay']) withdraw = bool(config['coinbasepro']['withdraw']) withdrawThreshold = float(config['coinbasepro']['withdrawThreshold']) toAddress = config['coinbasepro']['toAddress'] coinbasepro = ccxt.coinbasepro({ 'apiKey': api_key, 'secret': secret, 'password': password }) def main(): try: while True: try: fiat_balance = float(coinbasepro.fetch_balance()[fiat]['free']) except Exception as e: fiat_balance = -1 print("Failed to retreive fiat balance") print(e) print("#####################") print(datetime.datetime.now())
# coding=utf-8 import ccxt import os ### DISPLAY #### def display(): os.system('clear && figlet "COINBASE"') print('\n') ### ACCOUNT CREDINTIALS #### coinbase_pro = ccxt.coinbasepro({ 'apiKey': '2851606201d8765e5f91a93cd710707b', 'secret': 'DVYqJXYxdaiinH7sTeWsTV5alpYRy2jtT/5P3xFbh96OTuDcVjdmmBKPbQMv7sWuGWQM88Ho9O/L/oIn50Ip1g==', 'password': '******' }) gemini = ccxt.gemini({ 'apiKey': 'master-bkm4AS6XfKmmctFaJ5n1', 'secret': '3q2B8futRKUqmF53eiPf6zK7Gihz' # 'password': '' }) ### TRADING PAIRS ### # trading_pairs = coinbase_pro.load_markets()
def oe_client(self): return ccxt.coinbasepro({'enableRateLimit': True})
import numpy as np import time import datetime from pytz import timezone import cry_arb_evaluator import json dash = '-' * 25 space = ' ' * 2 tz = timezone('EST') kraken = ccxt.kraken({'enableRateLimit': True}) exmo = ccxt.exmo({'enableRateLimit': True}) binance = ccxt.binance({'enableRateLimit': True}) hitbtc = ccxt.hitbtc2({'enableRateLimit': True}) coinbasepro = ccxt.coinbasepro({ 'enableRateLimit': True, }) gemini = ccxt.gemini({ 'enableRateLimit': True, }) bitfinex = ccxt.bitfinex({ 'enableRateLimit': True, }) livecoin = ccxt.livecoin({ 'enableRateLimit': True, }) kucoin = ccxt.kucoin({ 'enableRateLimit': True, }) cex = ccxt.cex({ 'enableRateLimit': True,
def name(name): exchange = ccxt.coinbasepro() BotStrategys = BotStrategy() current_buy_price = 0 candlesticks = [] open_ = [] high = [] low = [] close = [] start_time = time.time() length_bear = 0 length_bull = 0 period = 60 developingcandle = candle_info(period) utility = trading_utilities() timer = 0 count=0 my_time = [] fama = [] mama = [] hl2 = [] history = exchange.fetch_ohlcv(name,'1m') j = 0 accounts = account() plot = graphing() push = push_notification() current_high = 0 bought = 0 for i in range(len(history)-1,0,-1): my_time.append(history[i][0]/1000.00) open_.append(history[i][1]) high.append(history[i][2]) low.append(history[i][3]) close.append(history[i][4]) candlesticks.append([history[i][0]/1000.00,history[i][1],history[i][2],history[i][3],history[i][4]]) hl2.append((history[i][2]+history[i][3])/2.0) j+=1 while True: try: ticks = float(((exchange.fetchTicker(name)['last']))) #print(name,ticks) except: # print("Error Occured") # print("Attempting to reconnect...") pass #Builds the acutal candles developingcandle.candle_tick(ticks) #Determines the difference in percent between current price and highest price if current_high < ticks: current_high = ticks #print(round((ticks-current_high)/current_high,4)) #Once Time period has passed a finished candle is added on to stack if developingcandle.isClosed(): #Grabs OHLC values from candle_info class o,h,l,c = developingcandle.candle_tick(ticks) #Records current time and adds to list t = time.time() my_time.append(t) #adds tOHLC to candle list candlesticks.append([t,o,h,l,c]) #Creates ability to access all values individually open_.append(o) high.append(h) low.append(l) close.append(c) #like an average for candle hl2.append((h+l)/2.0) #clears candle_info class developingcandle = candle_info(period) print("Open: "+str(o)+" High: "+str(h)+" Low: "+str(l)+" Close: "+str(c)+" current: "+str(ticks)) #creates arrays to be used with ta-lib indicators in their desired format open2 = np.array(open_,dtype=float) high2 = np.array(close,dtype=float) low2 = np.array(low,dtype=float) close2 = np.array(close,dtype=float) my_time2 = np.array(my_time,dtype=float) hl2_ = np.array(hl2,dtype=float) #calls to candles_types class where all candle patterns are and returns list of candles names that are present candles_info = candles_types(open2,high2,low2,close2) bull,bear = candles_info.all_candles() #every 5 candles idealInvestment strategy has a chance to buy or sell if(count==0): BotStrategys.idealInvested(close, ticks,open2,high2,low2,close2) count+=1 #change 5 to how frenquently buy/sell orders are desired if(count>5): count=0 timer = 1 #only keeps 50 candles and deletes extra if len(open_)>50: del open_[0] del high[0] del low[0] del close[0] del my_time[0] del candlesticks[0] # # # if timer == 1 and time.time() > start_time + period: # open2 = np.array(open_,dtype=float) # high2 = np.array(close,dtype=float) # low2 = np.array(low,dtype=float) # close2 = np.array(close,dtype=float) # candles_info = candles_types(open2,high2,low2,close2) # bull,bear = candles_info.all_candles() # mama1 = np.array(mama,dtype=float) # fama1 = np.array(fama,dtype=float) #Put code to sleep to ensure API ping does not exceed rate limit time.sleep(exchange.rateLimit/1000)
root = os.path.dirname( os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) sys.path.append(root + '/python') import ccxt # noqa: E402 # ----------------------------------------------------------------------------- # common constants msec = 1000 minute = 60 * msec hold = 30 # ----------------------------------------------------------------------------- exchange = ccxt.coinbasepro() # ----------------------------------------------------------------------------- from_datetime = '2017-09-01 00:00:00' from_timestamp = exchange.parse8601(from_datetime) # ----------------------------------------------------------------------------- now = exchange.milliseconds() # ----------------------------------------------------------------------------- data = [] while from_timestamp < now:
sys.path.append(root + '/python') import ccxt # noqa: E402 # ----------------------------------------------------------------------------- # common constants msec = 1000 minute = 60 * msec hold = 30 # ----------------------------------------------------------------------------- exchange = ccxt.coinbasepro({ 'rateLimit': 3000, 'enableRateLimit': True, # 'verbose': True, }) # ----------------------------------------------------------------------------- from_datetime = '2017-09-01 00:00:00' from_timestamp = exchange.parse8601(from_datetime) # ----------------------------------------------------------------------------- now = exchange.milliseconds() # ----------------------------------------------------------------------------- data = []
# SL & TP LEVELS SL_LEVEL = 300 TP_LEVEL = 500 SL2_LEVEL = 70 SL_OFFSET = 70 # TRADE SIZE TRADE_SIZE = 200 # PERCENTAGE VOL ABOVE AVG pavg = 100 exchanges = { 'binance': binance(), 'bitfinex': bitfinex(), 'coinbase': coinbasepro(), 'bitmex': bitmex(), 'hitbtc': hitbtc2(), 'kraken': kraken(), 'bittrex': bittrex(), 'huobi': huobipro() } symbols = { 'binance': 'BTC/USDC', 'bitfinex': 'BTC/USD', 'coinbase': 'BTC/USD', 'bitmex': 'BTC/USD', 'hitbtc': 'BTC/USDT', 'kraken': 'BTC/USD', 'bittrex': 'BTC/USD', 'huobi': 'BTC/USDT'
print(bPairs) cTKraken = partial(containsTwo, list(map(KRAKEN_MAP.get, CURRENCIES))) K = ccxt.kraken() kInfo = K.publicGetAssetPairs()['result'] kRawPairs = [kInfo[entry]['altname'] for entry in kInfo] kTradeablePairs = list(filter(cTKraken, kRawPairs)) kTradeablePairs = list(filter(lambda x: '.d' not in x, kTradeablePairs)) print(kTradeablePairs) sPKraken = partial(splitPair, list(map(KRAKEN_MAP.get, CURRENCIES))) kPairs = list(map(sPKraken, kTradeablePairs)) print(kPairs) # Coinbase C = ccxt.coinbasepro() cInfo = C.publicGetProducts() cRawPairs = [entry['id'].replace('-', '') for entry in cInfo] cTradeablePairs = list(filter(cT, cRawPairs)) print(cTradeablePairs) cPairs = list(map(sP, cTradeablePairs)) print(cPairs) # Bitfinex bitfinex = ccxt.bitfinex() bitfinexInfo = bitfinex.publicGetSymbolsDetails() bitfinexRawPairs = [entry['pair'].upper() for entry in bitfinexInfo] bitfinexTradeablePairs = list(filter(cT, bitfinexRawPairs)) print(bitfinexTradeablePairs)
""" Authorization for Coinbase Pro API using the ccxt packages """ import ccxt import config exchange = ccxt.coinbasepro({ 'apiKey': config.CBP_API_KEY, 'secret': config.CBP_SECRET_KEY, 'password': config.CBP_PW })
# indodax # ############### exchanges['indodax'] = {} exchanges['indodax']['init'] = ccxt.indodax(config.indodax) exchanges['indodax']['limit'] = 500 exchanges['indodax']['currency'] = 'idr' exchanges['indodax']['name'] = 'indodax' exchanges['indodax']['name_trader'] = 'indodax' ############### # Coinbasepro GBP # ############### exchanges['coinbasepro_gbp'] = {} exchanges['coinbasepro_gbp']['init'] = ccxt.coinbasepro(config.gdax_gbp) exchanges['coinbasepro_gbp']['limit'] = 500 exchanges['coinbasepro_gbp']['currency'] = 'gbp' exchanges['coinbasepro_gbp']['name'] = 'coinbasepro' exchanges['coinbasepro_gbp']['name_trader'] = 'coinbasepro_gbp' ############### # Coinbasepro EUR # ############### exchanges['coinbasepro_eur'] = {} exchanges['coinbasepro_eur']['init'] = ccxt.coinbasepro(config.gdax_eur) exchanges['coinbasepro_eur']['limit'] = 500 exchanges['coinbasepro_eur']['currency'] = 'eur' exchanges['coinbasepro_eur']['name'] = 'coinbasepro' exchanges['coinbasepro_eur']['name_trader'] = 'coinbasepro_eur'
return style(s, '\033[1m') def underline(s): return style(s, '\033[4m') def dump(*args): print(' '.join([str(arg) for arg in args])) # instantiate exchanges coinbasepro = ccxt.coinbasepro({ 'apiKey': '92560ffae9b8a01d012726c698bcb2f1', # standard 'secret': '9aHjPmW+EtRRKN/OiZGjXh8OxyThnDL4mMDre4Ghvn8wjMniAr5jdEZJLN/knW6FHeQyiz3dPIL5ytnF0Y6Xwg==', 'password': '******', # requires a password! }) coinbasepro.urls['api'] = coinbasepro.urls['test'] # use the testnet hitbtc = ccxt.hitbtc({ 'apiKey': '18339694544745d9357f9e7c0f7c41bb', 'secret': '8340a60fb4e9fc73a169c26c7a7926f5', }) try: # fetch account balance from the exchange coinbaseproBalance = coinbasepro.fetch_balance() # output the result