Files
catalyst/zipline/pipeline/__init__.py
T
Scott Sanderson a8b67d352e MAINT: Refactor in prep for downsampled terms.
- Split out extra_rows handling into an `ExecutionPlan` subclass.
  `ExecutionPlan` now requires the dates and calendar against which a
  set of terms will be computed, and now defers to a term's
  `compute_extra_rows` method when deciding how many extra rows are
  required to compute for that term. This will allow downsampled terms
  to request enough extra rows to guarantee that we can maintain consistent
  calculation dates.

  As a consequence of the above, `TermGraph` now only deals with logical
  dependencies, not with metadata surrounding extra row calculations.
  This means that TermGraph can be used to generate dependency
  visualizations in interactive contexts where we don't yet have a
  calendar or start/end dates.

- Refactored test_{filter,factor,classifier} to use check_terms instead
  of run_graph.  This makes it easier to make changes to TermGraph,
  since the testing interface is now to simply provide a dict of terms.

- Refactored BasePipelineTestCase to use fixtures to create an asset
  finder.  This fixes a potential leak of the test's asset db, which was
  not being explicitly cleaned up.

- Refactored test_technical to use BasePipelineTestCase.

- Added a new special term, `InputDates()`, which can be used to request
  date labels for inputs.  Like `AssetExists`, `InputDates` is provided
  in the initial workspace by default.

- Added a default (failing) `_compute` method to `AssetExists` which
  provides a more useful error than AttributeError.
2016-08-17 16:52:09 -04:00

67 lines
1.9 KiB
Python

from __future__ import print_function
from zipline.assets import AssetFinder
from .classifiers import Classifier, CustomClassifier
from .engine import SimplePipelineEngine
from .factors import Factor, CustomFactor
from .filters import Filter, CustomFilter
from .term import Term
from .graph import ExecutionPlan, TermGraph
from .pipeline import Pipeline
from .loaders import USEquityPricingLoader
def engine_from_files(daily_bar_path,
adjustments_path,
asset_db_path,
calendar,
warmup_assets=False):
"""
Construct a SimplePipelineEngine from local filesystem resources.
Parameters
----------
daily_bar_path : str
Path to pass to `BcolzDailyBarReader`.
adjustments_path : str
Path to pass to SQLiteAdjustmentReader.
asset_db_path : str
Path to pass to `AssetFinder`.
calendar : pd.DatetimeIndex
Calendar to use for the loader.
warmup_assets : bool, optional
Whether or not to populate AssetFinder caches. This can speed up
initial latency on subsequent pipeline runs, at the cost of extra
memory consumption. Default is False
"""
loader = USEquityPricingLoader.from_files(daily_bar_path, adjustments_path)
if not asset_db_path.startswith("sqlite:"):
asset_db_path = "sqlite:///" + asset_db_path
asset_finder = AssetFinder(asset_db_path)
if warmup_assets:
results = asset_finder.retrieve_all(asset_finder.sids)
print("Warmed up %d assets." % len(results))
return SimplePipelineEngine(
lambda _: loader,
calendar,
asset_finder,
)
__all__ = (
'Classifier',
'CustomFactor',
'CustomFilter',
'CustomClassifier',
'engine_from_files',
'ExecutionPlan',
'Factor',
'Filter',
'Pipeline',
'SimplePipelineEngine',
'Term',
'TermGraph',
)