diff --git a/zipline/data/bundles/core.py b/zipline/data/bundles/core.py index 89064577..f9525e05 100644 --- a/zipline/data/bundles/core.py +++ b/zipline/data/bundles/core.py @@ -28,7 +28,7 @@ from zipline.utils.compat import mappingproxy from zipline.utils.input_validation import ensure_timestamp, optionally import zipline.utils.paths as pth from zipline.utils.preprocess import preprocess -from zipline.utils.calendars import get_calendar +from zipline.utils.calendars import get_calendar, register_calendar nyse_cal = get_calendar('NYSE') trading_days = nyse_cal.all_sessions @@ -564,3 +564,6 @@ def _make_bundle_core(): return BundleCore(bundles, register, unregister, ingest, load, clean) bundles, register, unregister, ingest, load, clean = _make_bundle_core() + +register_calendar("YAHOO", get_calendar("NYSE")) +register_calendar("QUANDL", get_calendar("NYSE")) diff --git a/zipline/data/bundles/quandl.py b/zipline/data/bundles/quandl.py index ba0526f5..f0343c92 100644 --- a/zipline/data/bundles/quandl.py +++ b/zipline/data/bundles/quandl.py @@ -123,7 +123,7 @@ def fetch_symbol_metadata_frame(api_key, # cut out all the other stuff in the name column # we need to escape the paren because it is actually splitting on a regex data.asset_name = data.asset_name.str.split(r' \(', 1).str.get(0) - data['exchange'] = 'quandl' + data['exchange'] = 'QUANDL' data['auto_close_date'] = data['end_date'] + pd.Timedelta(days=1) return data diff --git a/zipline/data/bundles/yahoo.py b/zipline/data/bundles/yahoo.py index db9ce298..4a317516 100644 --- a/zipline/data/bundles/yahoo.py +++ b/zipline/data/bundles/yahoo.py @@ -123,6 +123,11 @@ def yahoo_equities(symbols, start=None, end=None): daily_bar_writer.write(_pricing_iter(), show_progress=show_progress) symbol_map = pd.Series(metadata.symbol.index, metadata.symbol) + + # Hardcode the exchange to "YAHOO" for all assets and (elsewhere) + # register "YAHOO" to resolve to the NYSE calendar, because these are + # all equities and thus can use the NYSE calendar. + metadata['exchange'] = "YAHOO" asset_db_writer.write(equities=metadata) adjustments = [] diff --git a/zipline/examples/__init__.py b/zipline/examples/__init__.py index 667fdd17..8a06f8a1 100644 --- a/zipline/examples/__init__.py +++ b/zipline/examples/__init__.py @@ -7,6 +7,8 @@ from zipline import run_algorithm # These are used by test_examples.py to discover the examples to run. +from zipline.utils.calendars import register_calendar, get_calendar + EXAMPLE_MODULES = {} for f in os.listdir(os.path.dirname(__file__)): if not f.endswith('.py') or f == '__init__.py': @@ -65,6 +67,9 @@ def run_example(example_name, environ): Run an example module from zipline.examples. """ mod = EXAMPLE_MODULES[example_name] + + register_calendar("YAHOO", get_calendar("NYSE"), force=True) + return run_algorithm( initialize=getattr(mod, 'initialize', None), handle_data=getattr(mod, 'handle_data', None),