コード例 #1
0
async def compare_markets(itoken, all_tokens, percent, currency, proxy, cnt,
                          currencyUSD):
    idex_depth = await get_idex_depth(itoken[3], cnt)
    compare_result = []
    if idex_depth:
        for token in all_tokens:
            if token[0] == itoken[0] and 'usd' not in token[0].lower(
            ) and 'usd' not in itoken[0].lower():
                # idex_depth = {'asks': itoken[5], 'bids': itoken[4]}
                c_bids = None
                if 'hotbit' in token[2]:
                    hotbit_depth = await get_hotbit_depth(token[3], proxy)
                    if hotbit_depth:
                        c_bids = hotbit_depth['bids']
                elif 'hitbtc' in token[2]:
                    hitbtc_deth = await get_hitbtc_depth(token[3], proxy)
                    if hitbtc_deth:
                        c_bids = []
                        for bid in hitbtc_deth['bid']:
                            c_bids.append([bid['price'], bid['size']])
                # elif 'bilaxy' in token[2]:
                #     bilaxy_deth = await get_bilaxy_depth(token[3], proxy)
                #     if bilaxy_deth:
                #         c_bids = bilaxy_deth['bids']
                elif 'uniswap' in token[2]:
                    c_bids = token[4]
                else:
                    c_bids = None
                if idex_depth['asks']:
                    compare_result.append(
                        ct(buy_from='idex',
                           buy_symbol=itoken[3],
                           buy_prices=idex_depth['asks'],
                           buy_volume=0,
                           sell_to=token[2],
                           sell_prices=c_bids,
                           sell_volume=1,
                           sell_symbol=token[3],
                           contract=token[1],
                           profit_percent=percent,
                           currency=currency,
                           currencyUSD=currencyUSD).compare())
                if idex_depth['bids'] and ('bancor' in token[2] or 'uniswap'
                                           in token[2] or 'kyber' in token[2]
                                           or 'uniswap_one' in token[2]):
                    compare_result.append(
                        ct(buy_from=token[2],
                           buy_symbol=token[3],
                           buy_prices=token[5],
                           buy_volume=0,
                           sell_to='idex',
                           sell_prices=idex_depth['bids'],
                           sell_volume=1,
                           sell_symbol=itoken[3],
                           contract=token[1],
                           profit_percent=percent,
                           currency=currency,
                           currencyUSD=currencyUSD).compare())
    return compare_result
コード例 #2
0
async def compare_markets(htoken, all_tokens, percent, currency, cnt, currencyUSD):
    hitbtc_deth = await get_hitbtc_depth(htoken[3], cnt)
    asks = []
    bids = []
    compare_result = []
    if hitbtc_deth:
        for token in all_tokens:
            # print(token)
            if token[0] == htoken[0] and 'usd' not in token[0].lower() and 'usd' not in htoken[0].lower():
                c_bids = None
                # if 'idex' in token[2]:
                #     idex_depth = await get_idex_depth(token[3], cnt)
                #     if idex_depth:
                #         if len(idex_depth['bids']) > 0:
                #             c_bids = idex_depth['bids']
                if 'hotbit' in token[2]:
                    hotbit_depth = await get_hotbit_depth(token[3], cnt)
                    if hotbit_depth:
                        c_bids = hotbit_depth['bids']
                # elif 'bilaxy' in token[2]:
                #     bilaxy_deth = await get_bilaxy_depth(token[3], cnt)
                #     if bilaxy_deth:
                #         c_bids = bilaxy_deth['bids']
                elif 'uniswap' in token[2]:
                    c_bids = token[4]
                else:
                    c_bids = None
                for ask in hitbtc_deth['ask']:
                    asks.append([ask['price'], ask['size']])
                compare_result.append(
                    ct(buy_from='hitbtc', buy_symbol=htoken[3], buy_prices=asks, buy_volume=0, sell_to=token[2],
                       sell_prices=c_bids, sell_volume=1, sell_symbol=token[3],
                       contract=token[1], profit_percent=percent, currency=currency, currencyUSD=currencyUSD).compare())
                if 'bancor' in token[2] or 'uniswap' in token[2] or 'kyber' in token[2] or 'uniswap_one' in token[2]:
                    for bid in hitbtc_deth['bid']:
                        bids.append([bid['price'], bid['size']])
                    compare_result.append(
                        ct(buy_from=token[2], buy_symbol=token[3], buy_prices=token[5], buy_volume=1, sell_to='hitbtc',
                           sell_prices=bids, sell_volume=0, sell_symbol=htoken[3],
                           contract=token[1], profit_percent=percent, currency=currency, currencyUSD=currencyUSD).compare())
    return compare_result
コード例 #3
0
async def compare(tsymbol, bids, asks, itoken, direction, all_tokens, currency,
                  currencyUSD, percent):
    # print(tsymbol, bids, asks, itoken, direction, currency, currencyUSD, percent)
    compare_result = []
    """(self, buy_from, buy_symbol, buy_prices, buy_volume, sell_to, sell_symbol, sell_prices, sell_volume,
                 contract, profit_percent, currency, currencyUSD)"""
    for token in all_tokens:
        if token[0] == tsymbol and 'usd' not in token[0].lower(
        ) and 'usd' not in tsymbol.lower():
            c_bids = get_token_depth(token)
            if asks:
                compare_result.append(
                    ct(buy_from='hitbtc',
                       buy_symbol=itoken,
                       buy_prices=asks,
                       buy_volume=0,
                       sell_to=token[2],
                       sell_prices=c_bids,
                       sell_volume=1,
                       sell_symbol=token[3],
                       contract=token[1],
                       profit_percent=percent,
                       currency=currency,
                       currencyUSD=currencyUSD).compare())
            if bids and ('bancor' in token[2] or 'uniswap' in token[2]
                         or 'kyber' in token[2] or 'uniswap_one' in token[2]):
                compare_result.append(
                    ct(buy_from=token[2],
                       buy_symbol=token[3],
                       buy_prices=token[5],
                       buy_volume=0,
                       sell_to='hitbtc',
                       sell_prices=bids,
                       sell_volume=1,
                       sell_symbol=itoken,
                       contract=token[1],
                       profit_percent=percent,
                       currency=currency,
                       currencyUSD=currencyUSD).compare())
    return compare_result