TST: Ensure batch_order_target_percent orders like order_target_percent

This commit is contained in:
Richard Frank
2016-12-20 19:27:28 -05:00
parent 1cb85b70f2
commit 581e827208
3 changed files with 87 additions and 0 deletions
+1
View File
@@ -7,6 +7,7 @@ from .core import ( # noqa
FetcherDataPortal,
MockDailyBarReader,
OpenPrice,
RecordBatchBlotter,
add_security_data,
all_pairs_matching_predicate,
all_subindices,
+15
View File
@@ -39,6 +39,7 @@ from zipline.data.us_equity_pricing import (
BcolzDailyBarWriter,
SQLiteAdjustmentWriter,
)
from zipline.finance.blotter import Blotter
from zipline.finance.trading import TradingEnvironment
from zipline.finance.order import ORDER_STATUS
from zipline.lib.labelarray import LabelArray
@@ -1502,6 +1503,20 @@ def ensure_doctest(f, name=None):
return f
class RecordBatchBlotter(Blotter):
"""Blotter that tracks how its batch_order method was called.
"""
def __init__(self, data_frequency, asset_finder):
super(RecordBatchBlotter, self).__init__(
data_frequency, asset_finder,
)
self.order_batch_called = []
def batch_order(self, *args, **kwargs):
self.order_batch_called.append((args, kwargs))
return super(RecordBatchBlotter, self).batch_order(*args, **kwargs)
####################################
# Shared factors for pipeline tests.
####################################