Merge branch 'master' of github.com:quantopian/zipline

This commit is contained in:
Thomas Wiecki
2012-06-28 12:58:55 -04:00
4 changed files with 20 additions and 18 deletions
+1 -3
View File
@@ -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'])
+11 -1
View File
@@ -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 = [
-14
View File
@@ -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
+8
View File
@@ -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
#--------------------------------