quantopian / zipline

Zipline, a Pythonic Algorithmic Trading Library
https://www.zipline.io
Apache License 2.0
17.7k stars 4.73k forks source link

ImportError: cannot import name information_ratio #1855

Closed ginward closed 7 years ago

ginward commented 7 years ago

Dear Zipline Maintainers,

Before I tell you about my issue, let me describe my environment:

Environment

Now that you know a little about me, let me tell you about the issue I am having:

ImportError: cannot import name information_ratio

I was simply importing zipline and then it throws and error: ImportError: cannot import name information_ratio

Here is how you can reproduce this issue on your machine:

Reproduction Steps

  1. pip install zipline
  2. create a py file "zip.py"
  3. write import zipline.api or import zipline or from zipline.api import order, record, symbol
  4. write on terminal python zip.py

What steps have you taken to resolve this already?

$ brew install freetype pkg-config gcc openssl

$ pip install zipline

$ pip install empyrical

...

Traceback

Traceback (most recent call last):
  File "zip.py", line 1, in <module>
    import zipline.api
  File "/usr/local/lib/python2.7/site-packages/zipline/__init__.py", line 42, in <module>
    from .utils.run_algo import run_algorithm
  File "/usr/local/lib/python2.7/site-packages/zipline/utils/run_algo.py", line 17, in <module>
    from zipline.algorithm import TradingAlgorithm
  File "/usr/local/lib/python2.7/site-packages/zipline/algorithm.py", line 85, in <module>
    from zipline.finance.performance import PerformanceTracker
  File "/usr/local/lib/python2.7/site-packages/zipline/finance/performance/__init__.py", line 16, in <module>
    from . tracker import PerformanceTracker
  File "/usr/local/lib/python2.7/site-packages/zipline/finance/performance/tracker.py", line 69, in <module>
    import zipline.finance.risk as risk
  File "/usr/local/lib/python2.7/site-packages/zipline/finance/risk/__init__.py", line 16, in <module>
    from . report import RiskReport
  File "/usr/local/lib/python2.7/site-packages/zipline/finance/risk/report.py", line 64, in <module>
    from . period import RiskMetricsPeriod
  File "/usr/local/lib/python2.7/site-packages/zipline/finance/risk/period.py", line 28, in <module>
    from empyrical import (
ImportError: cannot import name information_ratio

Sincerely, Jinhua Wang

richafrank commented 7 years ago

Hi @ginward ! The latest empyrical release broke compatibility with zipline, so you can either downgrade empyrical to 0.2.2 or install the compatibility branch of zipline that hasn't been merged to master yet.

ginward commented 7 years ago

Thanks. It seems that I can use conda instead to install it.

sokol11 commented 4 years ago

This is still an issue on empyrical 0.5.3

richafrank commented 4 years ago

Hi @sokol11 , information_ratio was removed from empyrical and then from zipline in v1.1.1 (released July 5, 2017). It sounds like you have an old version of zipline that still depends on information_ratio.