diff --git a/zipline/finance/performance.py b/zipline/finance/performance.py index 34dfae89..9d761eb1 100644 --- a/zipline/finance/performance.py +++ b/zipline/finance/performance.py @@ -287,8 +287,6 @@ class PerformanceTracker(object): if self.results_socket: msg = zp.PERF_FRAME(self.to_dict()) self.results_socket.send(msg) - else: - log.debug(self.to_dict()) # if self.trading_environment.max_drawdown: @@ -555,7 +553,7 @@ class PerformancePeriod(object): # cumulative_capital_used, max_leverage, max_capital_used portfolio['cash'] = portfolio['ending_cash'] portfolio['start_date'] = portfolio['period_open'] - portfolio['position_value'] = portfolio['ending_value'] + portfolio['positions_value'] = portfolio['ending_value'] del(portfolio['ending_cash']) del(portfolio['period_open']) diff --git a/zipline/finance/risk.py b/zipline/finance/risk.py index a63cf872..7021c581 100644 --- a/zipline/finance/risk.py +++ b/zipline/finance/risk.py @@ -126,7 +126,7 @@ class RiskMetrics(): Returns a dict object of the form: """ period_label = self.end_date.strftime("%Y-%m") - return { + rval = { 'trading_days' : self.trading_days, 'benchmark_volatility' : self.benchmark_volatility, 'algo_volatility' : self.algorithm_volatility, @@ -141,6 +141,16 @@ class RiskMetrics(): 'period_label' : period_label } + # check if a field in rval is nan, and replace it with + # None. + def check_entry(key, value): + if key != 'period_label': + return np.isnan(value) + else: + return False + + return {k:None if check_entry(k,v) else v for k,v in rval.iteritems()} + def __repr__(self): statements = [] metrics = [ diff --git a/zipline/finance/trading.py b/zipline/finance/trading.py index 2d378574..b2aacdc1 100644 --- a/zipline/finance/trading.py +++ b/zipline/finance/trading.py @@ -151,20 +151,6 @@ class TransactionSimulator(object): dt.replace(tzinfo = pytz.utc), direction ) - elif len(orders) > 0: - warning = """ -Calculated a zero volume transaction on trade: -{event} -for orders: -{orders} - """ - warning = warning.format( - event=str(event), - orders=str(orders) - ) - LOGGER.warn(warning) - return None - def create_transaction(self, sid, amount, price, dt, direction): self.txn_count += 1 diff --git a/zipline/lines.py b/zipline/lines.py index a229c9f0..d696d97e 100644 --- a/zipline/lines.py +++ b/zipline/lines.py @@ -325,6 +325,14 @@ class SimulatedTrading(object): if blocking: self.sim_context.join() + @property + def is_success(self): + # TODO: other assertions? + if self.sim.did_clean_shutdown(): + return True + else: + return False + #-------------------------------- # Component property accessors #--------------------------------