from packages import zb as ZB pgmanager = DB.PGManager(database='quantum', user='******', pw='Caichong416', host='localhost', port='5432') virtual_account = ACCOUNT.Account('', '') binance = BN.Binance(virtual_account) bitfinex = BF.Bitfinex(virtual_account) bitso = BS.Bitso(virtual_account) bitstamp = BST.Bitstamp(virtual_account) bittrex = BTT.Bittrex(virtual_account) coinbase = CB.Coinbase(virtual_account) digifinex = DF.DigiFinex(virtual_account) gate = G.Gateio(virtual_account) huobi = HB.Huobi(virtual_account) itbit = IB.Itbit(virtual_account) kraken = KK.KrakenRest(virtual_account) kucoin = KC.Kucoin(virtual_account) liquid = LQ.Liquid(virtual_account) okex = OK.Okex(virtual_account) poloniex = PL.Poloniex(virtual_account) zb = ZB.Zb(virtual_account) exchanges = [ binance, bitfinex, bitso, bitstamp, bittrex, coinbase, digifinex, gate, huobi, itbit, kraken, kucoin, liquid, okex, poloniex, zb ] # exchanges=[bittrex,zb]
def get_all_currency_pairs(cls, market, account=None, user_id=None): market = str(market).lower() if market == 'digifinex': from packages import digifinex as DIGIFINEX digifinex = DIGIFINEX.DigiFinex(account) tickers = digifinex.ticker() # 在digiFinex返回的tickers数据结构里,每个项的vol字段的值指的是base的成交量,而不是reference的成交量,所以首先要变成reference成交量 currency_pairs = { 'usdt': [], 'btc': [], 'usdt2': [], 'eth': [], 'dft': [] } # currency_pairs_in_reference_of_btc=[] # currency_pairs_in_reference_of_usdt = [] # currency_pairs_in_reference_of_usdt2 = [] # currency_pairs_in_reference_of_eth = [] # currency_pairs_in_reference_of_dft = [] for item in dict(tickers).keys(): base = str(item).split('_')[1] reference = str(item).split('_')[0] currency_pair = CurrencyPair(base, reference) vol = tickers[item]['vol'] * tickers[item]['last'] currency_pairs[reference].append({ 'currency_pair': currency_pair, 'vol': vol, 'reference': reference }) # sorted(x, key=lambda x : x['name'], reverse=True) for item in currency_pairs.keys(): currency_pairs[item] = sorted(currency_pairs[item], key=lambda x: x['vol'], reverse=True) if market == 'aex': from packages import aex as AEX aex = AEX.AEX(account, user_id) tickers = {} tickers['cny'] = aex.ticker(CurrencyPair('all', 'cny'), True) tickers['usdt'] = aex.ticker(CurrencyPair('all', 'usdt'), True) # 在digiFinex返回的tickers数据结构里,每个项的vol字段的值指的是base的成交量,而不是reference的成交量,所以首先要变成reference成交量 _tickers = {} for key1 in tickers.keys(): for key2 in tickers[key1]: if key1 + '_' + key2 == 'usdt_tusd' or key1 + '_' + key2 == 'usdt_pax': continue _tickers[key1 + '_' + key2] = tickers[key1][key2]['ticker'] tickers = _tickers currency_pairs = {'usdt': [], 'cny': []} for item in dict(tickers).keys(): base = str(item).split('_')[1] reference = str(item).split('_')[0] currency_pair = CurrencyPair(base, reference) vol = tickers[item]['vol'] * tickers[item]['last'] currency_pairs[reference].append({ 'currency_pair': currency_pair, 'vol': vol, 'reference': reference }) # sorted(x, key=lambda x : x['name'], reverse=True) for item in currency_pairs.keys(): currency_pairs[item] = sorted(currency_pairs[item], key=lambda x: x['vol'], reverse=True) return currency_pairs
import sys sys.path.append("..") from packages import digifinex as DIGIFINEX from packages import account as ACCOUNT from packages import currency_pair as CURRENCYPAIR from packages import universal as UNIVERSAL import time from threading import Thread account = ACCOUNT.Account('15d12cfa0a69be', 'c6d6a4b051b36e373bb47eede7c1675d05d12cfa0') digifinex = DIGIFINEX.DigiFinex(account) currency_pair = CURRENCYPAIR.CurrencyPair('ltc', 'usdt') # global variables are defined here: CURRENCY_PAIR_INFOS = None PRICE_PRECISION = {} CHANGING_UNIT = None MINIMUM_AMOUNT = None INITIAL_FUNDS = None FEES = {'maker': 0, 'taker': 0.002} depths = [] balance = None my_pending_orders = None def initialize(): # 0. read exchange-based constants global CURRENCY_PAIR_INFOS global PRICE_PRECISION