patched guard logic in max drawdown calculation. needs real work.

This commit is contained in:
fawce
2012-04-05 12:43:43 -04:00
parent 14b57dad07
commit aaf2fae2b8
3 changed files with 6 additions and 13 deletions
-9
View File
@@ -189,9 +189,6 @@ class Component(object):
self.stop_tic = time.time()
# shouldn't block if we've done our job correctly
# self.context.term()
def run(self, catch_exceptions=True):
"""
Run the component.
@@ -214,12 +211,6 @@ class Component(object):
self.shutdown()
self.teardown_sockets()
#else:
#try:
#self._run()
#finally:
#self.shutdown()
#self.teardown_sockets()
def working(self):
"""
+3 -3
View File
@@ -237,11 +237,11 @@ class RiskMetrics():
compounded_returns = []
cur_return = 0.0
for r in self.algorithm_returns:
if(r != -1.0):
try:
cur_return = math.log(1.0 + r) + cur_return
#this is a guard for a single day returning -100%
else:
qutil.LOGGER.warn("negative 100 percent return, zeroing the returns")
except ValueError:
qutil.LOGGER.warn("{cur} return, zeroing the returns".format(cur=cur_return))
cur_return = 0.0
compounded_returns.append(cur_return)
+3 -1
View File
@@ -358,7 +358,8 @@ class TradingEnvironment(object):
treasury_curves,
period_start=None,
period_end=None,
capital_base=None
capital_base=None,
max_drawdown=None
):
self.trading_days = []
@@ -370,6 +371,7 @@ class TradingEnvironment(object):
self.period_end = period_end
self.capital_base = capital_base
self.period_trading_days = None
self.max_drawdown = max_drawdown
for bm in benchmark_returns:
self.trading_days.append(bm.date)