Skip to content

Commit

Permalink
Merge pull request #1584 from quantopian/allow-single-continuous-future
Browse files Browse the repository at this point in the history
BUG: Fix `data.history` with a single continuous future.
  • Loading branch information
ehebert committed Nov 8, 2016
2 parents 25eb13c + 3e3d95e commit 44b97be
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions zipline/_protocol.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ from six import iteritems, PY2, string_types
from cpython cimport bool
from collections import Iterable

from zipline.assets import Asset, Future
from zipline.assets import Asset, AssetConvertible, Future
from zipline.assets.continuous_futures import ContinuousFuture
from zipline.zipline_warnings import ZiplineDeprecationWarning

Expand Down Expand Up @@ -637,7 +637,7 @@ cdef class BarData:
last market close instead.
"""
if isinstance(fields, string_types):
single_asset = isinstance(assets, Asset)
single_asset = isinstance(assets, AssetConvertible)

if single_asset:
asset_list = [assets]
Expand Down Expand Up @@ -670,7 +670,7 @@ cdef class BarData:
# columns are the assets, indexed by dt.
return df
else:
if isinstance(assets, Asset):
if isinstance(assets, AssetConvertible):
# one asset, multiple fields. for now, just make multiple
# history calls, one per field, then stitch together the
# results. this can definitely be optimized!
Expand Down
1 change: 1 addition & 0 deletions zipline/assets/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1218,6 +1218,7 @@ class AssetConvertible(with_metaclass(ABCMeta)):

AssetConvertible.register(Integral)
AssetConvertible.register(Asset)
AssetConvertible.register(ContinuousFuture)
# Use six.string_types for Python2/3 compatibility
for _type in string_types:
AssetConvertible.register(_type)
Expand Down

0 comments on commit 44b97be

Please sign in to comment.