From f4bc73b738fed0cde63170a044105ad546884d72 Mon Sep 17 00:00:00 2001 From: fawce Date: Thu, 8 Mar 2012 17:37:15 -0500 Subject: [PATCH] updates for algo proxy. --- zipline/finance/trading.py | 10 +++++++--- zipline/messaging.py | 5 +++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/zipline/finance/trading.py b/zipline/finance/trading.py index 2ecdc197..431323c9 100644 --- a/zipline/finance/trading.py +++ b/zipline/finance/trading.py @@ -28,7 +28,9 @@ class TradeSimulationClient(qmsg.Component): #next feed event socks = dict(self.poll.poll(self.heartbeat_timeout)) - if self.result_feed in socks and socks[self.result_feed] == self.zmq.POLLIN: + if self.result_feed in socks and \ + socks[self.result_feed] == self.zmq.POLLIN: + msg = self.result_feed.recv() if msg == str(zp.CONTROL_PROTOCOL.DONE): @@ -61,7 +63,8 @@ class OrderDataSource(qmsg.DataSource): def __init__(self, simulation_dt): """ - :param simulation_time: datetime in UTC timezone, sets the start time of simulation. orders + :param simulation_time: datetime in UTC timezone, sets the start + time of simulation. orders will be timestamped relative to this datetime. event = { 'sid' : an integer for security id, @@ -129,7 +132,8 @@ class OrderDataSource(qmsg.DataSource): count += 1 self.sent_count += 1 - #TODO: we have to send at least one dummy order per do_work iteration or the feed will block waiting for our messages. + #TODO: we have to send at least one dummy order per do_work iteration + # or the feed will block waiting for our messages. if(count == 0): self.send_dummy() self.sent_count += 1 diff --git a/zipline/messaging.py b/zipline/messaging.py index e187ab78..87673c00 100644 --- a/zipline/messaging.py +++ b/zipline/messaging.py @@ -384,7 +384,8 @@ class MergedParallelBuffer(ParallelBuffer): def append(self, event): """ - :param event: a namedict with one entry. key is the name of the transform, value is the transformed value. + :param event: a namedict with one entry. key is the name of the + transform, value is the transformed value. Add an event to the buffer for the source specified by source_id. """ @@ -398,7 +399,7 @@ class BaseTransform(Component): Top level execution entry point for the transform - connects to the feed socket to subscribe to events - - connets to the result socket (most oftened bound by a TransformsMerge) to PUSH transforms + - connects to the result socket (most oftened bound by a TransformsMerge) to PUSH transforms - processes all messages received from feed, until DONE message received - pushes all transforms - sends DONE to result socket, closes all sockets and context