MAINT: Add equity to naming of bar data classes.

In preparation of adding futures, add equity to the names of both the
classes and methods for writing bcolz data. Futures data will use a
different minutes per day with a separate reader. This change will allow
both equity and futures fixtures to be side by side.

Also, break out the method which generates the dataframes and trading
days member into fixtures (`EquityMinuteBarData` and
`EquityDailyBarData`) on which the `*BarReader` fixture depends.  This
fixture is separated out to enable reader/writers in different formats
to use the same data setup. (There is internal code which needs to write
minute and daily bar data in a database format.)
This commit is contained in:
Eddie Hebert
2016-06-28 15:30:20 -04:00
parent c89e957905
commit 51eda06323
22 changed files with 349 additions and 278 deletions
+2 -2
View File
@@ -176,7 +176,7 @@ class BundleCoreTestCase(WithInstanceTmpDir, ZiplineTestCase):
columns = 'open', 'high', 'low', 'close', 'volume'
actual = bundle.minute_bar_reader.load_raw_arrays(
actual = bundle.equity_minute_bar_reader.load_raw_arrays(
columns,
minutes[0],
minutes[-1],
@@ -190,7 +190,7 @@ class BundleCoreTestCase(WithInstanceTmpDir, ZiplineTestCase):
msg=colname,
)
actual = bundle.daily_bar_reader.load_raw_arrays(
actual = bundle.equity_daily_bar_reader.load_raw_arrays(
columns,
calendar[0],
calendar[-1],
+1 -1
View File
@@ -216,7 +216,7 @@ class QuandlBundleTestCase(ZiplineTestCase):
assert_equal(equity.end_date, self.asset_end, msg=equity)
cal = self.calendar
actual = bundle.daily_bar_reader.load_raw_arrays(
actual = bundle.equity_daily_bar_reader.load_raw_arrays(
self.columns,
cal[cal.get_loc(self.asset_start, 'bfill')],
cal[cal.get_loc(self.asset_end, 'ffill')],
+1 -1
View File
@@ -177,7 +177,7 @@ class YahooBundleTestCase(WithResponses, ZiplineTestCase):
assert_equal(equity.start_date, self.asset_start, msg=equity)
assert_equal(equity.end_date, self.asset_end, msg=equity)
actual = bundle.daily_bar_reader.load_raw_arrays(
actual = bundle.equity_daily_bar_reader.load_raw_arrays(
self.columns,
cal[cal.get_loc(self.asset_start, 'bfill')],
cal[cal.get_loc(self.asset_end, 'ffill')],
+10 -10
View File
@@ -43,7 +43,7 @@ from zipline.pipeline.loaders.synthetic import (
)
from zipline.testing import seconds_to_timestamp
from zipline.testing.fixtures import (
WithBcolzDailyBarReader,
WithBcolzEquityDailyBarReader,
ZiplineTestCase,
)
from zipline.utils.calendars import get_calendar
@@ -79,19 +79,19 @@ EQUITY_INFO = DataFrame(
TEST_QUERY_ASSETS = EQUITY_INFO.index
class BcolzDailyBarTestCase(WithBcolzDailyBarReader, ZiplineTestCase):
BCOLZ_DAILY_BAR_START_DATE = TEST_CALENDAR_START
BCOLZ_DAILY_BAR_END_DATE = TEST_CALENDAR_STOP
class BcolzDailyBarTestCase(WithBcolzEquityDailyBarReader, ZiplineTestCase):
EQUITY_DAILY_BAR_START_DATE = TEST_CALENDAR_START
EQUITY_DAILY_BAR_END_DATE = TEST_CALENDAR_STOP
@classmethod
def make_equity_info(cls):
return EQUITY_INFO
@classmethod
def make_daily_bar_data(cls):
def make_equity_daily_bar_data(cls):
return make_bar_data(
EQUITY_INFO,
cls.bcolz_daily_bar_days,
cls.equity_daily_bar_days,
)
@classmethod
@@ -187,12 +187,12 @@ class BcolzDailyBarTestCase(WithBcolzDailyBarReader, ZiplineTestCase):
def test_read_first_trading_day(self):
self.assertEqual(
self.bcolz_daily_bar_reader.first_trading_day,
self.bcolz_equity_daily_bar_reader.first_trading_day,
self.trading_days[0],
)
def _check_read_results(self, columns, assets, start_date, end_date):
results = self.bcolz_daily_bar_reader.load_raw_arrays(
results = self.bcolz_equity_daily_bar_reader.load_raw_arrays(
columns,
start_date,
end_date,
@@ -280,7 +280,7 @@ class BcolzDailyBarTestCase(WithBcolzDailyBarReader, ZiplineTestCase):
)
def test_unadjusted_spot_price(self):
reader = self.bcolz_daily_bar_reader
reader = self.bcolz_equity_daily_bar_reader
# At beginning
price = reader.spot_price(1, Timestamp('2015-06-01', tz='UTC'),
'close')
@@ -318,7 +318,7 @@ class BcolzDailyBarTestCase(WithBcolzDailyBarReader, ZiplineTestCase):
reader.spot_price(4, Timestamp('2015-06-16', tz='UTC'), 'close')
def test_unadjusted_spot_price_empty_value(self):
reader = self.bcolz_daily_bar_reader
reader = self.bcolz_equity_daily_bar_reader
# A sid, day and corresponding index into which to overwrite a zero.
zero_sid = 1