Skip to content

Commit

Permalink
ENH: Rewrite of Zipline to use lazy access pattern
Browse files Browse the repository at this point in the history
More documentation to follow in release notes.

Based on lazy-mainline branch, see for more details.

Also-By: Jean Bredeche <[email protected]>
Also-By: Andrew Liang <[email protected]>
Also-By: Abhijeet Kalyan <[email protected]>
  • Loading branch information
Eddie Hebert authored and Jean Bredeche committed Apr 4, 2016
1 parent 822f889 commit 16fd668
Show file tree
Hide file tree
Showing 117 changed files with 14,899 additions and 324,969 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,4 @@ after_success:
branches:
only:
- master
- lazy-mainline
2 changes: 2 additions & 0 deletions etc/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,5 @@ toolz==0.7.4

# Asset writer and finder
sqlalchemy==1.0.8

intervaltree==2.1.0
3 changes: 3 additions & 0 deletions etc/requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,8 @@ futures==3.0.5
requests-futures==0.9.7
piprot==0.9.6

# For mocking out requests fetches
responses==0.4.0

# For asset db management
alembic==0.7.7
2 changes: 2 additions & 0 deletions etc/requirements_py2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Caching and other utilities
functools32==3.2.3.post2
143 changes: 0 additions & 143 deletions scripts/generate_new_sample_saved_state.py

This file was deleted.

42 changes: 32 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -89,6 +90,12 @@ def build_extensions(self):
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']
)
]


Expand Down Expand Up @@ -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.
Expand All @@ -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):
Expand Down
Loading

0 comments on commit 16fd668

Please sign in to comment.