-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOrder_Class.py
More file actions
50 lines (29 loc) · 1.1 KB
/
Order_Class.py
File metadata and controls
50 lines (29 loc) · 1.1 KB
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
43
44
45
46
47
48
49
50
from datetime import datetime, timezone
from zoneinfo import ZoneInfo
class Order:
def __init__(self ,order_id ,agent_id ,order_type ,side ,qty,price=None,timestamp = None): # thinking of making
self.order_id = order_id
self.agent_id = agent_id
self.price = price
self.qty = qty
self.type = order_type # LIMIT / MARKET type
self.side = side # BUY / SELL
self.timestamp = timestamp
self.order_status = 'Pending'
# self refers the particluar instance of class...!
def __repr__(self):
return f"[ORDER ID {self.order_id} -> {self.side} {self.qty} @ {self.price}]"
def show_order_info(self):
print(self)
''''''
odr = Order('O1','1XYZ','LIMIT','BUY',10,210)
# checking if it works
odr.show_order_info()
# first task finished !
print(odr.timestamp)
# Ignore now
# Understand this , Later !!
'''
def __repr__(self):
return f"[{self.order_type}] {self.side} {self.qty} @ {self.price} by Agent {self.agent_id} (Status: {self.order_status})
'''