Skip to content

Commit 2c54050

Browse files
committed
checkpoint
1 parent 0c8889f commit 2c54050

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

bin/limitbook-parse.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@
1616
trade_id = 0
1717
for line in reader:
1818
if line[0] == 'B' or line[0] == 'A':
19-
tokens = line.split(",")
20-
(trades, order) = order_book.process_order(
21-
{"type" : "limit",
19+
tokens = line.strip().split(",")
20+
d = {"type" : "limit",
2221
"side" : "bid" if tokens[0] == 'B' else 'ask',
2322
"quantity": int(tokens[1]),
2423
"price" : Decimal(tokens[2]),
25-
"trade_id" : trade_id}, False, False)
24+
"trade_id" : trade_id}
25+
if len(tokens) >=4:
26+
d['tag'] = tokens[3]
27+
(trades, order) = order_book.process_order(d, False, False)
2628
trade_id = trade_id + 1
2729
# Manual Debugging
2830
print ("\n")

orderbook/order.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ def __init__(self, quote, order_list):
1414
self.price = Decimal(quote['price']) # decimal representing price (currency)
1515
self.order_id = int(quote['order_id'])
1616
self.trade_id = int(quote['trade_id'])
17+
self.tag = quote.get('tag', None)
1718
# doubly linked list to make it easier to re-order Orders for a particular price point
1819
self.next_order = None
1920
self.prev_order = None
@@ -35,4 +36,4 @@ def update_quantity(self, new_quantity, new_timestamp):
3536
self.quantity = new_quantity
3637

3738
def __str__(self):
38-
return "Order: Price - %s, Quantity - %s, Timestamp - %s" % (self.price, self.quantity, self.timestamp)
39+
return "Order: %s@%s Timestamp - %s%s" % (self.quantity, self.price, self.timestamp, '' if self.tag is None else (", Tag -%s" % self.tag))

0 commit comments

Comments
 (0)