def _load_gateio_ticker_data(symbol): gateio = ccxt.gateio({'verbose': True}) markets = gateio.load_markets() ticker = gateio.fetch_ticker(symbol) ticker.pop('info') ticker2 = {} ticker2['symbol'] = ticker.pop('symbol') ticker2['priceChange'] = ticker.pop('change') ticker2['priceChangePercent'] = ticker.pop('percentage') ticker2['weightedAvgPrice'] = ticker.pop('vwap') ticker2['prevClosePrice'] = ticker.pop('previousClose') ticker2['lastPrice'] = ticker.pop('last') ticker2['lastQty'] = 'none' ticker2['bidPrice'] = ticker.pop('bid') ticker2['bidQty'] = ticker.pop('bidVolume') ticker2['askPrice'] = ticker.pop('ask') ticker2['askQty'] = ticker.pop('askVolume') ticker2['openPrice'] = ticker.pop('open') ticker2['highPrice'] = ticker.pop('high') ticker2['lowPrice'] = ticker.pop('low') ticker2['volume'] = ticker.pop('baseVolume') ticker2['quoteVolume'] = ticker.pop('quoteVolume') ticker2['openTime'] = ticker.pop('datetime') ticker2['closeTime'] = ticker.pop('timestamp') ticker2['firstId'] = 'none' ticker2['lastId'] = 'none' ticker2['count'] = 'none' ticker = ticker2 return ticker
def gateioData(): betime = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())) try: gateio = ccxt.gateio() coindata = list(gateio.fetch_tickers().values()) columns = ['symbol', 'ask', 'bid', 'close', 'last', 'high', 'low', 'info', 'datetime'] df = pd.DataFrame(coindata) df = df[columns] df['exchange'] = 'gateio' df['vol'] = [i['baseVolume'] for i in df['info']] df['datetime'] = [i.replace('T', ' ') for i in df['datetime']] df['datetime'] = [i.replace('Z', '') for i in df['datetime']] df = df.drop(['info'], axis=1) df['basecurrency'] = list(i.split('/')[0] for i in df['symbol']) df['quotcurrency'] = list(i.split('/')[1] for i in df['symbol']) df['createtime'] = starttime df['codeid'] = 2 try: engine = create_engine("mysql+pymysql://coin:[email protected]:3306/coindata?charset=utf8") df.to_sql('coindata_tickers', con=engine, if_exists='append', index=False) except: with open('coindataerr.log','a') as f: f.write('%s:gateio数据入库失败!\n' % betime) pass except: with open('coindataerr.log','a') as f: f.write('%s:gateio数据获取失败!\n' % betime) pass
def gateioData(): gateio = ccxt.gateio() coindata = list(gateio.fetch_tickers().values()) columns = ['ask', 'bid', 'close', 'high', 'low', 'last', 'symbol', 'average', 'baseVolume', 'timestamp'] df = pd.DataFrame(coindata) df = df[columns] df['exchange'] = 'gateio' df['createtime'] = starttime df['baseCurrency'] = list(i.split('/')[0] for i in df['symbol']) df['quotCurrency'] = list(i.split('/')[1] for i in df['symbol']) engine = create_engine("mysql+pymysql://quziyou:0739#[email protected]:5389/coinData?charset=utf8") df.to_sql('coindata_tickers', con=engine, if_exists='append', index=False)
def start_check_from_ccxt(self): binance = ccxt.binance({ 'enableRateLimit': True, }) self.check_ccxt_exchange(binance, KLINE_TIMEFRAME_12HOUR) okex3 = ccxt.okex3({ 'enableRateLimit': True, }) self.check_ccxt_exchange(okex3, KLINE_TIMEFRAME_12HOUR) self.check_ccxt_exchange(okex3, KLINE_TIMEFRAME_1DAY) gate = ccxt.gateio({ 'enableRateLimit': True, }) self.check_ccxt_exchange(gate, KLINE_TIMEFRAME_12HOUR) self.check_ccxt_exchange(gate, KLINE_TIMEFRAME_1DAY) huobi = ccxt.huobipro({ 'enableRateLimit': True, })
def get_info_acc_order(ltc_used, ltc_total): print("-------------------------------获取账户信息-----------------------") apiKey = '073193AA-70CB-486A-B777-FA1ADF8544D5' secret = '1381a2091471e42d0aa4da874a092cb6b1eca48c9c17432f1c492add8f85a058' # Gate.io Key try: gateio = ccxt.gateio({"apiKey": apiKey, 'secret': secret}) balance = gateio.fetch_balance() print(balance) temp = balance['LTC'] # 获取LTC ltc_used = float(temp['used']) ltc_total = float(temp['total']) except ApiException as e: ltc_used = 0 ltc_total = 0 print("Woring: Connection fail!!!!!!!" % e) print(ltc_total) # 获取账户余额 return ltc_used, ltc_total
def _load_gateio_trades_data(symbol): gateio = ccxt.gateio({'verbose': True}) markets = gateio.load_markets() trades = gateio.fetch_trades(symbol) l = len(trades) L = list(range(l)) trades_bak = [] i = 0 for i in L: trades_1 = trades[i] trades2 = {} trades2['a'] = trades_1.pop('id') trades2['p'] = trades_1.pop('price') trades2['q'] = trades_1.pop('amount') trades2['f'] = 'none' trades2['l'] = 'none' trades2['T'] = trades_1.pop('timestamp') trades2['m'] = 'none' trades2['M'] = 'none' trades_bak.append(trades2) trades = trades2 return trades
def gateAgg(symbols): result = [] try: gate = ccxt.gateio({ 'apiKey': 'apiKey', 'secret': 'secret', 'options': { 'adjustForTimeDifference': True } }) totalBalance = gate.fetch_balance()["free"] exchangeSymbols = gate.symbols checkSymbols = list(np.intersect1d(exchangeSymbols, symbols)) allData = gate.fetch_tickers(checkSymbols) ethPrice = gate.fetch_ticker("ETH/USDT")["last"] btcPrice = gate.fetch_ticker("BTC/USDT")["last"] for s in checkSymbols: try: quote = s.split("/")[-1] dataSymbols = allData[s] coinBalance = totalBalance.get(s.split("/")[0], 0) volume = int(float(dataSymbols["baseVolume"])) ask = dataSymbols["ask"] bid = dataSymbols["bid"] last = float(dataSymbols["last"]) if quote == "BTC": volume = int(volume * btcPrice * last) elif quote == "ETH": volume = int(volume * ethPrice * last) else: volume = int(volume * dataSymbols["last"]) volume = volume / ethPrice result.append(["gate", s, coinBalance, ask, bid, volume]) except: print("Gate couldn`t get " + s) continue except Exception as e: print(str(e)[:150]) return (result)
def main(): exchange = ccxt.gateio() markets = exchange.load_markets() # exchange.verbose = True # uncomment for debugging purposes if necessary since = exchange.parse8601('2022-01-01T00:00:00Z') symbol = 'BTC/USDT' timeframe = '1h' all_ohlcvs = [] while True: try: ohlcvs = exchange.fetch_ohlcv(symbol, timeframe, since) all_ohlcvs += ohlcvs if len(ohlcvs): print('Fetched', len(ohlcvs), symbol, timeframe, 'candles from', exchange.iso8601(ohlcvs[0][0])) since = ohlcvs[-1][0] + 1 else: break except Exception as e: print(type(e).__name__, str(e)) print('Fetched', len(all_ohlcvs), symbol, timeframe, 'candles in total') if len(all_ohlcvs): print(table([[exchange.iso8601(o[0])] + o[1:] for o in all_ohlcvs]))
def text_reply(msg): # print msg['Text'] # print msg['ToUserName'] # print msg['FromUserName'] #print chardet.detect(text) text = msg['Text'] chatroom_name = msg.User.NickName if chatroom_name in white_list and text.encode( 'utf-8').isalpha() and len(text) > 0 and len(text) < 10: text = '{0}/USDT'.format(text.upper()) try: gateio = ccxt.gateio() result = gateio.fetch_ticker(text) current_price = result['last'] change = result['change'] high24hr = result['high'] low24hr = result['low'] quoto_volume = result['baseVolume'] if quoto_volume > 10000: quoto_volume = u"{0:.2f}万".format(quoto_volume / 10000) print quoto_volume url = 'https://gate.io/' time1 = datetime.datetime.strptime(result['datetime'], '%Y-%m-%dT%H:%M:%S.%fZ') timenow = (time1 + datetime.timedelta(hours=8)) timestr = timenow.strftime('%Y-%m-%d %H:%M:%S') send_msg = u"gateio {0}\n当前价格: {1} 美元\n涨幅: {2:.2f}%\n24H最高价: {3}美元\n24H最低价: {4}美元\n" \ u"24H成交量: {5}\n更多详细信息: {6}\n[{7}]".format(text,current_price,change,high24hr,low24hr, quoto_volume,url,timestr) # print msg['FromUserName'] print send_msg return send_msg except ExchangeError, e: return u"gateio 未发现: {0}".format(text) except ExchangeNotAvailable, e: print e.message return '服务器忙,请重试!'
import time import os import asyncio good_coin = ['BTC', 'ETH', 'XRP', 'BCH', 'EOS', 'XLM', 'LTC', 'ADA', 'XMR', 'TRX', 'BNB', 'ONT', 'NEO', 'DCR'] # good_coin = ['BTC', 'ETH', 'XRP'] good_exchange_name = ['binance', 'fcoin', 'gateio', 'huobipro', 'kucoin', 'okex','bcex','bibox','bigone','bitfinex','bitforex', 'bithumb','bitkk','cex','coinbase','coinex','cointiger','exx','gdax','gemini','hitbtc','rightbtc', 'theocean','uex'] # good_exchange_name = ['huobipro', 'kucoin', 'okex'] def_quote = 'USDT' # delay 2 seconds delay = 2 all_exchange = ccxt.exchanges gate = ccxt.gateio() print(gate) gate_markets = gate.load_markets() print('gateio markets is {}'.format(gate.markets)) # test demo def test_demo(): # from variable id exchange_id = 'okcoincny' # os.environ.setdefault('http_proxy', 'http://127.0.0.1:1080') # os.environ.setdefault('https_proxy', 'http://127.0.0.1:1080') # print('http_proxy is {},https_proxy is {}'.format(os.environ.get('http_proxy'), os.environ.get('https_proxy'))) binance = getattr(ccxt, exchange_id)() binance_markets = binance.load_markets() print ('gateio markets is {}'.format(binance_markets))
import os from random import randint 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 print('CCXT Version:', ccxt.__version__) exchange = ccxt.gateio({ 'apiKey': 'YOUR_API_KEY', 'secret': 'YOUR_SECRET_KEY', 'options': { 'defaultType': 'future', }, }) markets = exchange.load_markets() # exchange.verbose = True # uncomment for debugging purposes if necessary # Example 1: Creating a future (market) order try: # find a valid future futures = [] for key in markets: market = markets[key] if market['future']:
#-*- coding: utf-8 -*- import ccxt binance = ccxt.binance() gateio = ccxt.gateio({ "apiKey": "0368E005-8696-4C30-874B-3F8011972BED", "secret": "b48810de25da779a9633815df5bf073acbb7c9ac6bd6afd9f97db21fce425e92" }) gateio.load_markets() # print(gateio.fetch_tickers()) gateio.symbols print(gateio.account()) print(gateio.fetch_ticker("ADA/USDT")) print(gateio.create_limit_buy_order("ADA/USDT", 0.0006, 0.0078)) print(gateio.create_limit_sell_order("EOS/USDT", 1, 12)) print(gateio.create_limit_buy_order("EOS/USDT", 1, 10)) print(gateio.fetch_my_trades()) print(gateio.fetch_balance()) print(gateio.fetch_trade(symbol="EOS/USDT")) print(gateio.create_market_sell_order("EOS/USDT", 1, 10)) print(exchange.create_limit_buy_order(symbol, 1, 0))
# -*- coding: utf-8 -*- import ccxt import time import numpy as np from logging import Logger gateio = ccxt.gateio({}) listPool = [] # 价格池 sortPool = [] # 排序后的价格池 LENGTH = 1440 # 价格池容量 12小时的价格 symbol = "EOS/USDT" AMOUNT = 0.4 # 每次买入量,gate.io要求大于1 usdat interval = 30 # 30 每次获取价格的时间间隔,单位:秒 avg_short = 51 # 51 短线均值:avg_short * interval (秒) avg_middle = 101 # 101 中线均值:avg_middle * interval (秒) # avg_long = 301 # 长线均值: avg_long * interval (秒) sell_lmt = 173 # 可卖数量低于该值不卖 buy_lmt = 1 # 可买余额低于该值不买 sell_price = [] # 卖出价列表 buy_price = [] # 买入价列表 avg_diff = [0, 0, 0] # 短均线值-中均线值的差 logger = Logger(logName='log/avg_strategy', logLevel="INFO", logger="start_avg.py").getlog() def doTicker(): ticker = gateio.fetch_ticker(symbol=symbol) last = ticker["last"]
def exchangeObject(exchange_in): exchanges = [ ccxt.acx(), ccxt.bitbay(), ccxt.bitfinex(), ccxt.bitflyer(), ccxt.bithumb(), ccxt.bitlish(), ccxt.bitmarket(), ccxt.bitmex(), ccxt.bitso(), ccxt.bitstamp(), ccxt.bitstamp1(), ccxt.bittrex(), ccxt.bl3p(), ccxt.bleutrade(), ccxt.btcbox(), ccxt.btcchina(), ccxt.btcexchange(), ccxt.btcmarkets(), ccxt.btctradeua(), ccxt.btcturk(), ccxt.bxinth(), ccxt.ccex(), ccxt.cex(), ccxt.chbtc(), ccxt.chilebit(), ccxt.coincheck(), ccxt.coinfloor(), ccxt.coingi(), ccxt.coinmarketcap(), ccxt.coinmate(), ccxt.coinspot(), ccxt.cryptopia(), ccxt.dsx(), ccxt.exmo(), ccxt.flowbtc(), ccxt.foxbit(), ccxt.fybse(), ccxt.fybsg(), ccxt.gatecoin(), ccxt.gateio(), ccxt.gdax(), ccxt.gemini(), ccxt.getbtc(), ccxt.hitbtc(), ccxt.independentreserve(), ccxt.itbit(), ccxt.jubi(), ccxt.kraken(), ccxt.kucoin(), ccxt.kuna(), ccxt.lakebtc(), ccxt.liqui(), ccxt.livecoin(), ccxt.luno(), ccxt.mercado(), ccxt.mixcoins(), ccxt.nova(), ccxt.okcoincny(), ccxt.okcoinusd(), ccxt.okex(), ccxt.paymium(), ccxt.poloniex(), ccxt.qryptos(), ccxt.quadrigacx(), ccxt.southxchange(), ccxt.surbitcoin(), ccxt.therock(), ccxt.tidex(), ccxt.urdubit(), ccxt.vaultoro(), ccxt.vbtc(), ccxt.virwox(), ccxt.wex(), ccxt.xbtce(), ccxt.yobit(), ccxt.yunbi(), ccxt.zaif(), ccxt.zb() ] for count, exchange in enumerate([str(x) for x in exchanges]): if exchange_in.lower() in exchange: return exchanges[count] break
# print(df['time']) timelist = df['time'] # 转换成localtime # timestamp = int(timelist[6]) # print(timestamp) # timestamp = float(timestamp / 1000) # timearray = time.localtime(timestamp) # otherStyleTime = time.strftime("%Y-%m-%d %H:%M:%S", timearray) # print(otherStyleTime) print("OK") # exit() #######################N0.3获取账户信息######################################## print("-------------------------------获取账户信息-----------------------") apiKey = '073193AA-70CB-486A-B777-FA1ADF8544D5' secret = '1381a2091471e42d0aa4da874a092cb6b1eca48c9c17432f1c492add8f85a058' # Gate.io Key gateio = ccxt.gateio({"apiKey": apiKey, 'secret': secret}) balance = gateio.fetch_balance() # print(balance) temp = balance['LTC'] # 获取LTC print(temp) usdt_money = balance['USDT'] usdt_free = usdt_money['free'] usdt_used = usdt_money['used'] usdt_total = usdt_money['total'] ltc_free = float(temp['free']) ltc_used = float(temp['used']) ltc_total = float(temp['total']) print("ltc_free" + str(ltc_free)) print("ltc_used:" + str(ltc_used)) # 显示账户中的LTC余额 print("ltc_total:" + str(ltc_total)) print("usdt_free:" + str(usdt_free)) # 显示账户中的USDT余额
ccxt.coinnest(), ccxt.coinone(), ccxt.coinsecure(), ccxt.coinspot(), ccxt.coolcoin(), ccxt.cryptopia(), ccxt.dsx(), ccxt.ethfinex(), ccxt.exmo(), ccxt.exx(), ccxt.flowbtc(), ccxt.foxbit(), ccxt.fybse(), ccxt.fybsg(), ccxt.gatecoin(), ccxt.gateio(), ccxt.gdax(), ccxt.gemini(), ccxt.getbtc(), ccxt.hadax(), ccxt.hitbtc(), ccxt.hitbtc2(), ccxt.huobi(), ccxt.huobicny(), ccxt.huobipro(), ccxt.ice3x(), ccxt.independentreserve(), ccxt.indodax(), ccxt.itbit(), ccxt.jubi(), ccxt.kraken(),
previousBalance = 0 currentBalance = 0 previousRate = 0 currentRate = 0 previousPerc = 0 currentPerc = 0 startTime = time.time() timeDelta = 0 displayTime = 60/3 screenToShow = 0 exchange = ccxt.gateio() def update_data(): global previousBalance global currentBalance global previousRate global currentRate global previousPerc global currentPerc previousBalance = currentBalance try: currentBalance = get_bscscan_balance() except:
def move_nas_usdt_huobi_gateio(self,rate): gateio=ccxt.gateio() huobi = ccxt.huobipro() huobi.apiKey='7548cd5e-b95cad3b-33ebac0a-f809d' huobi.secret='63a58654-0cf1b5fa-9ded4823-a9165' gateio.apiKey="1C465DD1-3657-4AEB-B6AA-62F558F397ED" gateio.secret="" while True: try: depth_huobi=huobi.fetch_order_book("NAS/USDT",limit=7) depth_gateio=gateio.fetch_order_book("NAS/USDT",limit=7) huobi_bids=list(depth_huobi['bids']) hb_bids_1=list(huobi_bids[0]) #买一价 hb_bids_1_price=float(hb_bids_1[0]) #买一量 hb_bids_1_amount=float(hb_bids_1[1]) #获取卖一 hb_huobi_asks=list(depth_huobi['asks']) hb_asks_1=list(hb_huobi_asks[0]) #卖一价 hb_aks_1_price=float(hb_asks_1[0]) #卖一量 hb_asks_1_amount=float(hb_asks_1[1]) gateio_bids=list(depth_gateio['bids']) gate_bids_1=list(gateio_bids[0]) gate_bids_7=list(gateio_bids[-1]) gate_bids_7_price=float(gate_bids_7[0]) gate_bids_1_price=float(gate_bids_1[0]) gate_bids_1_amout=float(gate_bids_1[1]) gateio_asks=list(depth_gateio['asks']) gate_asks_7=list(gateio_asks[-1]) gate_asks_1=list(gateio_asks[0]) gate_asks_1_price=float(gate_asks_1[0]) gate_asks_7_price=float(gate_asks_7[0]) gate_asks_1_amout=float(gate_asks_1[1]) condition_1=float((hb_bids_1_price-gate_asks_1_price)/gate_asks_1_price) condition_2=float((gate_bids_1_price-hb_aks_1_price)/hb_aks_1_price) print("CONDITION_1:",condition_1,"CONDITION_2:",condition_2) if condition_1>=rate or condition_2>=rate: #获取火币余额 self. times+=1 huobi_all_balance=dict(huobi.fetch_balance()["info"]) huobi_data=dict(huobi_all_balance["data"]) huobi_list=list(huobi_data["list"]) for i,val in enumerate(huobi_list): val=dict(val) #print(val) if val["type"]=="trade" and val["currency"]=="usdt": self.huobi_usdt_balance=float(val["balance"]) if val["type"]=="trade" and val["currency"]=="nas": self.huobi_nas_balance=float(val["balance"]) #获取gate余额 gateio_all_balance=dict(dict(gateio.fetch_balance()["info"])["available"]) self.gate_nas_balance=float(gateio_all_balance["NAS"]) self.gate_usdt_balance=float(gateio_all_balance["USDT"]) print(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),"-----交易前----","gate_NAS余额:",self.gate_nas_balance,"gate_USDT 余额:",self.gate_usdt_balance,"火币_NAS余额:",self.huobi_nas_balance,"火币USDT余额:",self.huobi_usdt_balance,"交易前NAS总量:",(self.gate_nas_balance+self.huobi_nas_balance),"交易前USDT总和:",(self.huobi_usdt_balance+self.gate_usdt_balance)) #if condition_1>=rate and hb_asks_1_amount #条件2 if condition_1>=rate and hb_asks_1_amount>=2 and gate_bids_1_amout>=2 and self.gate_usdt_balance>=gate_asks_1_price and self.huobi_nas_balance>=1: print("火币卖,gate买") huobi_sell_order=huobi.create_market_sell_order("NAS/USDT",1) gate_buy_order=gateio.create_limit_buy_order("NAS/USDT",1/0.998,gate_asks_1_price*1.05) print(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),"--交易订单:[","火币卖单-",huobi_sell_order,"],[gate买单-",gate_buy_order,"]") #print(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),"-----交易后----","gateNAS余额:",self.gate_nas_balance,"gate USDT 余额:",self.gate_usdt_balance,"火币NAS余额:",self.huobi_nas_balance,"火币USDT余额:",self.huobi_usdt_balance,"交易后NAS总量:",self.gate_nas_balance+self.huobi_nas_balance,"交易后USDT总和:",self.huobi_usdt_balance+self.gate_usdt_balance) self.counter+=1 else: if self.gate_usdt_balance<gate_asks_1_price: print("gate_usdt余额不足!") subject="gate_usdt余额不足!" content="gate_usdt余额不足!" ms=email_sender.email_sender() ret=ms.mail(content,subject,"*****@*****.**") elif self.huobi_nas_balance<1: print("火币_NAS余额不足!") subject="火币_NAS余额不足!" content="火币_NAS余额不足!" ms=email_sender.email_sender() ret=ms.mail(content,subject,"*****@*****.**") elif hb_asks_1_amount<2 and gate_bids_1_amout<2: print("火币卖gate买交易量不满足") if condition_2 >=rate and hb_asks_1_amount>=2 and gate_bids_1_amout>=2 and self.huobi_usdt_balance>=hb_bids_1_price and self.gate_nas_balance>=1 : print("火币买,gate卖") huobi_buy_order=huobi.create_market_buy_order("NAS/USDT",(hb_bids_1_price)*(1.005/0.998)) gate_sell_order=gateio.create_limit_sell_order("NAS/USDT",1,gate_bids_7_price*0.95) print(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),"--交易订单:[","火币买单-",huobi_buy_order,"],[gate卖单-",gate_sell_order,"]") self.counter+=1 #print(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),"-----交易后----","gateNAS余额:",self.gate_nas_balance,"gate USDT 余额:",self.gate_usdt_balance,"火币NAS余额:",self.huobi_nas_balance,"火币USDT余额:",self.huobi_usdt_balance,"交易后NAS总量:",self.gate_nas_balance+self.huobi_nas_balance,"交易后USDT总和:",self.huobi_usdt_balance+self.gate_usdt_balance) else: if self.huobi_usdt_balance<hb_bids_1_price: print("火币_usdt余额不足!") subject="火币_usdt余额不足!" content="火币_usdt余额不足!" ms=email_sender.email_sender() ret=ms.mail(content,subject,"*****@*****.**") elif self.gate_nas_balance<1: print("GATE_NAS余额不足!") subject="GATE_NAS余额不足!" content="GATE_NAS余额不足!" ms=email_sender.email_sender() ret=ms.mail(content,subject,"*****@*****.**") elif hb_asks_1_amount<2 and gate_bids_1_amout<2: print("火币买gate卖交易量不满足") #time.sleep(0.0005) print(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),"--已搬砖次数:",self.counter,"--检测到可搬砖次数:",self.times) except: pass
def __init__(self): self.name = 'gateio' self.client = ccxt.gateio() self.client.apiKey = KEY_SECRET['gateio'][0] self.client.secret = KEY_SECRET['gateio'][1]
def _load_gateio_orderbook_data(symbol): gateio = ccxt.gateio({'verbose': True}) markets = gateio.load_markets() orderbook = gateio.fetch_order_book(symbol) return orderbook
def _load_gateio_ohlcv_data(symbol): gateio = ccxt.gateio({'verbose': True}) markets = gateio.load_markets() ohlcv = gateio.fetch_ohlcv(symbol) return ohlcv
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
# coding=utf-8 import ccxt import time hitbtc = ccxt.hitbtc({'verbose': True}) bitmex = ccxt.bitmex() huobi = ccxt.huobi() exmo = ccxt.exmo({ 'apiKey': 'YOUR_PUBLIC_API_KEY', 'secret': 'YOUR_SECRET_PRIVATE_KEY', }) t1 = time.time() gateio = ccxt.gateio() t2 = time.time() # print gateio.load_markets() print gateio.fetch_ticker('DAI/USDT') t3 = time.time() print t3 - t2, t2 - t1 # print gateio.market_id('DAI/USDT') # print gateio.fetch_balance() def test(): hitbtc_markets = hitbtc.load_markets() print(hitbtc.id, hitbtc_markets) print(bitmex.id, bitmex.load_markets()) print(huobi.id, huobi.load_markets()) print(hitbtc.fetch_order_book(hitbtc.symbols[0]))
path = '/home/ribs/Documents/ccxt/python/csv_exports' csv_file_name = exchange_name + '_' + sc_pair + '_' + date1 + '_' + date2 + '.csv' output_file = os.path.join(path, csv_file_name) output_file = exchange_name + '_' + sc_pair + '_' + date1 + '_' + date2 + '.csv' output_dir = os.path.join('/home/ribs/Documents/ccxt/python/csv_exports/') # output_dir.mkdir(parents=True, exist_ok=True) # ----------------------------------------------------------------------------- exchange = ccxt.gateio({ 'rateLimit': 1000, 'enableRateLimit': True, # 'verbose': True, }) print(exchange.timeframes) # ----------------------------------------------------------------------------- # from_timestamp = time.strptime(date1, "%Y-%m-%d %H:%M:%S") # from_datetime = '2021-04-01 00:00:00' # from_timestamp = exchange.parse8601(from_datetime) from_timestamp = exchange.parse8601(date1) # now_datetime = time.strptime(date2, "%Y-%m-%d %H:%M:%S") now = exchange.parse8601(date2)