def __init__(self): self.priceTree = RBTree() self.priceMap = {} # Map from price -> orderList object self.orderMap = {} # Order ID to Order object self.volume = 0 # How much volume on this side? self.nOrders = 0 # How many orders? self.lobDepth = 0 # How many different prices on lob?
def shrinkData(filename, symbol, verbose): symbol = symbol.ljust(6) try: if verbose: print "started reading file: {}".format(filename) reader = open(filename,'r') except IOError: sys.exit('Cannot open input file: {}'.format(filename)) else: if verbose: print "file in memory, opening outfile" writer = open(filename+'_short','w') ids = RBTree() for line in reader: messageType = line[9] idNum = line[10:22] if messageType == 'A': if line[29:35] == symbol: ids.insert(idNum, idNum) writer.write(line) elif messageType == 'a': if line[33:39] == symbol: ids.insert(idNum, idNum) writer.write(line) elif messageType == 'E': if idNum in ids: writer.write(line) elif messageType == 'e': if idNum in ids: writer.write(line) elif messageType == 'X': if idNum in ids: writer.write(line) elif messageType == 'x': if idNum in ids: writer.write(line) if verbose: print "done" reader.close() writer.close() # os.chdir('/Users/user/Desktop/BATSCHIX/CXE') # shrinkData('2013-05-13_EU_pitch', 'DBKd', True)