mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-01 07:07:29 +08:00
patching the filter test because we are now trying to calculate end of test risk
This commit is contained in:
+11
-2
@@ -320,8 +320,12 @@ class RiskReport():
|
||||
self.algorithm_returns = algorithm_returns
|
||||
self.trading_environment = trading_environment
|
||||
|
||||
start_date = self.algorithm_returns[0].date
|
||||
end_date = self.algorithm_returns[-1].date
|
||||
if len(self.algorithm_returns) == 0:
|
||||
start_date = self.trading_environment.period_start
|
||||
end_date = self.trading_environment.period_end
|
||||
else:
|
||||
start_date = self.algorithm_returns[0].date
|
||||
end_date = self.algorithm_returns[-1].date
|
||||
|
||||
self.month_periods = self.periodsInRange(1, start_date, end_date)
|
||||
self.three_month_periods = self.periodsInRange(3, start_date, end_date)
|
||||
@@ -355,6 +359,11 @@ class RiskReport():
|
||||
ends = []
|
||||
cur_start = start.replace(day=1)
|
||||
|
||||
# in edge cases (all sids filtered out, start/end are adjacent)
|
||||
# a test will not generate any returns data
|
||||
if len(self.algorithm_returns) == 0:
|
||||
return ends
|
||||
|
||||
#ensure that we have an end at the end of a calendar month, in case
|
||||
#the return series ends mid-month...
|
||||
the_end = advance_by_months(end.replace(day=1),1) - one_day
|
||||
|
||||
@@ -243,7 +243,6 @@ class OrderDataSource(qmsg.DataSource):
|
||||
if(count == 0):
|
||||
self.send(zp.namedict({}))
|
||||
|
||||
|
||||
|
||||
class TransactionSimulator(qmsg.BaseTransform):
|
||||
|
||||
|
||||
+6
-2
@@ -23,10 +23,14 @@ class TradeDataSource(zm.DataSource):
|
||||
if event.sid in self.filter['SID']:
|
||||
message = zp.DATASOURCE_FRAME(event)
|
||||
else:
|
||||
message = zp.DATASOURCE_FRAME(None)
|
||||
blank = zp.namedict({
|
||||
"type" : zp.DATASOURCE_TYPE.TRADE,
|
||||
"source_id" : self.get_id
|
||||
})
|
||||
message = zp.DATASOURCE_FRAME(blank)
|
||||
|
||||
self.data_socket.send(message)
|
||||
|
||||
|
||||
|
||||
class RandomEquityTrades(TradeDataSource):
|
||||
"""
|
||||
|
||||
@@ -155,7 +155,6 @@ class FinanceTestCase(TestCase):
|
||||
zipline = SimulatedTrading.create_test_zipline(**self.zipline_test_config)
|
||||
|
||||
zipline.simulate(blocking=True)
|
||||
|
||||
#check that the algorithm received no events
|
||||
self.assertEqual(
|
||||
0,
|
||||
|
||||
Reference in New Issue
Block a user