def generate_pairs_filter_xml(maxpairs=None):

    lock = threading.Lock()
    exchanges = u.getExchangesFromXml('exchanges.xml')
    assets = u.getAssetsFromXml('assets.xml')
    logger = loggerHandler('generate_pairs_filter_xml',log_path='log/')
    
    u.initExchangesConcurrency(exchanges,assets,logger)
    pairs = u.getMostQuotedPairs(exchanges,logger)

    root = etree.Element('PairsFilter')

    if maxpairs:
        if maxpairs>len(pairs):
            maxpairs = len(pairs)
    else:
        maxpairs = len(pairs)
    
    for pair in pairs[:maxpairs]:
        node = etree.SubElement(root,'Pair',name=pair[1])
        
    str_xml = etree.tostring(root,pretty_print=True)
    outFile = open('pairs_filter.xml','w')
    outFile.write(str_xml.decode())
    outFile.close()
    logger.close()
예제 #2
0
            return True
    return False

if __name__=="__main__":

    threads = []
    time_start = time.time()
    exchanges = u.getExchangesFromXml('exchanges.xml')
    assets = u.getAssetsFromXml('assets.xml')
    pairs_filter = u.getPairsFilterFromXml('pairs_filter.xml')
    logger = loggerHandler('exchange_listener',log_path='log/')
    loggerExchangeInfo = loggerHandler('exchange_info',log_path='log/')
    loggerArbitrage = loggerHandler('exchange_arbitrage',log_path='log/')

    #init exchanges
    u.initExchangesConcurrency(exchanges,assets,logger)
    
    #delete pair we are not listening
    u.deletePairsUnlistened(exchanges,pairs_filter)
    
    #listen to exchanges
    threads = u.launchExchangeListenersWithPairsFilter(exchanges,pairs_filter,logger)
    time.sleep(3)

    print('Launching shell....')
    print('****************************************************************')
    print('****  key in \'cmdlist\' to get list of available commands *****')
    print('****************************************************************')
    
    #shell loop
    while True: