mirror of
https://github.com/wassname/catalyst.git
synced 2026-06-30 17:39:36 +08:00
Merge pull request #1584 from quantopian/allow-single-continuous-future
BUG: Fix `data.history` with a single continuous future.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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]
|
||||
@@ -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!
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user