mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-03 06:34:39 +08:00
Backtest protocol, ala Bredeche.
This commit is contained in:
+13
-2
@@ -14,7 +14,8 @@ import humanhash
|
||||
from datetime import datetime
|
||||
|
||||
import zipline.util as qutil
|
||||
from zipline.protocol import CONTROL_PROTOCOL, COMPONENT_STATE
|
||||
from zipline.protocol import CONTROL_PROTOCOL, COMPONENT_STATE, \
|
||||
COMPONENT_FAILURE, BACKTEST_STATE
|
||||
|
||||
class Component(object):
|
||||
"""
|
||||
@@ -66,6 +67,7 @@ class Component(object):
|
||||
self.controller = None
|
||||
self.heartbeat_timeout = 2000
|
||||
self.state_flag = COMPONENT_STATE.OK
|
||||
self.error_state = COMPONENT_FAILURE.NOFAILURE
|
||||
self.on_done = None
|
||||
|
||||
self._exception = None
|
||||
@@ -254,8 +256,17 @@ class Component(object):
|
||||
# Internal Maintenance
|
||||
# ----------------------
|
||||
|
||||
def signal_exception(self, exc=None):
|
||||
def signal_exception(self, exc=None, scope=None):
|
||||
|
||||
if scope == 'algo':
|
||||
self.error_state = COMPONENT_FAILURE.ALGOEXCEPT
|
||||
else:
|
||||
self.error_state = COMPONENT_FAILURE.HOSTEXCEPT
|
||||
|
||||
self.state_flag = COMPONENT_STATE.EXCEPTION
|
||||
# mark the time of failure so we can track the failure
|
||||
# progogation through the system.
|
||||
|
||||
self.stop_tic = time.time()
|
||||
|
||||
self._exception = exc
|
||||
|
||||
@@ -274,6 +274,27 @@ COMPONENT_STATE = Enum(
|
||||
'EXCEPTION' , # 2
|
||||
)
|
||||
|
||||
# NOFAILURE - Component is either not running or has not failed
|
||||
# ALGOEXCEPT - Exception thrown in the given algorithm
|
||||
# HOSTEXCEPT - Exception thrown on our end.
|
||||
# INTERRUPT - Manually interuptted by user
|
||||
|
||||
COMPONENT_FAILURE = Enum(
|
||||
'NOFAILURE' ,
|
||||
'ALGOEXCEPT' ,
|
||||
'HOSTEXCEPT' ,
|
||||
'INTERRUPT' ,
|
||||
)
|
||||
|
||||
BACKTEST_STATE = Enum(
|
||||
'IDLE' ,
|
||||
'QUEUED' ,
|
||||
'INPROGRESS' ,
|
||||
'CANCELLED' , # cancelled ( before natural completion )
|
||||
'EXCEPTION' , # failure ( due to unnatural causes )
|
||||
'DONE' , # done ( naturally completed )
|
||||
)
|
||||
|
||||
# ==================
|
||||
# Datasource Protocol
|
||||
# ==================
|
||||
|
||||
Reference in New Issue
Block a user