mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-24 13:00:57 +08:00
fixed tests net of merge of dataflow.
This commit is contained in:
@@ -2,12 +2,12 @@
|
||||
verbosity=2
|
||||
detailed-errors=1
|
||||
|
||||
with-xcoverage=1
|
||||
cover-package=zipline
|
||||
cover-erase=1
|
||||
cover-html=1
|
||||
cover-html-dir=docs/_build/html/cover
|
||||
with-xunit=1
|
||||
#with-xcoverage=1
|
||||
#cover-package=zipline
|
||||
#cover-erase=1
|
||||
#cover-html=1
|
||||
#cover-html-dir=docs/_build/html/cover
|
||||
#with-xunit=1
|
||||
|
||||
|
||||
# Drop into debugger on failure
|
||||
|
||||
@@ -119,7 +119,6 @@ import numbers
|
||||
import datetime
|
||||
import pytz
|
||||
import copy
|
||||
import pandas
|
||||
from collections import namedtuple
|
||||
|
||||
from protocol_utils import Enum, FrameExceptionFactory, namedict
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import copy
|
||||
import pandas
|
||||
from ctypes import Structure, c_ubyte
|
||||
|
||||
def Enum(*options):
|
||||
@@ -85,3 +86,8 @@ class namedict(object):
|
||||
|
||||
def has_attr(self, name):
|
||||
return self.__dict__.has_key(name)
|
||||
|
||||
def as_series(self):
|
||||
s = pandas.Series(self.__dict__)
|
||||
s.name = self.sid
|
||||
return s
|
||||
|
||||
@@ -84,9 +84,8 @@ class TestAlgorithm():
|
||||
event = zp.namedict(data)
|
||||
#place an order for 100 shares of sid:133
|
||||
if self.incr < self.count:
|
||||
if event.source_id != zp.FINANCE_COMPONENT.ORDER_SOURCE:
|
||||
self.trading_client.order(self.sid, self.amount)
|
||||
self.incr += 1
|
||||
self.trading_client.order(self.sid, self.amount)
|
||||
self.incr += 1
|
||||
elif not self.done:
|
||||
self.trading_client.signal_order_done()
|
||||
self.done = True
|
||||
|
||||
@@ -210,6 +210,8 @@ class FinanceTestCase(TestCase):
|
||||
self.trading_environment.period_start = trade_history[0].dt
|
||||
self.trading_environment.period_end = trade_history[-1].dt
|
||||
self.trading_environment.capital_base = 10000
|
||||
self.trading_environment.frame_index = ['sid', 'volume', 'dt', \
|
||||
'price', 'changed']
|
||||
|
||||
trading_client = TradeSimulationClient(self.trading_environment)
|
||||
#client will send 10 orders for 100 shares of 133
|
||||
@@ -291,6 +293,8 @@ class FinanceTestCase(TestCase):
|
||||
self.trading_environment.period_start = trade_history[0].dt
|
||||
self.trading_environment.period_end = trade_history[-1].dt
|
||||
self.trading_environment.capital_base = 10000
|
||||
self.trading_environment.frame_index = ['sid', 'volume', 'dt', \
|
||||
'price', 'changed']
|
||||
|
||||
set1 = SpecificEquityTrades("flat-133", trade_history)
|
||||
|
||||
|
||||
@@ -11,6 +11,9 @@ class Risk(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
qutil.configure_logging()
|
||||
start_date = datetime.datetime(year=2006, month=1, day=1, tzinfo=pytz.utc)
|
||||
end_date = datetime.datetime(year=2006, month=12, day=31, tzinfo=pytz.utc)
|
||||
|
||||
self.benchmark_returns, self.treasury_curves = \
|
||||
factory.load_market_data()
|
||||
|
||||
@@ -23,9 +26,9 @@ class Risk(unittest.TestCase):
|
||||
self.oneday = datetime.timedelta(days=1)
|
||||
self.tradingday = datetime.timedelta(hours=6, minutes=30)
|
||||
self.dt = datetime.datetime.utcnow()
|
||||
start_date = datetime.datetime(year=2006, month=1, day=1, tzinfo=pytz.utc)
|
||||
|
||||
self.algo_returns_06 = factory.create_returns_from_list(RETURNS, start_date, self.trading_calendar)
|
||||
end_date = datetime.datetime(year=2006, month=12, day=31, tzinfo=pytz.utc)
|
||||
|
||||
self.metrics_06 = risk.RiskReport(self.algo_returns_06, self.trading_calendar)
|
||||
|
||||
def tearDown(self):
|
||||
|
||||
Reference in New Issue
Block a user