def __init__(self, quantity, key, secret): self.quantity = quantity self.commission = .2 from bitfinex.client import Client, TradeClient self.privateWrapper = TradeClient(key, secret) self.publicWrapper = Client()
def paper_trade(): try: client = Client() symbols = client.symbols() symbol = 'btcusd' lastprice = client.ticker(symbol)['last_price'] print(lastprice) threading.Timer(0.5, paper_trade).start() except: print('couldnt get price data') threading.Timer(0.5, paper_trade).start()
def getprices(self): try: client = Client() symbols = client.symbols() btcsymbol = 'btc' ethsymbol = 'eth' symbol = 'btcusd' lastprice = client.ticker(symbol)['last_price'] btcresponse = client.lends(btcsymbol) ethresponse = client.lends(ethsymbol) self.newbtclent = float(btcresponse[0]['amount_lent']) self.newbtcused = float(btcresponse[0]['amount_used']) self.newethlent = float(ethresponse[0]['amount_lent']) self.newethused = float(ethresponse[0]['amount_used']) self.keepgoing = 1 except: print('unable to get price data')
def setUp(self): self.client = Client()
from sqlalchemy import * import time import numpy as np from decimal import Decimal # using bitfinex APIs to get today's_ticker from bitfinex.client import Client, TradeClient client = Client() trade = TradeClient('K4HJultQmdvroWCnNy5OMcXx7QfGoQgZw0vrkWmuV1Y', 'dFt4tsMFszh2vTGGvHqFEP3fkaaSniJ4zDA4pSWyJOM') # we are inporting the Databse that is being created by bitfinex-boat engine = create_engine('sqlite:////home/metal-machine/Desktop/all_ticker.db') metadata = MetaData(engine) tickers = Table('ticker', metadata, autoload=True) def find_nearest(array, value): """ gets the numpy array and timestamp as input and retunrs the nearest value""" idx = np.abs(array - value).argmin() return array[idx] def ohlc_past(hours): """This function returns the seconds as input and retrun the required ohlc_4""" seconds = 3600 * hours # converting hours into seconds time_delta = float('{:7f}'.format(time.time() - seconds)) time_stamp = tickers.select(tickers.c.timestamp) timestamp_array = np.array([i[1] for i in time_stamp.execute()])
import logging import gdax import requests from random import * from bitfinex.client import Client from bittrex.bittrex import Bittrex # Enable logging logging.basicConfig( format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO) logger = logging.getLogger(__name__) gdax_client = gdax.PublicClient() bitf_client = Client() bittrex_client = Bittrex(None, None) def help(bot, update): result = "Supported Commands\n" result = result + "(GDAX Price Lookup) /gdax <FIRST-H-PAIR> <SECOND-H-PAIR>\n" result = result + "(Bittrex Price Lookup) /btrx <FIRST-H-PAIR> <SECOND-H-PAIR>\n" result = result + "(Bitfinex Price Lookup) /bitf <FIRST-H-PAIR> <SECOND-H-PAIR>\n" result = result + "(Kraken Price Lookup) /krkn <FIRST-H-PAIR> <Second-H-PAIR>\n" result = result + "(Random Coin BTRX) /rcoin\n" result = result + "Example: /gdax ETH USD\n" update.message.reply_text(result) def gdax(bot, update):
from bitfinex.client import Client client = Client('apiKey','apiSecret') orders=[] for price in range(3, 6): print (price) payload = { "symbol": 'IOTUSD', "amount": '100', "price": str(price), "exchange": 'bitfinex', "side": 'buy', "type": 'limit' } orders.append(payload) apiResponse = client.place_multiple_orders(orders) print(apiResponse)
def callback_inline1(call): if call.data == "Poloniex": x = (polo('returnTicker')['BTC_ETH']['highestBid']) y = (polo('returnTicker')['USDT_REP']['highestBid']) z = (polo('returnTicker')['BTC_DOGE']['highestBid']) x1 = (polo('returnTicker')['BTC_XBC']['highestBid']) y2 = (polo('returnTicker')['ETH_ETC']['highestBid']) z2 = (polo('returnTicker')['BTC_MAID']['highestBid']) mes = '<b>BTC_ETH</b>: ' + str(x) + '\n<b>USDT_REP</b>: ' + str( y) + '<b>\nBTC_DOGE</b>: ' + str(z) + '<b>\nBTC_XBC</b>: ' + str( x1) + '<b>\nETH_ETC</b>: ' + str( y2) + '<b>\nBTC_MAID</b>: ' + str(z2) z = bot.send_message(call.message.chat.id, mes, parse_mode='HTML') if call.data == "Kraken": url = 'https://api.kraken.com/0/public/Ticker?pair=' XXBTZUSD = url + 'XXBTZUSD' r = requests.get(XXBTZUSD) x = r.json() h = [] for i in x['result']['XXBTZUSD'].keys(): h.append(x['result']['XXBTZUSD'][i]) z = [] for i in range(0, len(h)): try: w = '\n'.join(h[i]) z.append(w) except: print(1) w = '\n'.join(z) mes = '<b>XXBTZUSD</b>: ' + str(w) z = bot.send_message(call.message.chat.id, mes, parse_mode='HTML') if call.data == "Bitfinex": client = Client() symbols = client.symbols() btcusd = client.ticker(symbols[0]) ltcusd = client.ticker(symbols[1]) ltcbtc = client.ticker(symbols[2]) ethusd = client.ticker(symbols[3]) ethbtc = client.ticker(symbols[4]) etcbtc = client.ticker(symbols[5]) etcusd = client.ticker(symbols[6]) rrtusd = client.ticker(symbols[7]) mes = '<b>btc_usd</b>: ' + str( btcusd['last_price']) + '\n<b>ltc_usd</b>: ' + str( ltcusd['last_price']) + '<b>\nltc_btc</b>: ' + str( ltcbtc['last_price']) + '<b>\neth_usd</b>: ' + str( ethusd['last_price']) + '<b>\neth_btc</b>: ' + str( ethbtc['last_price']) + '<b>\netc_btc</b>: ' + str( etcbtc['last_price'] ) + '<b>\netc_btc</b>: ' + str( etcusd['last_price'] ) + '<b>\nrrt_usd=</b>: ' + str( rrtusd['last_price']) z = bot.send_message(call.message.chat.id, mes, parse_mode='HTML') if call.data == "Bittrex": url = 'https://bittrex.com/api/v1.1/public/getmarketsummary?market=btc-ltc' z = [] r = requests.get(url) x = r.json() for i in x['result'][0]: e = x['result'][0][i] k = str(i) + ' : ' + str(e) z.append(k) w = '\n'.join(z) mes = '<b>btc-ltc</b>: ' + str(w) z = bot.send_message(call.message.chat.id, mes, parse_mode='HTML') if call.data == "Yobit": url = 'https://yobit.net/api/2/ltc_btc/ticker' feed = requests.get(url) x = feed.json() z = [] for i in x['ticker']: e = x['ticker'][i] k = str(i) + ' : ' + str(e) z.append(k) w = '\n'.join(z) mes = '<b>ltc_btc</b>: ' + str(w) z = bot.send_message(call.message.chat.id, mes, parse_mode='HTML')