def __init__(self): Exchange.__init__(self, "KRAKEN") self.conn = Connection() self.api = API() self.price_decimals = dict() self.lot_decimals = dict() self.api.load_key('kraken.keys') self.pair_name_map = {} with open('kraken_info.json') as f: self.tickers = json.loads(f.read())['result'].items() self.symbols = [ 'USD', 'BTC', 'ETH', 'LTC', 'BCH', 'XMR', 'XRP', 'XLM', 'ADA', 'ATOM' ] for pair, info in self.tickers: if '.' in pair: # some duplicate entries have a period, unsure why continue token = symbol_from_kraken(info['base']) currency = symbol_from_kraken(info['quote']) if token in self.symbols and currency in self.symbols: uniform_ticker = "%s-%s" % (token, currency) self.pair_name_map[uniform_ticker] = pair self.fees[uniform_ticker] = FEES[self.name].taker self.price_decimals[uniform_ticker] = info['pair_decimals'] self.lot_decimals[uniform_ticker] = info['lot_decimals']
def __init__(self, manager): Exchange.__init__(self, manager) self.name = 'okcoin' self.tick_url = 'https://www.okcoin.com/api/ticker.do?symbol={}' self.depth_url = 'https://www.okcoin.com/api/depth.do?symbol={}' self.trade_url = 'https://www.okcoin.com/api/trades.do?symbol={}' self.tick_query = '''INSERT IGNORE INTO bitcoin_ticker (exchange, ticker, requested, received, bid, ask, low, high, last, vol) VALUES ('{}', '{}', {}, {}, {}, {}, {}, {}, {}, {})'''
def __init__(self, manager): Exchange.__init__(self, manager) self.name = 'chbtc' self.tick_url = 'http://api.chbtc.com/data/ticker' self.depth_url = 'http://api.chbtc.com/data/depth' self.trade_url = 'http://api.chbtc.com/data/getTrades' self.tick_query = '''INSERT IGNORE INTO bitcoin_ticker (exchange, ticker, requested, received, bid, ask, low, high, last, vol) VALUES ('{}', '{}', {}, {}, {}, {}, {}, {}, {}, {})'''
def __init__(self): Exchange.__init__(self) self.name = 'Bitfinex' self.trading_fee = 0.0015 self.transfer_fee = 0 self.logger = logging.getLogger('BitBot.Bitfinex')
def __init__(self, manager): Exchange.__init__(self, manager) self.name = 'bitstamp' self.tick_url = 'https://www.bitstamp.net/api/ticker/' self.depth_url = 'https://www.bitstamp.net/api/order_book/' self.trade_url = 'http://www.bitstamp.net/api/transactions?time=minute' self.tick_interval = 2 self.depth_interval = 20
def __init__(self, manager): Exchange.__init__(self, manager) self.name = 'mtgox' self.tick_url = 'http://data.mtgox.com/api/1/{}/ticker' self.depth_url = 'http://data.mtgox.com/api/2/{}/money/depth/fetch' self.trade_url = 'https://data.mtgox.com/api/2/{}/money/trades' self.depth_query = '''INSERT IGNORE INTO {} (ticker, requested, received, timestamp, bid, ask, bids, asks) VALUES ('{}', {}, {}, {}, {}, {}, '{}', '{}')''' self.depth_interval = 15
def __init__(self, manager): Exchange.__init__(self, manager) self.name = 'fxbtc' self.depth_interval = 15 self.tick_interval = 2 self.tick_url = 'https://data.fxbtc.com/api?op=query_ticker&symbol={}' self.depth_url = 'https://data.fxbtc.com/api?op=query_depth&symbol={}' self.trade_url = 'https://data.fxbtc.com/api?op=query_history_trades&symbol={}' self.tick_query = '''INSERT IGNORE INTO bitcoin_ticker (exchange, ticker, requested, received, bid, ask, low, high, last, vol)
def __init__(self, manager): Exchange.__init__(self, manager) self.trade_interval = 10 self.depth_interval = 10 self.name = 'btcchina' self.tick_url = 'https://data.btcchina.com/data/ticker?market={}' self.depth_url = 'https://data.btcchina.com/data/orderbook?market={}' self.trade_url = 'http://data.btcchina.com/data/historydata?market={}' self.tick_query = '''INSERT IGNORE INTO bitcoin_ticker (exchange, ticker, requested, received, bid, ask, low, high, last, vol) VALUES ('{}', '{}', {}, {}, {}, {}, {}, {}, {}, {})'''
def __init__(self, manager): Exchange.__init__(self, manager) self.depth_interval = 10 self.name = 'bitfinex' self.tick_url = 'https://api.bitfinex.com/v1/ticker/{}' self.depth_url = 'https://api.bitfinex.com/v1/book/{}' self.trade_url = 'https://api.bitfinex.com/v1/trades/{}' self.tick_query= '''INSERT IGNORE INTO bitcoin_ticker (exchange, ticker, requested, received, timestamp, bid, ask, last) VALUES ('{}', '{}', {}, {}, {}, {}, {}, {})''' self.last_trade_query = '''SELECT MAX(timestamp) FROM {} WHERE ticker = '{}' '''
def __init__(self): Exchange.__init__(self, 'BITFLYER') with open('bitflyer.keys') as secrets_file: secrets = json.load(secrets_file) self.api = API(str(secrets['key']), str(secrets['secret']), timeout=5) self.symbols = ['USD', 'BTC'] self.fees['BTC-USD'] = FEES[self.name].taker
def __init__(self): Exchange.__init__(self, 'ITBIT') with open('itbit.keys') as secrets_file: secrets = json.load(secrets_file) self.api = itBitApiConnection(secrets['key'], secrets['secret'], secrets['userId']) self.symbols = ['USD', 'BTC', 'ETH'] self.fees['BTC-USD'] = FEES[self.name].taker self.fees['ETH-USD'] = FEES[self.name].taker wallets = self.api.get_all_wallets().json() assert (len(wallets) == 1) self.wallet_id = self.api.get_all_wallets().json()[0]['id']
def __init__(self): Exchange.__init__(self, 'GDAX') with open('gdax.keys') as secrets_file: secrets = json.load(secrets_file) self.api = gdax.AuthenticatedClient(secrets['key'], secrets['secret'], secrets['passphrase']) self.symbols = ['USD', 'BTC', 'ETH', 'LTC', 'BCH'] for ticker in PAIRS: if ticker.startswith('LTC') or ticker.startswith('ETH'): self.fees[ticker] = Decimal('0.003') else: self.fees[ticker] = FEES[self.name].taker
def __init__(self): Exchange.__init__(self, 'BITSTAMP') with open('bitstamp.keys') as secrets_file: secrets = json.load(secrets_file) self.api = bitstamp.client.Trading(username=secrets['username'], key=secrets['key'], secret=secrets['secret']) self.symbols = ['USD', 'BTC', 'ETH', 'LTC', 'BCH', 'XRP'] for ticker, info in PAIRS.iteritems(): if info['token'] in self.symbols and info[ 'currency'] in self.symbols: # TODO can pull fees from account info call self.fees[ticker] = FEES[self.name].taker
def __init__(self): Exchange.__init__(self, "BITTREX") with open("bittrex.keys") as secrets_file: secrets = json.load(secrets_file) self.api = api(secrets['key'], secrets['secret']) self.symbols = ['BTC','ETH','LTC','BAT','CVC','BCH','DNT','RCN','XMR','ADA','XRP','MANA','XLM','ZRX','PART'] self.markets = self.api.get_markets() for market in self.markets: currency = symbol_from_bittrex(market['BaseCurrency']) token = symbol_from_bittrex(market['MarketCurrency']) uniform_ticker = "%s-%s" % (token,currency) if token in self.symbols and currency in self.symbols: self.fees[uniform_ticker] = FEES[self.name].taker
def __init__(self): Exchange.__init__(self, 'BINANCE') with open('binance.keys', 'r') as api_key: self.api = api(api_key.readline().strip(), api_key.readline().strip()) self.symbols = [ 'BTC', 'ETH', 'LTC', 'DNT', 'ZRX', 'KNC', 'RCN', 'XMR', 'BCH', 'BAT', 'ADA', 'XRP', 'MANA', 'XLM', 'BNB', 'CVC', 'ATOM' ] self.fees = {} account_info = self.api.account_info() for ticker in PAIRS: self.fees[ticker] = FEES[self.name].taker
def __init__(self): Exchange.__init__(self, "POLO") with open("poloniex.keys") as secrets_file: secrets = json.load(secrets_file) self.tapi = api(bytearray(secrets['key'], 'utf-8'), bytearray(secrets['secret'], 'utf-8')) with open(INFO_CACHE_PATH) as f: self.tickers = json.loads(f.read()) self.symbols = [ 'BTC', 'ETH', 'LTC', 'BCH', 'ZRX', 'CVC', 'XMR', 'XRP', 'XLM', 'KNC', 'BAT', 'MANA', 'ATOM' ] for ticker in self.tickers.keys(): (token, currency) = parse_ticker(ticker) if token in self.symbols and currency in self.symbols: uniform_ticker = "%s-%s" % (token, currency) self.fees[uniform_ticker] = FEES[self.name].taker
def __init__(self): Exchange.__init__(self, "LIQUI") self.conn = liqui.connection handler = liqui.KeyHandler("liqui.keys", resaveOnDeletion=True) self.tapi = liqui.TradeAPI(handler.getKeys()[0], handler) self.prices = {} self.symbols = [ 'BTC', 'ETH', 'GNT', 'ICN', 'LTC', 'MLN', 'REP', 'USDT', 'TRST', 'WAVES', 'RLC', 'DASH', 'BAT', 'ANT', 'QRL', 'BNT', 'SNGLS', 'SNT', 'STORJ', 'ADX', 'OMG', 'CVC', 'DGD', 'BCC', 'ZRX', 'DNT', 'OAX', 'KNC', 'SALT', 'ENG', 'AST', 'REQ', 'MANA', 'AION' ] self.tickers = liqui.common.market_info for ticker, info in self.tickers['pairs'].items(): (token, currency) = ticker.upper().split('_') uniform_ticker = "%s-%s" % (token, currency) if token in self.symbols and currency in self.symbols: self.fees[uniform_ticker] = FEES[self.name].taker
def __init__(self, order): self.cfg = json.load(open('config.json')) self.order = order self.stopLossPrice = hlp.roundPrice( float(self.order['buyPrice']) * (1 - (float(self.cfg['stopLossPercentage']) / 100)), self.order['tickSize']) self.minSellPrice = hlp.roundPrice( float(self.order['buyPrice']) * (1 + (float(self.cfg['minProfitPercentage']) / 100)), self.order['tickSize']) self.maxSellPrice = hlp.roundPrice( float(self.order['buyPrice']) * (1 + (float(self.cfg['maxProfitPercentage']) / 100)), self.order['tickSize']) self.trailDeviation = 1 - (float(self.cfg['trailDeviation']) / 100) Exchange.__init__(self) Thread.__init__(self) self.daemon = True self.start()
def __init__(self): Exchange.__init__(self) self.name = 'Btce' self.trading_fee = 0.002 self.transfer_fee = 0.001 self.nonce = 1 self.logger = logging.getLogger('BitBot.BTCE') #Find the correct nonce parameter print 'Computing correct nonce parameter' params = { 'method' : 'getInfo', 'nonce' : self.nonce } params = urllib.urlencode(params) H = hmac.new(keys.BTCE_API_SECRET_KEY, digestmod=hashlib.sha512) H.update(params) sign = H.hexdigest() headers = { 'Content-type' : 'application/x-www-form-urlencoded', 'Key' : keys.BTCE_API_KEY, 'Sign' : sign } req = urllib2.Request(BTCE.private_url, params, headers) res = urllib2.urlopen(req) res = json.load(res) error = res['error'] error = error.split(' ') for word in error: if 'key' in word: n = word.replace('key', '') n = n.replace(':', '') n = n.replace(',', '') self.nonce = int(n)
def __init__(self, manager): Exchange.__init__(self, manager) self.name = '796' self.tick_query = '''INSERT IGNORE INTO bitcoin_ticker (exchange, ticker, requested, received, bid, ask, low, high, last, vol) VALUES ('{}', '{}', {}, {}, {}, {}, {}, {}, {}, {})''' self.depth_interval = 10
def __init__(self): Exchange.__init__(self, exchange='exchange-001', type='fanout') self.bind()
def __init__(self): Exchange.__init__(self) self.cbx_extern = CampBX(keys.CAMPBX_LOGIN, keys.CAMPBX_PASS) self.cbx_extern.debug_mode(True) self.name = 'CampBX'