mirror of
https://github.com/wassname/catalyst.git
synced 2026-06-29 08:47:07 +08:00
patched guard logic in max drawdown calculation. needs real work.
This commit is contained in:
@@ -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):
|
||||
"""
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user