def fetch_data(symbol, min_interval, points): # Enter Binance keys exchange = ccxt.binanceus({ 'apiKey': crypto_config.binance_codes['key'], 'secret': crypto_config.binance_codes['secret'] }) # Load markets markets = exchange.load_markets() print('Markets loaded.') # Prepare arguments for data retrieval with ccxt library tf = str(min_interval) + 'm' if points > 1000: points = 1000 # Get Cardano data, 5/15min interval, train for past 6 months/180 days/4,320 hours/259,200 minutes/51,840 5min # intervals or 17,280 15min intervals ada_data_raw = exchange.fetch_ohlcv(symbol, timeframe=tf, limit=points) print('Data obtained for {0} at {1} minute intervals'.format( symbol, min_interval)) # Convert to pandas data frame ada_data_pandas = pd.DataFrame( ada_data_raw, columns=['unix_time', 'c_open', 'high', 'low', 'c_close', 'volume']) return ada_data_pandas
def __init__(self): self.exchanges = { 'binanceus': ccxt.binanceus(), 'bittrex': ccxt.bittrex(), # 'coinbase': ccxt.coinbase(), # coinbase has most currency pairs, by like 3 times the next highest, consider removing. Also coinbase limits API to 3-6 calls/sec 'gemini': ccxt.gemini(), # 'kraken': ccxt.kraken(), # updating their API 'livecoin': ccxt.livecoin(), 'theocean': ccxt.theocean(), # 'okex': ccxt.okex(), #Canadian, does not allow us 'bitmart': ccxt.bitmart(), # 'cex': ccxt.cex(), # EU # 'bitbay': ccxt.bitbay(), # EU, Updating API # 'bcex': ccxt.bcex(), #candian exch, their API is updating # 'bitbay': ccxt.bitbay(), 'paymium': ccxt.paymium(), 'binance': ccxt.binance(), 'okcoin': ccxt.okcoin(), 'bitfinex': ccxt.bitfinex() # non-US } # creates a markets variable in each exchange instance. ex. exchages[0].markets will return markets self.loadMarkets() # these are tickers available on exchnage, but not US customers, or don't allow deposits/withdrawals self.unavailableTickers = { 'binanceus': [], 'bittrex': [ 'LUNA/BTC', 'ABBC/BTC', 'Capricoin/BTC', 'DRGN/BTC', 'CVT/BTC', 'NXT/BTC' ], # 'coinbase': [], 'gemini': [], # 'kraken': [], # Updating their API 'livecoin': [ 'BTM/BTC', 'BTM/ETH', 'NANO/BTC', 'NANO/ETH', 'XTZ/BTC', 'XTZ/ETH', 'THETA/BTC', 'THETA/ETH', 'ABBC/BTC', 'ABBC/ETH', 'AE/BTC', 'AE/ETH', 'IOST/BTC', 'IOST/ETH' ], 'theocean': [], # 'okex': ['AET/ETH','AET/BTC'], # does not allow US, but allows canadian 'bitmart': [], # 'cex': [], # 'bitbay': [], # 'bcex': [], #candian exch, their API is updating 'bitbay': [], 'paymium': [], 'binance': [], 'okcoin': [], 'bitfinex': [] } self.commonTickers = self.getCommonTickers() # then only call fetch_tickers for common_tickers between exchanges self.minProfit = 1 # percent profit # in USD NOTE: still need to incorporate this. I think coinmarketcap API has a quick conversion call self.minVolume = 200 self.txfrCosts = []
# Anthony Peters, Franz Nastor, Peter Radev, Jack Hudanick, Tim Abbenhaus, Collin Jones import ccxt import numpy as np import networkx as nx import logic from firebase import firebase import routes import matplotlib.pyplot as plt # Loads in our Exchange # Loads in currency_pairs and adds them to a list with BTC/USD as last item # Creates Graph exchange = ccxt.binanceus() exchange.load_markets() currency_pairs = exchange.symbols currency_pairs.sort() G = nx.DiGraph() # Loads ask and bid price holder for the exchange and currency pairs ask = np.zeros(5) bid = np.zeros(5) # Replace currency in the list function substring = 'USDT' substring2 = 'BUSD' substring3 = '/BTC' logic.replace_currency(substring, currency_pairs)
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"):
import ccxt import config import schedule import pandas as pd pd.set_option('display.max_rows', None) import warnings warnings.filterwarnings('ignore') import numpy as np from datetime import datetime import time exchange = ccxt.binanceus({ "apiKey": config.BINANCE_API_KEY, "secret": config.BINANCE_SECRET_KEY }) def tr(data): data['previous_close'] = data['close'].shift(1) data['high-low'] = abs(data['high'] - data['low']) data['high-pc'] = abs(data['high'] - data['previous_close']) data['low-pc'] = abs(data['low'] - data['previous_close']) tr = data[['high-low', 'high-pc', 'low-pc']].max(axis=1) return tr def atr(data, period):