mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-24 13:00:57 +08:00
MAINT: More renaming.
s/FFCEngine/PipelineEngine/ s/FFCLoader/PipelineLoader/
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
"""
|
||||
Base class for FFC unit tests.
|
||||
Base class for Pipeline API unittests.
|
||||
"""
|
||||
from functools import wraps
|
||||
from unittest import TestCase
|
||||
@@ -9,7 +9,7 @@ from pandas import date_range, Int64Index, DataFrame
|
||||
from six import iteritems
|
||||
|
||||
from zipline.finance.trading import TradingEnvironment
|
||||
from zipline.pipeline.engine import SimpleFFCEngine
|
||||
from zipline.pipeline.engine import SimplePipelineEngine
|
||||
from zipline.pipeline.term import AssetExists
|
||||
from zipline.utils.pandas_utils import explode
|
||||
from zipline.utils.test_utils import make_simple_asset_info, ExplodingObject
|
||||
@@ -43,7 +43,7 @@ def with_defaults(**default_funcs):
|
||||
with_default_shape = with_defaults(shape=lambda self: self.default_shape)
|
||||
|
||||
|
||||
class BaseFFCTestCase(TestCase):
|
||||
class BasePipelineTestCase(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.__calendar = date_range('2014', '2015', freq=trading_day)
|
||||
@@ -81,7 +81,7 @@ class BaseFFCTestCase(TestCase):
|
||||
graph : zipline.pipeline.graph.TermGraph
|
||||
Graph to run.
|
||||
initial_workspace : dict
|
||||
Initial workspace to forward to SimpleFFCEngine.compute_chunk.
|
||||
Initial workspace to forward to SimplePipelineEngine.compute_chunk.
|
||||
mask : DataFrame, optional
|
||||
This is a value to pass to `initial_workspace` as the mask from
|
||||
`AssetExists()`. Defaults to a frame of shape `self.default_shape`
|
||||
@@ -92,7 +92,7 @@ class BaseFFCTestCase(TestCase):
|
||||
results : dict
|
||||
Mapping from termname -> computed result.
|
||||
"""
|
||||
engine = SimpleFFCEngine(
|
||||
engine = SimplePipelineEngine(
|
||||
ExplodingObject(),
|
||||
self.__calendar,
|
||||
self.__finder,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"""
|
||||
Tests for SimpleFFCEngine
|
||||
Tests for SimplePipelineEngine
|
||||
"""
|
||||
from __future__ import division
|
||||
from unittest import TestCase
|
||||
@@ -33,12 +33,12 @@ from zipline.pipeline.loaders.synthetic import (
|
||||
from zipline.finance.trading import TradingEnvironment
|
||||
from zipline.pipeline import Pipeline
|
||||
from zipline.pipeline.data import USEquityPricing
|
||||
from zipline.pipeline.loaders.frame import DataFrameFFCLoader, MULTIPLY
|
||||
from zipline.pipeline.loaders.frame import DataFrameLoader, MULTIPLY
|
||||
from zipline.pipeline.loaders.equity_pricing_loader import (
|
||||
BcolzDailyBarReader,
|
||||
USEquityPricingLoader,
|
||||
)
|
||||
from zipline.pipeline.engine import SimpleFFCEngine
|
||||
from zipline.pipeline.engine import SimplePipelineEngine
|
||||
from zipline.pipeline.factor import CustomFactor
|
||||
from zipline.pipeline.factor.technical import (
|
||||
MaxDrawdown,
|
||||
@@ -115,7 +115,7 @@ class ConstantInputTestCase(TestCase):
|
||||
|
||||
def test_bad_dates(self):
|
||||
loader = self.loader
|
||||
engine = SimpleFFCEngine(loader, self.dates, self.asset_finder)
|
||||
engine = SimplePipelineEngine(loader, self.dates, self.asset_finder)
|
||||
|
||||
p = Pipeline('test')
|
||||
|
||||
@@ -129,7 +129,7 @@ class ConstantInputTestCase(TestCase):
|
||||
loader = self.loader
|
||||
finder = self.asset_finder
|
||||
assets = array(self.assets)
|
||||
engine = SimpleFFCEngine(loader, self.dates, self.asset_finder)
|
||||
engine = SimplePipelineEngine(loader, self.dates, self.asset_finder)
|
||||
num_dates = 5
|
||||
dates = self.dates[10:10 + num_dates]
|
||||
|
||||
@@ -152,7 +152,7 @@ class ConstantInputTestCase(TestCase):
|
||||
loader = self.loader
|
||||
finder = self.asset_finder
|
||||
assets = self.assets
|
||||
engine = SimpleFFCEngine(loader, self.dates, self.asset_finder)
|
||||
engine = SimplePipelineEngine(loader, self.dates, self.asset_finder)
|
||||
result_shape = (num_dates, num_assets) = (5, len(assets))
|
||||
dates = self.dates[10:10 + num_dates]
|
||||
|
||||
@@ -186,7 +186,7 @@ class ConstantInputTestCase(TestCase):
|
||||
loader = self.loader
|
||||
finder = self.asset_finder
|
||||
assets = self.assets
|
||||
engine = SimpleFFCEngine(loader, self.dates, self.asset_finder)
|
||||
engine = SimplePipelineEngine(loader, self.dates, self.asset_finder)
|
||||
shape = num_dates, num_assets = (5, len(assets))
|
||||
dates = self.dates[10:10 + num_dates]
|
||||
|
||||
@@ -230,7 +230,7 @@ class ConstantInputTestCase(TestCase):
|
||||
def test_numeric_factor(self):
|
||||
constants = self.constants
|
||||
loader = self.loader
|
||||
engine = SimpleFFCEngine(loader, self.dates, self.asset_finder)
|
||||
engine = SimplePipelineEngine(loader, self.dates, self.asset_finder)
|
||||
num_dates = 5
|
||||
dates = self.dates[10:10 + num_dates]
|
||||
high, low = USEquityPricing.high, USEquityPricing.low
|
||||
@@ -347,7 +347,7 @@ class FrameInputTestCase(TestCase):
|
||||
]
|
||||
)
|
||||
low_base = DataFrame(self.make_frame(30.0))
|
||||
low_loader = DataFrameFFCLoader(low, low_base.copy(), adjustments=None)
|
||||
low_loader = DataFrameLoader(low, low_base.copy(), adjustments=None)
|
||||
|
||||
# Pre-apply inverse of adjustments to the baseline.
|
||||
high_base = DataFrame(self.make_frame(30.0))
|
||||
@@ -355,10 +355,10 @@ class FrameInputTestCase(TestCase):
|
||||
high_base.iloc[:apply_idxs[1], 1] /= 3.0
|
||||
high_base.iloc[:apply_idxs[2], 1] /= 5.0
|
||||
|
||||
high_loader = DataFrameFFCLoader(high, high_base, adjustments)
|
||||
high_loader = DataFrameLoader(high, high_base, adjustments)
|
||||
loader = MultiColumnLoader({low: low_loader, high: high_loader})
|
||||
|
||||
engine = SimpleFFCEngine(loader, self.dates, self.asset_finder)
|
||||
engine = SimplePipelineEngine(loader, self.dates, self.asset_finder)
|
||||
|
||||
for window_length in range(1, 4):
|
||||
low_mavg = SimpleMovingAverage(
|
||||
@@ -468,7 +468,7 @@ class SyntheticBcolzTestCase(TestCase):
|
||||
df.ix[end + 1:, asset] = nan # +1 to *not* overwrite end_date
|
||||
|
||||
def test_SMA(self):
|
||||
engine = SimpleFFCEngine(
|
||||
engine = SimplePipelineEngine(
|
||||
self.ffc_loader,
|
||||
self.env.trading_days,
|
||||
self.finder,
|
||||
@@ -520,7 +520,7 @@ class SyntheticBcolzTestCase(TestCase):
|
||||
# computed results are pretty much useless (everything is either NaN)
|
||||
# or zero, but verifying we correctly handle those corner cases is
|
||||
# valuable.
|
||||
engine = SimpleFFCEngine(
|
||||
engine = SimplePipelineEngine(
|
||||
self.ffc_loader,
|
||||
self.env.trading_days,
|
||||
self.finder,
|
||||
@@ -588,7 +588,7 @@ class MultiColumnLoaderTestCase(TestCase):
|
||||
dates=self.dates,
|
||||
assets=self.assets,
|
||||
)
|
||||
engine = SimpleFFCEngine(loader, self.dates, self.asset_finder)
|
||||
engine = SimplePipelineEngine(loader, self.dates, self.asset_finder)
|
||||
|
||||
sumdiff = RollingSumDifference()
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ from zipline.errors import UnknownRankMethod
|
||||
from zipline.pipeline import Factor, Filter, TermGraph
|
||||
from zipline.utils.test_utils import check_arrays
|
||||
|
||||
from .base import BaseFFCTestCase
|
||||
from .base import BasePipelineTestCase
|
||||
|
||||
|
||||
class F(Factor):
|
||||
@@ -19,7 +19,7 @@ class Mask(Filter):
|
||||
window_length = 0
|
||||
|
||||
|
||||
class FactorTestCase(BaseFFCTestCase):
|
||||
class FactorTestCase(BasePipelineTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(FactorTestCase, self).setUp()
|
||||
|
||||
@@ -23,7 +23,7 @@ from zipline.errors import BadPercentileBounds
|
||||
from zipline.pipeline import Filter, Factor, TermGraph
|
||||
from zipline.utils.test_utils import check_arrays
|
||||
|
||||
from .base import BaseFFCTestCase, with_default_shape
|
||||
from .base import BasePipelineTestCase, with_default_shape
|
||||
|
||||
|
||||
def rowwise_rank(array, mask=None):
|
||||
@@ -69,7 +69,7 @@ class Mask(Filter):
|
||||
window_length = 0
|
||||
|
||||
|
||||
class FilterTestCase(BaseFFCTestCase):
|
||||
class FilterTestCase(BasePipelineTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(FilterTestCase, self).setUp()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"""
|
||||
Tests for zipline.pipeline.loaders.frame.DataFrameFFCLoader.
|
||||
Tests for zipline.pipeline.loaders.frame.DataFrameLoader.
|
||||
"""
|
||||
from unittest import TestCase
|
||||
|
||||
@@ -20,14 +20,14 @@ from zipline.lib.adjustment import (
|
||||
from zipline.pipeline.data import USEquityPricing
|
||||
from zipline.pipeline.loaders.frame import (
|
||||
ADD,
|
||||
DataFrameFFCLoader,
|
||||
DataFrameLoader,
|
||||
MULTIPLY,
|
||||
OVERWRITE,
|
||||
)
|
||||
from zipline.utils.tradingcalendar import trading_day
|
||||
|
||||
|
||||
class DataFrameFFCLoaderTestCase(TestCase):
|
||||
class DataFrameLoaderTestCase(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.nsids = 5
|
||||
@@ -48,7 +48,7 @@ class DataFrameFFCLoaderTestCase(TestCase):
|
||||
def test_bad_input(self):
|
||||
data = arange(100).reshape(self.ndates, self.nsids)
|
||||
baseline = DataFrame(data, index=self.dates, columns=self.sids)
|
||||
loader = DataFrameFFCLoader(
|
||||
loader = DataFrameLoader(
|
||||
USEquityPricing.close,
|
||||
baseline,
|
||||
)
|
||||
@@ -71,10 +71,7 @@ class DataFrameFFCLoaderTestCase(TestCase):
|
||||
def test_baseline(self):
|
||||
data = arange(100).reshape(self.ndates, self.nsids)
|
||||
baseline = DataFrame(data, index=self.dates, columns=self.sids)
|
||||
loader = DataFrameFFCLoader(
|
||||
USEquityPricing.close,
|
||||
baseline,
|
||||
)
|
||||
loader = DataFrameLoader(USEquityPricing.close, baseline)
|
||||
|
||||
dates_slice = slice(None, 10, None)
|
||||
sids_slice = slice(1, 3, None)
|
||||
@@ -178,7 +175,7 @@ class DataFrameFFCLoaderTestCase(TestCase):
|
||||
]
|
||||
|
||||
adjustments = DataFrame(relevant_adjustments + irrelevant_adjustments)
|
||||
loader = DataFrameFFCLoader(
|
||||
loader = DataFrameLoader(
|
||||
USEquityPricing.close,
|
||||
baseline,
|
||||
adjustments=adjustments,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"""
|
||||
Tests for Algorithms running the full FFC stack.
|
||||
Tests for Algorithms using the Pipeline API.
|
||||
"""
|
||||
from unittest import TestCase
|
||||
from os.path import (
|
||||
@@ -44,7 +44,7 @@ from zipline.finance import trading
|
||||
from zipline.pipeline import Pipeline
|
||||
from zipline.pipeline.factor.technical import VWAP
|
||||
from zipline.pipeline.data import USEquityPricing
|
||||
from zipline.pipeline.loaders.frame import DataFrameFFCLoader, MULTIPLY
|
||||
from zipline.pipeline.loaders.frame import DataFrameLoader, MULTIPLY
|
||||
from zipline.pipeline.loaders.equity_pricing_loader import (
|
||||
BcolzDailyBarReader,
|
||||
DailyBarWriterFromCSVs,
|
||||
@@ -149,7 +149,7 @@ class ClosesOnly(TestCase):
|
||||
self.adj_closes = adj_closes = self.closes.copy()
|
||||
adj_closes.ix[:self.split_date, self.split_asset] *= self.split_ratio
|
||||
|
||||
self.ffc_loader = DataFrameFFCLoader(
|
||||
self.ffc_loader = DataFrameLoader(
|
||||
column=USEquityPricing.close,
|
||||
baseline=self.closes,
|
||||
adjustments=self.adjustments,
|
||||
@@ -304,7 +304,7 @@ class ClosesOnly(TestCase):
|
||||
algo.run(source=self.closes.iloc[10:17])
|
||||
|
||||
|
||||
class FFCAlgorithmTestCase(TestCase):
|
||||
class PipelineAlgorithmTestCase(TestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
|
||||
@@ -75,8 +75,8 @@ from zipline.assets.futures import FutureChain
|
||||
from zipline.gens.composites import date_sorted_sources
|
||||
from zipline.gens.tradesimulation import AlgorithmSimulator
|
||||
from zipline.pipeline.engine import (
|
||||
NoOpFFCEngine,
|
||||
SimpleFFCEngine,
|
||||
NoOpPipelineEngine,
|
||||
SimplePipelineEngine,
|
||||
)
|
||||
from zipline.sources import DataFrameSource, DataPanelSource
|
||||
from zipline.utils.api_support import (
|
||||
@@ -323,18 +323,18 @@ class TradingAlgorithm(object):
|
||||
|
||||
def init_engine(self, loader):
|
||||
"""
|
||||
Construct and save an FFCEngine from loader.
|
||||
Construct and save a PipelineEngine from loader.
|
||||
|
||||
If loader is None, constructs a NoOpFFCEngine.
|
||||
If loader is None, constructs a NoOpPipelineEngine.
|
||||
"""
|
||||
if loader is not None:
|
||||
self.engine = SimpleFFCEngine(
|
||||
self.engine = SimplePipelineEngine(
|
||||
loader,
|
||||
self.trading_environment.trading_days,
|
||||
self.asset_finder,
|
||||
)
|
||||
else:
|
||||
self.engine = NoOpFFCEngine()
|
||||
self.engine = NoOpPipelineEngine()
|
||||
|
||||
def initialize(self, *args, **kwargs):
|
||||
"""
|
||||
@@ -1369,7 +1369,7 @@ class TradingAlgorithm(object):
|
||||
|
||||
See Also
|
||||
--------
|
||||
:meth:`zipline.pipeline.engine.FFCEngine.run_pipeline`
|
||||
:meth:`zipline.pipeline.engine.PipelineEngine.run_pipeline`
|
||||
"""
|
||||
# NOTE: We don't currently support multiple pipelines, but we plan to
|
||||
# in the future.
|
||||
@@ -1421,7 +1421,7 @@ class TradingAlgorithm(object):
|
||||
|
||||
See Also
|
||||
--------
|
||||
FFCEngine.run_pipeline
|
||||
PipelineEngine.run_pipeline
|
||||
"""
|
||||
days = self.trading_environment.trading_days
|
||||
|
||||
|
||||
@@ -627,7 +627,7 @@ class AssetFinder(object):
|
||||
See Also
|
||||
--------
|
||||
numpy.putmask
|
||||
zipline.pipeline.engine.SimpleFFCEngine._compute_root_mask
|
||||
zipline.pipeline.engine.SimplePipelineEngine._compute_root_mask
|
||||
"""
|
||||
# This is a less than ideal place to do this, because if someone adds
|
||||
# assets to the finder after we've touched lifetimes we won't have
|
||||
|
||||
+3
-3
@@ -318,8 +318,8 @@ class WindowLengthNotPositive(ZiplineError):
|
||||
|
||||
class InputTermNotAtomic(ZiplineError):
|
||||
"""
|
||||
Raised when a non-atomic term is specified as an input to an FFC term with
|
||||
a lookback window.
|
||||
Raised when a non-atomic term is specified as an input to a Pipeline API
|
||||
term with a lookback window.
|
||||
"""
|
||||
msg = (
|
||||
"Can't compute {parent} with non-atomic input {child}."
|
||||
@@ -409,7 +409,7 @@ class NoSuchPipeline(ZiplineError, KeyError):
|
||||
|
||||
class UnsupportedDataType(ZiplineError):
|
||||
"""
|
||||
Raised by FFC CustomFactors with unsupported dtypes.
|
||||
Raised by CustomFactors with unsupported dtypes.
|
||||
"""
|
||||
msg = "CustomFactors with dtype {dtype} are not supported."
|
||||
|
||||
|
||||
+10
-10
@@ -1,5 +1,5 @@
|
||||
"""
|
||||
Compute Engine for FFC API
|
||||
Compute Engine definitions for the Pipeline API.
|
||||
"""
|
||||
from abc import (
|
||||
ABCMeta,
|
||||
@@ -28,7 +28,7 @@ from zipline.utils.pandas_utils import explode
|
||||
from .term import AssetExists
|
||||
|
||||
|
||||
class FFCEngine(with_metaclass(ABCMeta)):
|
||||
class PipelineEngine(with_metaclass(ABCMeta)):
|
||||
|
||||
@abstractmethod
|
||||
def run_pipeline(self, pipeline, start_date, end_date):
|
||||
@@ -63,9 +63,9 @@ class FFCEngine(with_metaclass(ABCMeta)):
|
||||
raise NotImplementedError("run_pipeline")
|
||||
|
||||
|
||||
class NoOpFFCEngine(FFCEngine):
|
||||
class NoOpPipelineEngine(PipelineEngine):
|
||||
"""
|
||||
An FFCEngine that doesn't do anything.
|
||||
A PipelineEngine that doesn't do anything.
|
||||
"""
|
||||
def run_pipeline(self, pipeline, start_date, end_date):
|
||||
return DataFrame(
|
||||
@@ -76,13 +76,13 @@ class NoOpFFCEngine(FFCEngine):
|
||||
)
|
||||
|
||||
|
||||
class SimpleFFCEngine(object):
|
||||
class SimplePipelineEngine(object):
|
||||
"""
|
||||
FFC Engine class that computes each term independently.
|
||||
PipelineEngine class that computes each term independently.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
loader : FFCLoader
|
||||
loader : PipelineLoader
|
||||
A loader to use to retrieve raw data for atomic terms.
|
||||
calendar : DatetimeIndex
|
||||
Array of dates to consider as trading days when computing a range
|
||||
@@ -149,7 +149,7 @@ class SimpleFFCEngine(object):
|
||||
|
||||
See Also
|
||||
--------
|
||||
FFCEngine.run_pipeline
|
||||
PipelineEngine.run_pipeline
|
||||
"""
|
||||
if end_date <= start_date:
|
||||
raise ValueError(
|
||||
@@ -205,7 +205,7 @@ class SimpleFFCEngine(object):
|
||||
start_idx, end_idx = self._calendar.slice_locs(start_date, end_date)
|
||||
if start_idx < extra_rows:
|
||||
raise NoFurtherDataError(
|
||||
msg="Insufficient data to compute FFC Matrix: "
|
||||
msg="Insufficient data to compute Pipeline mask: "
|
||||
"start date was %s, "
|
||||
"earliest known date was %s, "
|
||||
"and %d extra rows were requested." % (
|
||||
@@ -275,7 +275,7 @@ class SimpleFFCEngine(object):
|
||||
|
||||
def compute_chunk(self, graph, dates, assets, initial_workspace):
|
||||
"""
|
||||
Compute the FFC terms in the graph for the requested start and end
|
||||
Compute the Pipeline terms in the graph for the requested start and end
|
||||
dates.
|
||||
|
||||
Parameters
|
||||
|
||||
@@ -437,7 +437,7 @@ class CustomFactor(RequiredWindowLengthMixin, CustomTermMixin, Factor):
|
||||
Base class for user-defined Factors operating on windows of raw data.
|
||||
|
||||
TODO: This is basically the most important class to document in the whole
|
||||
FFC API...
|
||||
Pipeline API...
|
||||
|
||||
We currently only support CustomFactors of type float64.
|
||||
"""
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"""
|
||||
FFC-specific extensions to networkx.DiGraph
|
||||
Dependency-Graph representation of Pipeline API terms.
|
||||
"""
|
||||
from networkx import (
|
||||
DiGraph,
|
||||
@@ -16,7 +16,7 @@ class CyclicDependency(Exception):
|
||||
|
||||
class TermGraph(DiGraph):
|
||||
"""
|
||||
Graph represention of FFC Term dependencies.
|
||||
Graph represention of Pipeline Term dependencies.
|
||||
|
||||
Each node in the graph has an `extra_rows` attribute, indicating how many,
|
||||
if any, extra rows we should compute for the node. Extra rows are most
|
||||
@@ -99,8 +99,8 @@ class TermGraph(DiGraph):
|
||||
See Also
|
||||
--------
|
||||
zipline.pipeline.graph.TermGraph.offset
|
||||
zipline.pipeline.engine.SimpleFFCEngine._inputs_for_term
|
||||
zipline.pipeline.engine.SimpleFFCEngine._mask_for_term
|
||||
zipline.pipeline.engine.SimplePipelineEngine._inputs_for_term
|
||||
zipline.pipeline.engine.SimplePipelineEngine._mask_and_dates_for_term
|
||||
"""
|
||||
out = {}
|
||||
for term in self:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"""
|
||||
Base class for FFC data loaders.
|
||||
Base class for Pipeline API data loaders.
|
||||
"""
|
||||
from abc import (
|
||||
ABCMeta,
|
||||
@@ -10,7 +10,7 @@ from abc import (
|
||||
from six import with_metaclass
|
||||
|
||||
|
||||
class FFCLoader(with_metaclass(ABCMeta)):
|
||||
class PipelineLoader(with_metaclass(ABCMeta)):
|
||||
"""
|
||||
ABC for classes that can load data for use with zipline.pipeline APIs.
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ from zipline.lib.adjusted_array import (
|
||||
)
|
||||
from zipline.errors import NoFurtherDataError
|
||||
|
||||
from .base import FFCLoader
|
||||
from .base import PipelineLoader
|
||||
from ._equities import _compute_row_slices, _read_bcolz_data
|
||||
from ._adjustments import load_adjustments_from_sqlite
|
||||
|
||||
@@ -571,9 +571,9 @@ class SQLiteAdjustmentReader(object):
|
||||
)
|
||||
|
||||
|
||||
class USEquityPricingLoader(FFCLoader):
|
||||
class USEquityPricingLoader(PipelineLoader):
|
||||
"""
|
||||
FFCLoader for US Equity Pricing
|
||||
PipelineLoader for US Equity Pricing data
|
||||
|
||||
Delegates loading of baselines and adjustments.
|
||||
"""
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"""
|
||||
FFC Loader accepting a DataFrame as input.
|
||||
PipelineLoader accepting a DataFrame as input.
|
||||
"""
|
||||
from numpy import (
|
||||
ix_,
|
||||
@@ -18,7 +18,7 @@ from zipline.lib.adjustment import (
|
||||
Float64Overwrite,
|
||||
)
|
||||
|
||||
from .base import FFCLoader
|
||||
from .base import PipelineLoader
|
||||
|
||||
|
||||
ADD, MULTIPLY, OVERWRITE = range(3)
|
||||
@@ -37,9 +37,9 @@ ADJUSTMENT_COLUMNS = Index([
|
||||
])
|
||||
|
||||
|
||||
class DataFrameFFCLoader(FFCLoader):
|
||||
class DataFrameLoader(PipelineLoader):
|
||||
"""
|
||||
An FFCLoader that reads its input from DataFrames.
|
||||
A PipelineLoader that reads its input from DataFrames.
|
||||
|
||||
Mostly useful for testing, but can also be used for real work if your data
|
||||
fits in memory.
|
||||
|
||||
@@ -15,8 +15,8 @@ from pandas import DataFrame, Timestamp
|
||||
from six import iteritems
|
||||
from sqlite3 import connect as sqlite3_connect
|
||||
|
||||
from .base import FFCLoader
|
||||
from .frame import DataFrameFFCLoader
|
||||
from .base import PipelineLoader
|
||||
from .frame import DataFrameLoader
|
||||
from .equity_pricing_loader import (
|
||||
BcolzDailyBarWriter,
|
||||
SQLiteAdjustmentReader,
|
||||
@@ -32,9 +32,9 @@ def nanos_to_seconds(nanos):
|
||||
return nanos / (1000 * 1000 * 1000)
|
||||
|
||||
|
||||
class MultiColumnLoader(FFCLoader):
|
||||
class MultiColumnLoader(PipelineLoader):
|
||||
"""
|
||||
FFCLoader that can delegate to sub-loaders.
|
||||
PipelineLoader that can delegate to sub-loaders.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@@ -60,7 +60,7 @@ class MultiColumnLoader(FFCLoader):
|
||||
|
||||
class ConstantLoader(MultiColumnLoader):
|
||||
"""
|
||||
Synthetic FFCLoader that returns a constant value for each column.
|
||||
Synthetic PipelineLoader that returns a constant value for each column.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@@ -85,7 +85,7 @@ class ConstantLoader(MultiColumnLoader):
|
||||
columns=assets,
|
||||
dtype=column.dtype,
|
||||
)
|
||||
loaders[column] = DataFrameFFCLoader(
|
||||
loaders[column] = DataFrameLoader(
|
||||
column=column,
|
||||
baseline=frame,
|
||||
adjustments=None,
|
||||
|
||||
@@ -40,7 +40,7 @@ class NotSpecified(object):
|
||||
|
||||
class Term(object):
|
||||
"""
|
||||
Base class for terms in an FFC API compute graph.
|
||||
Base class for terms in a Pipeline API compute graph.
|
||||
"""
|
||||
# These are NotSpecified because a subclass is required to provide them.
|
||||
inputs = NotSpecified
|
||||
@@ -63,7 +63,7 @@ class Term(object):
|
||||
Memoized constructor for Terms.
|
||||
|
||||
Caching previously-constructed Terms is useful because it allows us to
|
||||
only compute equivalent sub-expressions once when traversing an FFC
|
||||
only compute equivalent sub-expressions once when traversing a Pipeline
|
||||
dependency graph.
|
||||
|
||||
Caching previously-constructed Terms is **sane** because terms and
|
||||
@@ -301,7 +301,7 @@ class AssetExists(Term):
|
||||
|
||||
This is morally a Filter, in the sense that it produces a boolean value for
|
||||
every asset on every date. We don't subclass Filter, however, because
|
||||
`AssetExists` is computed directly by the FFCEngine.
|
||||
`AssetExists` is computed directly by the PipelineEngine.
|
||||
|
||||
See Also
|
||||
--------
|
||||
@@ -314,7 +314,7 @@ class AssetExists(Term):
|
||||
|
||||
def _compute(self, *args, **kwargs):
|
||||
# TODO: Consider moving the bulk of the logic from
|
||||
# SimpleFFCEngine._compute_root_mask here.
|
||||
# SimplePipelineEngine._compute_root_mask here.
|
||||
raise NotImplementedError(
|
||||
"Direct computation of AssetExists is not supported!"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user