From e8728c0cd41ccb09fb3c631e12e95d492f79c38d Mon Sep 17 00:00:00 2001 From: Joe Jevnik Date: Wed, 15 Jun 2016 19:52:32 -0400 Subject: [PATCH] TST: fix data tests --- tests/data/bundles/test_core.py | 2 +- tests/data/bundles/test_yahoo.py | 3 +++ zipline/data/_equities.pyx | 2 +- zipline/data/bundles/core.py | 8 +++++--- zipline/data/bundles/quandl.py | 5 ++++- zipline/data/us_equity_pricing.py | 3 +-- 6 files changed, 15 insertions(+), 8 deletions(-) diff --git a/tests/data/bundles/test_core.py b/tests/data/bundles/test_core.py index 1a0b2484..f79b3ef8 100644 --- a/tests/data/bundles/test_core.py +++ b/tests/data/bundles/test_core.py @@ -303,7 +303,7 @@ class BundleCoreTestCase(WithInstanceTmpDir, ZiplineTestCase): output_dir): _wrote_to.append(output_dir) - _wrote_to.clear() + _wrote_to[:] = [] self.ingest('bundle', environ=self.environ) assert_equal(len(_wrote_to), 1, msg='ingest was called more than once') ingestions = self._list_bundle() diff --git a/tests/data/bundles/test_yahoo.py b/tests/data/bundles/test_yahoo.py index f2054e09..80937cd6 100644 --- a/tests/data/bundles/test_yahoo.py +++ b/tests/data/bundles/test_yahoo.py @@ -1,3 +1,5 @@ +from __future__ import division + import numpy as np import pandas as pd from six.moves.urllib.parse import urlparse, parse_qs @@ -201,4 +203,5 @@ class YahooBundleTestCase(WithResponses, ZiplineTestCase): adjustments, expected, msg=column, + decimal=4, ) diff --git a/zipline/data/_equities.pyx b/zipline/data/_equities.pyx index caa8ae69..5b80aada 100644 --- a/zipline/data/_equities.pyx +++ b/zipline/data/_equities.pyx @@ -212,7 +212,7 @@ cpdef _read_bcolz_data(ctable_t table, carray[first_row:last_row + 1] else: continue - + if column_name in {'open', 'high', 'low', 'close'}: where_nan = (outbuf == 0) outbuf_as_float = outbuf.astype(float64) * .001 diff --git a/zipline/data/bundles/core.py b/zipline/data/bundles/core.py index 873d9ca3..a0765f54 100644 --- a/zipline/data/bundles/core.py +++ b/zipline/data/bundles/core.py @@ -356,10 +356,12 @@ def _make_bundle_core(): asset_db_path(name, timestr, environ=environ), )).path, ) + wf = stack.enter_context(working_file( + adjustment_db_path(name, timestr, environ=environ), + )) + wf.close() # we need to close the file to delete it on windows adjustment_db_writer = SQLiteAdjustmentWriter( - stack.enter_context(working_file( - adjustment_db_path(name, timestr, environ=environ), - )).path, + wf.path, BcolzDailyBarReader(daily_bars_path), bundle.calendar, overwrite=True, diff --git a/zipline/data/bundles/quandl.py b/zipline/data/bundles/quandl.py index dcb08d88..ba0526f5 100644 --- a/zipline/data/bundles/quandl.py +++ b/zipline/data/bundles/quandl.py @@ -258,7 +258,10 @@ def gen_symbol_data(api_key, _update_splits(splits, asset_id, raw_data) _update_dividends(dividends, asset_id, raw_data) - raw_data = raw_data.reindex(calendar, copy=False).fillna(0.0) + raw_data = raw_data.reindex( + calendar.tz_localize(None), + copy=False, + ).fillna(0.0) yield asset_id, raw_data if should_sleep: diff --git a/zipline/data/us_equity_pricing.py b/zipline/data/us_equity_pricing.py index 1cc76bc3..cd94512b 100644 --- a/zipline/data/us_equity_pricing.py +++ b/zipline/data/us_equity_pricing.py @@ -15,7 +15,6 @@ from abc import ABCMeta, abstractmethod, abstractproperty from errno import ENOENT from functools import partial from os import remove -from os.path import exists import sqlite3 import warnings @@ -875,7 +874,7 @@ class SQLiteAdjustmentWriter(object): if isinstance(conn_or_path, sqlite3.Connection): self.conn = conn_or_path elif isinstance(conn_or_path, str): - if overwrite and exists(conn_or_path): + if overwrite: try: remove(conn_or_path) except OSError as e: