mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-03 01:58:14 +08:00
added a class to throw exceptions from the algorithm
This commit is contained in:
@@ -4,7 +4,6 @@ from unittest2 import TestCase, skip
|
||||
|
||||
from zipline.core.monitor import Controller
|
||||
|
||||
|
||||
class TestMonitor(TestCase):
|
||||
def setUp(self):
|
||||
self.log_handler = LoggingHandler()
|
||||
|
||||
@@ -180,8 +180,6 @@ class TradeSimulationClient(Component):
|
||||
- Set the current portfolio for the algorithm as per protocol.
|
||||
- Construct data based on backlog of events, send to algorithm.
|
||||
"""
|
||||
# current_portfolio = self.perf.get_portfolio()
|
||||
# self.algorithm.set_portfolio(current_portfolio)
|
||||
data = self.get_data()
|
||||
|
||||
if len(data) > 0:
|
||||
|
||||
@@ -138,17 +138,55 @@ class NoopAlgorithm(object):
|
||||
def get_sid_filter(self):
|
||||
return None
|
||||
|
||||
class ExceptionAlgorithm(object):
|
||||
"""
|
||||
Dolce fa niente.
|
||||
"""
|
||||
|
||||
def __init__(self, throw_from):
|
||||
self.throw_from == throw_from
|
||||
|
||||
def initialize(self):
|
||||
if self.throw_from == "initialize":
|
||||
raise Exception("Algo exception in initialize")
|
||||
else:
|
||||
pass
|
||||
|
||||
def set_order(self, order_callable):
|
||||
if self.throw_from == "set_order":
|
||||
raise Exception("Algo exception in set_order")
|
||||
else:
|
||||
pass
|
||||
|
||||
def set_portfolio(self, portfolio):
|
||||
if self.throw_from == "set_portfolio":
|
||||
raise Exception("Algo exception in set_portfolio")
|
||||
else:
|
||||
pass
|
||||
|
||||
def handle_data(self, data):
|
||||
if self.throw_from == "handle_data":
|
||||
raise Exception("Algo exception in handle_data")
|
||||
else:
|
||||
pass
|
||||
|
||||
def get_sid_filter(self):
|
||||
if self.throw_from == "get_sid_filter":
|
||||
raise Exception("Algo exception in get_sid_filter")
|
||||
else:
|
||||
return None
|
||||
|
||||
class TestPrintAlgorithm():
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
|
||||
def initialize(self):
|
||||
print "Initializing..."
|
||||
|
||||
def set_order(self, order_callable):
|
||||
pass
|
||||
|
||||
|
||||
def set_portfolio(self, portfolio):
|
||||
pass
|
||||
|
||||
|
||||
Reference in New Issue
Block a user