working on elminating the need for signaling order done.

This commit is contained in:
fawce
2012-03-19 16:08:53 -04:00
parent e7f44884cf
commit 87c9d913d6
4 changed files with 21 additions and 11 deletions
+7
View File
@@ -448,6 +448,13 @@ class Component(object):
"""
raise NotImplementedError
@property
def is_blocking(self):
"""
True if a zipline be held open for this component.
"""
return False
@property
def get_pure(self):
+1 -3
View File
@@ -170,15 +170,13 @@ class SimulatedTrading(object):
self.started = False
##################################################################
#TODO: the next three lines of code need refactoring from RealDiehl
#TODO: the next two lines of code need refactoring from RealDiehl
##################################################################
#wire up a callback inside the algorithm to receive frames from the
#trading client
self.trading_client.add_event_callback(self.algorithm.handle_frame)
#register the trading_client's order method with the algorithm
self.algorithm.set_order(self.trading_client.order)
#register the algorithm to signal order's are done
self.algorithm.set_done(self.trading_client.signal_order_done)
def add_source(self, source):
assert isinstance(source, zmsg.DataSource)
+4
View File
@@ -550,6 +550,10 @@ class DataSource(Component):
@property
def get_id(self):
return self.id
@property
def is_blocking(self):
return True
@property
def get_type(self):
+9 -8
View File
@@ -94,13 +94,9 @@ class TestAlgorithm():
self.incr = 0
self.done = False
self.order = None
self.on_done = None
def set_order(self, order_callable):
self.order = order_callable
def set_done(self, done_callable):
self.on_done = done_callable
def handle_frame(self, frame):
for dt, s in frame.iteritems():
@@ -111,7 +107,12 @@ class TestAlgorithm():
if self.incr < self.count:
self.order(self.sid, self.amount)
self.incr += 1
elif not self.done:
if self.on_done:
self.on_done()
self.done = True
class NoopAlgorithm(object):
def set_order(self, order_callable):
pass
def handle_frame(self, frame):
pass