forked from robcarver17/pysystemtrade
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathorders.py
33 lines (23 loc) · 806 Bytes
/
orders.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
from dataclasses import dataclass
from syscore.constants import named_object, arg_not_supplied
@dataclass()
class SimpleOrder:
### Simple order, suitable for use in simulation, but not complex enough for production
## Could share code, but too complicated
quantity: int
limit_price: float = None
@property
def is_market_order(self):
if self.limit_price is None:
return True
@property
def is_zero_order(self) -> bool:
return self.quantity == 0
@classmethod
def zero_order(cls):
return cls(quantity=0)
zero_order = SimpleOrder.zero_order()
class ListOfSimpleOrders(list):
def remove_zero_orders(self):
new_list = [order for order in self if not order.is_zero_order]
return ListOfSimpleOrders(new_list)