From 9db18846c93060426e95b9d8eabbe5e1048e3558 Mon Sep 17 00:00:00 2001 From: fawce Date: Mon, 16 Apr 2012 13:37:54 -0400 Subject: [PATCH] fixed type-os in serialization code --- zipline/finance/performance.py | 5 +++-- zipline/finance/trading.py | 15 ++++++++------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/zipline/finance/performance.py b/zipline/finance/performance.py index 03c94139..390ae430 100644 --- a/zipline/finance/performance.py +++ b/zipline/finance/performance.py @@ -218,8 +218,8 @@ class PerformanceTracker(): 'period_start' : self.period_start, 'period_end' : self.period_end, 'progress' : self.progress, - 'cumulative_captial_used' : self.cumulative_perf.cumulative_capital_used, - 'max_capital_used' : self.cumulative_perf.max_capital_used, + 'cumulative_capital_used' : self.cumulative_performance.cumulative_capital_used, + 'max_capital_used' : self.cumulative_performance.max_capital_used, 'last_close' : self.market_close, 'last_open' : self.market_open, 'capital_base' : self.capital_base, @@ -271,6 +271,7 @@ class PerformanceTracker(): trading_environment=self.trading_environment ) + # increment the day counter before we move markers forward. self.day_count += 1.0 # calculate progress of test diff --git a/zipline/finance/trading.py b/zipline/finance/trading.py index 97d8cebb..2b088a29 100644 --- a/zipline/finance/trading.py +++ b/zipline/finance/trading.py @@ -2,6 +2,7 @@ import datetime import pytz import math import pandas +import time from collections import Counter @@ -37,8 +38,8 @@ class TradeSimulationClient(qmsg.Component): self.current_dt = trading_environment.period_start self.last_iteration_dur = datetime.timedelta(seconds=0) self.algorithm = None - self.attempts = 0 - self.max_attempts = 1000 + self.max_wait = datetime.timedelta(seconds=10) + self.last_msg_dt = datetime.datetime.utcnow() assert self.trading_environment.frame_index != None self.event_frame = pandas.DataFrame( @@ -75,7 +76,7 @@ class TradeSimulationClient(qmsg.Component): if self.result_feed in socks and \ socks[self.result_feed] == self.zmq.POLLIN: - self.attempts = 0 + self.last_msg_dt = datetime.datetime.utcnow() # get the next message from the result feed msg = self.result_feed.recv() @@ -105,10 +106,10 @@ class TradeSimulationClient(qmsg.Component): # drained. Signal the order_source that we're done, and # the done will cascade through the whole zipline. # shutdown the feedback loop to the OrderDataSource - if self.attempts > self.max_attempts: - self.signal_order_done() - else: - self.attempts += 1 + wait_time = self.last_msg_dt - datetime.datetime.utcnow() + if wait_time > self.max_wait: + self.signal_order_done() + def process_event(self, event): # track the number of transactions, for testing purposes. if(event.TRANSACTION != None):