mirror of
https://github.com/wassname/catalyst.git
synced 2026-08-15 12:15:22 +08:00
ENH: Rewrite of Zipline to use lazy access pattern
More documentation to follow in release notes. Based on lazy-mainline branch, see for more details. Also-By: Jean Bredeche <jean@quantopian.com> Also-By: Andrew Liang <aliang@quantopian.com> Also-By: Abhijeet Kalyan <akalyan@quantopian.com>
This commit is contained in:
committed by
Jean Bredeche
parent
822f8891fe
commit
16fd6681a6
@@ -14,6 +14,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
from __future__ import print_function
|
||||
from functools import partial
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
@@ -89,6 +90,12 @@ ext_modules = [
|
||||
Extension('zipline.lib.rank', ['zipline/lib/rank.pyx']),
|
||||
Extension('zipline.data._equities', ['zipline/data/_equities.pyx']),
|
||||
Extension('zipline.data._adjustments', ['zipline/data/_adjustments.pyx']),
|
||||
Extension('zipline._protocol', ['zipline/_protocol.pyx']),
|
||||
Extension('zipline.gens.sim_engine', ['zipline/gens/sim_engine.pyx']),
|
||||
Extension(
|
||||
'zipline.data._minute_bar_internal',
|
||||
['zipline/data/_minute_bar_internal.pyx']
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
@@ -156,19 +163,27 @@ def _with_bounds(req):
|
||||
REQ_PATTERN = re.compile("([^=<>]+)([<=>]{1,2})(.*)")
|
||||
|
||||
|
||||
def _conda_format(req):
|
||||
def _conda_format(req, selector=None):
|
||||
match = REQ_PATTERN.match(req)
|
||||
if match and match.group(1).lower() == 'numpy':
|
||||
return 'numpy x.x'
|
||||
line = 'numpy x.x'
|
||||
else:
|
||||
line = REQ_PATTERN.sub(
|
||||
lambda m: '%s %s%s' % (m.group(1).lower(), m.group(2), m.group(3)),
|
||||
req,
|
||||
1,
|
||||
)
|
||||
|
||||
return REQ_PATTERN.sub(
|
||||
lambda m: '%s %s%s' % (m.group(1).lower(), m.group(2), m.group(3)),
|
||||
req,
|
||||
1,
|
||||
)
|
||||
if selector is not None:
|
||||
line += ' # [%s]' % selector
|
||||
|
||||
return line
|
||||
|
||||
|
||||
def read_requirements(path, strict_bounds, conda_format=False):
|
||||
def read_requirements(path,
|
||||
strict_bounds,
|
||||
conda_format=False,
|
||||
conda_selector=None):
|
||||
"""
|
||||
Read a requirements.txt file, expressed as a path relative to Zipline root.
|
||||
|
||||
@@ -183,15 +198,22 @@ def read_requirements(path, strict_bounds, conda_format=False):
|
||||
reqs = map(_with_bounds, reqs)
|
||||
|
||||
if conda_format:
|
||||
reqs = map(_conda_format, reqs)
|
||||
reqs = map(partial(_conda_format, selector=conda_selector), reqs)
|
||||
|
||||
return list(reqs)
|
||||
|
||||
|
||||
def install_requires(strict_bounds=False, conda_format=False):
|
||||
return read_requirements('etc/requirements.txt',
|
||||
reqs = read_requirements('etc/requirements.txt',
|
||||
strict_bounds=strict_bounds,
|
||||
conda_format=conda_format)
|
||||
if sys.version_info.major == 2 or conda_format:
|
||||
reqs += read_requirements('etc/requirements_py2.txt',
|
||||
strict_bounds=strict_bounds,
|
||||
conda_format=conda_format,
|
||||
conda_selector='py2k')
|
||||
|
||||
return reqs
|
||||
|
||||
|
||||
def extras_requires(conda_format=False):
|
||||
|
||||
Reference in New Issue
Block a user