Added basic logging capability to trading.py and related classes.
This commit is contained in:
+29
-2
@@ -10,15 +10,33 @@ class TickEvent(Event):
|
||||
self.bid = bid
|
||||
self.ask = ask
|
||||
|
||||
def __str__(self):
|
||||
return "Type: %s, Instrument: %s, Time: %s, Bid: %s, Ask: %s" % (
|
||||
str(self.type), str(self.instrument),
|
||||
str(self.time), str(self.bid), str(self.ask)
|
||||
)
|
||||
|
||||
def __repr__(self):
|
||||
return str(self)
|
||||
|
||||
|
||||
class SignalEvent(Event):
|
||||
def __init__(self, instrument, order_type, side, time):
|
||||
self.type = 'SIGNAL'
|
||||
self.instrument = instrument
|
||||
self.order_type = order_type
|
||||
self.side = side
|
||||
self.side = side
|
||||
self.time = time # Time of the last tick that generated the signal
|
||||
|
||||
def __str__(self):
|
||||
return "Type: %s, Instrument: %s, Order Type: %s, Side: %s" % (
|
||||
str(self.type), str(self.instrument),
|
||||
str(self.order_type), str(self.side)
|
||||
)
|
||||
|
||||
def __repr__(self):
|
||||
return str(self)
|
||||
|
||||
|
||||
class OrderEvent(Event):
|
||||
def __init__(self, instrument, units, order_type, side):
|
||||
@@ -26,4 +44,13 @@ class OrderEvent(Event):
|
||||
self.instrument = instrument
|
||||
self.units = units
|
||||
self.order_type = order_type
|
||||
self.side = side
|
||||
self.side = side
|
||||
|
||||
def __str__(self):
|
||||
return "Type: %s, Instrument: %s, Units: %s, Order Type: %s, Side: %s" % (
|
||||
str(self.type), str(self.instrument), str(self.units),
|
||||
str(self.order_type), str(self.side)
|
||||
)
|
||||
|
||||
def __repr__(self):
|
||||
return str(self)
|
||||
Reference in New Issue
Block a user