remove logging from initialize for now

This commit is contained in:
scottsanderson
2012-07-04 03:46:42 -04:00
parent 59fdd1f292
commit b447333fae
+12 -14
View File
@@ -41,6 +41,7 @@ class TradeSimulationClient(Component):
return str(zp.FINANCE_COMPONENT.TRADING_CLIENT)
def set_algorithm(self, algorithm):
"""
:param algorithm: must implement the algorithm protocol. See
:py:mod:`zipline.test.algorithm`
@@ -49,21 +50,20 @@ class TradeSimulationClient(Component):
# register the trading_client's order method with the algorithm
self.algorithm.set_order(self.order)
#TODO: re-enable initialization logging
#TODO: re-enable initialization logging. This means we can't call set_algorithm
#until we have a context for this component. Possibly this could happen
# ask the algorithm to initialize, routing stdout to a zmq PUSH socket.
#if self.log_socket:
# with self.zmq_out.threadbound(), \
# self.stdout_capture(self.logger, 'Algo print capture'):
# self.algorithm.initialize()
# if we don't have a log socket, initialize anyway.
#with self.zmq_out.threadbound(), self.stdout_capture(self.logger, 'Algo print capture'):
# self.algorithm.initialize()
#if we don't have a log socket, initialize anyway.
#else:
# self.algorithm.initialize()
self.algorithm.initialize()
def open(self):
self.result_feed = self.connect_result()
self.perf.open(self.context)
@@ -80,12 +80,10 @@ class TradeSimulationClient(Component):
self.zmq_out = ZeroMQLogHandler(uri = self.log_socket, context = context)
self.logger = Logger("Print")
self.stdout_capture = stdout_only_pipe #THIS IS A CLASS!
def do_work(self):
# poll all the sockets
socks = dict(self.poll.poll(self.heartbeat_timeout))
# see if the poller has results for the result_feed
if socks.get(self.result_feed) == self.zmq.POLLIN:
@@ -103,6 +101,7 @@ class TradeSimulationClient(Component):
event = zp.MERGE_UNFRAME(msg)
self.received_count += 1
# update performance and relay the event to the algorithm
self.process_event(event)
if self.perf.exceeded_max_loss:
self.finish_simulation()
@@ -118,7 +117,6 @@ class TradeSimulationClient(Component):
self.signal_done()
def process_event(self, event):
# generate transactions, if applicable
txn = self.txn_sim.apply_trade_to_open_orders(event)
if txn:
@@ -143,10 +141,10 @@ class TradeSimulationClient(Component):
# queue the event.
self.queue_event(event)
# if the event is later than our current time, run the algo
# otherwise, the algorithm has fallen behind the feed
# and processing per event is longer than time between events.
if event.dt >= self.current_dt:
# compress time by moving the current_time up to the event
# time.
@@ -168,13 +166,13 @@ class TradeSimulationClient(Component):
current_portfolio = self.perf.get_portfolio()
self.algorithm.set_portfolio(current_portfolio)
data = self.get_data()
if len(data) > 0:
# data injection pipeline for log rerouting
# any fields injected here should be added to
# LOG_EXTRA_FIELDS in zipline/protocol.py
if self.log_socket:
def inject_event_data(record):