diff --git a/zipline/gens/composites.py b/zipline/gens/composites.py index 964bbe42..af2fdc8c 100644 --- a/zipline/gens/composites.py +++ b/zipline/gens/composites.py @@ -18,15 +18,15 @@ def date_sorted_sources(*sources): """ for source in sources: - assert source.__dict__.has_key('__init__') - assert source.__dict__.has_key('get_hash') + assert iter(source), "Source %s not iterable" % source + assert source.__class__.__dict__.has_key('get_hash'), "No get_hash" # Get name hashes to pass to date_sort. - names = [source.get_hash for source in sources) + names = [source.get_hash() for source in sources] # Convert the list of generators into a flat stream by pulling # one element at a time from each. - stream_in = roundrobin(source_gens, names) + stream_in = roundrobin(sources, names) # Guarantee the flat stream will be sorted by date, using source_id as # tie-breaker, which is fully deterministic (given deterministic string diff --git a/zipline/gens/examples.py b/zipline/gens/examples.py index 93f77d47..5a24493f 100644 --- a/zipline/gens/examples.py +++ b/zipline/gens/examples.py @@ -23,7 +23,7 @@ if __name__ == "__main__": 'delta' : timedelta(minutes = 1), 'filter' : filter } - bundle_a = SourceBundle(SpecificEquityTrades, args_a, kwargs_a) + source_a = SpecificEquityTrades(*args_a, **kwargs_a) #Set up source b. Two minutes between events. args_b = tuple() @@ -33,12 +33,12 @@ if __name__ == "__main__": 'delta' : timedelta(minutes = 1), 'filter' : filter } - bundle_b = SourceBundle(SpecificEquityTrades, args_b, kwargs_b) + source_b = SpecificEquityTrades(*args_b, **kwargs_b) #Set up source c. Three minutes between events. sort_out = date_sorted_sources(source_a, source_b) - + # passthrough = TransformBundle(Passthrough, (), {}) # mavg_price = TransformBundle(MovingAverage, (timedelta(minutes = 20), ['price']), {}) # tnfm_bundles = (passthrough, mavg_price)