From ac7b44af23524917f2cb232e4f427298c38458d1 Mon Sep 17 00:00:00 2001 From: Scott Sanderson Date: Sat, 7 Nov 2015 15:50:30 -0500 Subject: [PATCH] ENH: Add USEquityPricingLoader.from_files. --- .../pipeline/loaders/equity_pricing_loader.py | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/zipline/pipeline/loaders/equity_pricing_loader.py b/zipline/pipeline/loaders/equity_pricing_loader.py index 8d00f602..6494e977 100644 --- a/zipline/pipeline/loaders/equity_pricing_loader.py +++ b/zipline/pipeline/loaders/equity_pricing_loader.py @@ -16,6 +16,10 @@ from numpy import ( uint32, ) +from zipline.data.us_equity_pricing import ( + BcolzDailyBarReader, + SQLiteAdjustmentReader, +) from zipline.lib.adjusted_array import ( adjusted_array, ) @@ -40,6 +44,24 @@ class USEquityPricingLoader(PipelineLoader): self._calendar = self.raw_price_loader._calendar self.adjustments_loader = adjustments_loader + @classmethod + def from_files(cls, pricing_path, adjustments_path): + """ + Create a loader from a bcolz equity pricing dir and a SQLite + adjustments path. + + Parameters + ---------- + pricing_path : str + Path to a bcolz directory written by a BcolzDailyBarWriter. + adjusments_path : str + Path to an adjusments db written by a SQLiteAdjustmentWriter. + """ + return cls( + BcolzDailyBarReader(pricing_path), + SQLiteAdjustmentReader(adjustments_path) + ) + def load_adjusted_array(self, columns, dates, assets, mask): # load_adjusted_array is called with dates on which the user's algo # will be shown data, which means we need to return the data that would