forked from danielktaylor/PyLimitBook
-
Notifications
You must be signed in to change notification settings - Fork 1
/
order.py
42 lines (32 loc) · 1019 Bytes
/
order.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/python
class Order(object):
def __init__(self, tick, orderList):
self.nextOrder = None
self.prevOrder = None
self.tick = tick
self.orderList = orderList
def nextOrder(self):
return self.nextOrder
def prevOrder(self):
return self.prevOrder
def updateQty(self, newQty, newTimestamp):
if newQty > self.qty and self.orderList.tailOrder != self:
# Move order to end of the tier (loses time priority)
self.orderList.moveTail(self)
self.orderList.volume -= self.qty - newQty
self.tick.timestamp = newTimestamp
self.tick.qty = newQty
@property
def idNum(self):
return self.tick.idNum
@property
def qty(self):
return self.tick.qty
@property
def price(self):
return self.tick.price
@property
def isBid(self):
return self.tick.isBid
def __str__(self):
return "%s\t@\t%.4f" % (self.qty, self.price / float(10000))