ENH: Use bundle name as exchange value

This commit is contained in:
Jean Bredeche
2016-08-02 22:53:08 -04:00
parent e6af4e4f1b
commit 7d4b19a7f0
4 changed files with 15 additions and 2 deletions
+4 -1
View File
@@ -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"))
+1 -1
View File
@@ -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
+5
View File
@@ -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 = []
+5
View File
@@ -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),