Skip to content

Commit

Permalink
Merge pull request #22 from tejtw/v2.0.0rc3
Browse files Browse the repository at this point in the history
MAINT:loaders
  • Loading branch information
Han860207 authored Feb 27, 2024
2 parents ff64de1 + 6cd17de commit bfd7d36
Show file tree
Hide file tree
Showing 12 changed files with 3,270 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/zipline/pipeline/loaders/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from .equity_pricing_loader import (
EquityPricingLoader,
USEquityPricingLoader,
)
from .fundamentals import TQuantFundamentalsPipelineLoader, TQuantAlternativesPipelineLoader


import os
module_dir = os.path.dirname(os.path.abspath(__file__))
ls_files = os.listdir(module_dir)
ndb_exist = [f for f in ls_files if f.startswith('ndb')]
if ndb_exist:
from .ndb_stk import NDBStkPipelineLoader
from .ndb_fin import NDBFinPipelineLoader



__all__ = [
"EquityPricingLoader",
"USEquityPricingLoader",
]
44 changes: 44 additions & 0 deletions src/zipline/pipeline/loaders/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
"""
Base class for Pipeline API data loaders.
"""
from interface import default, Interface


class PipelineLoader(Interface):
"""Interface for PipelineLoaders."""

def load_adjusted_array(self, domain, columns, dates, sids, mask):
"""
Load data for ``columns`` as AdjustedArrays.
Parameters
----------
domain : zipline.pipeline.domain.Domain
The domain of the pipeline for which the requested data must be
loaded.
columns : list[zipline.pipeline.data.dataset.BoundColumn]
Columns for which data is being requested.
dates : pd.DatetimeIndex
Dates for which data is being requested.
sids : pd.Index
Asset identifiers for which data is being requested.
mask : np.array[ndim=2, dtype=bool]
Boolean array of shape (len(dates), len(sids)) indicating dates on
which we believe the requested assets were alive/tradeable. This is
used for optimization by some loaders.
Returns
-------
arrays : dict[BoundColumn -> zipline.lib.adjusted_array.AdjustedArray]
Map from column to an AdjustedArray representing a point-in-time
rolling view over the requested dates for the requested sids.
"""

@default
@property
def currency_aware(self):
"""Whether or not this loader supports currency-conversions.
By default, assume that loaders to not support currency conversions.
"""
return False
Loading

0 comments on commit bfd7d36

Please sign in to comment.