quantopian / zipline

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

Tutorial buyapple.py fails in python 2.7.10 #650

Closed beebeed closed 8 years ago

beebeed commented 9 years ago

running buyapple.py fails in python 2.7.10 but runs in python 3.4.3 for zipline 8.0rc. The part of code that fails is data[symbol('AAPL')] found in

record(AAPL=data[symbol('AAPL')].price)

the error is

Traceback (most recent call last):
  File "C:\python2710_64\Scripts\run_algo.py", line 4, in <module>
    __import__('pkg_resources').run_script('zipline==0.8.0rc1', 'run_algo.py')
  File "C:\Python2710_64\lib\site-packages\pkg_resources\__init__.py", line 729, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "C:\Python2710_64\lib\site-packages\pkg_resources\__init__.py", line 1642, in run_script
    exec(code, namespace, namespace)
  File "c:\python2710_64\lib\site-packages\zipline-0.8.0rc1-py2.7-win-amd64.egg\EGG-INFO\scripts\run_algo.py", line 23, in <module>
    run_pipeline(print_algo=True, **parsed)
  File "C:\Python2710_64\lib\site-packages\zipline-0.8.0rc1-py2.7-win-amd64.egg\zipline\utils\cli.py", line 246, in run_pipeline
    perf = algo.run(source, overwrite_sim_params=overwrite_sim_params)
  File "C:\Python2710_64\lib\site-packages\zipline-0.8.0rc1-py2.7-win-amd64.egg\zipline\algorithm.py", line 529, in run
    for perf in self.gen:
  File "C:\Python2710_64\lib\site-packages\zipline-0.8.0rc1-py2.7-win-amd64.egg\zipline\gens\tradesimulation.py", line 120, in transform
    self.algo.instant_fill,
  File "C:\Python2710_64\lib\site-packages\zipline-0.8.0rc1-py2.7-win-amd64.egg\zipline\gens\tradesimulation.py", line 314, in _process_snapshot
    new_orders = self._call_handle_data()
  File "C:\Python2710_64\lib\site-packages\zipline-0.8.0rc1-py2.7-win-amd64.egg\zipline\gens\tradesimulation.py", line 343, in _call_handle_data
    self.simulation_dt,
  File "C:\Python2710_64\lib\site-packages\zipline-0.8.0rc1-py2.7-win-amd64.egg\zipline\utils\events.py", line 194, in handle_data
    event.handle_data(context, data, dt)
  File "C:\Python2710_64\lib\site-packages\zipline-0.8.0rc1-py2.7-win-amd64.egg\zipline\utils\events.py", line 212, in handle_data
    self.callback(context, data)
  File "C:\Python2710_64\lib\site-packages\zipline-0.8.0rc1-py2.7-win-amd64.egg\zipline\algorithm.py", line 306, in handle_data
    self._handle_data(self, data)
  File "buyapple.py", line 26, in handle_data
    record(AAPL=data[symbol('AAPL')].price)
  File "C:\Python2710_64\lib\site-packages\zipline-0.8.0rc1-py2.7-win-amd64.egg\zipline\protocol.py", line 518, in __getitem__
    return self._data[name]
KeyError: Equity(0, symbol='AAPL', asset_name='', exchange='', start_date=None, end_date=None, first_traded=None)

Environment: Windows 7 64 bit, Python 3.4, Python 2.7, zipline 0.8.0rc Appears to be with zipline.protocol.BarData and zipline.assets._assets.Equity

Kind regards

David Bieber

jfkirk commented 9 years ago

Thank you, David! I am investigating and attempting to reproduce.

Can you provide me with the command that you use to call runalgo.py?

beebeed commented 9 years ago

Actually I was running it in a debugger so added main into buyapple.py - here is the code I used

from datetime import datetime
import pytz

from zipline.api import order, record, symbol
from zipline import TradingAlgorithm
from zipline.utils.factory import load_from_yahoo

def initialize(context):
    pass

def handle_data(context, data):
    order(symbol('AAPL'), 10)
    record(AAPL=data[symbol('AAPL')].price)

if __name__ == '__main__':

    start = datetime(2008, 1, 1, 0, 0, 0, 0, pytz.utc)
    end = datetime(2010, 1, 1, 0, 0, 0, 0, pytz.utc)
    data = load_from_yahoo(stocks=['AAPL'], indexes={}, start=start,
                           end=end)
    data = data.dropna()
    algo = TradingAlgorithm(initialize=initialize,
                            handle_data=handle_data,
                            identifiers=['AAPL'])
    results = algo.run(data)
    results.portfolio_value.plot()

it fails at record(AAPL=data[symbol('AAPL')].price), was trying to debug it but couldn't figure out the inheritance.

beebeed commented 9 years ago

Forgot to say in the master 8.0rc there is a missing dependency contextlib2

jfkirk commented 9 years ago

Ok - I'll look in to the dependency as well. I'll update once I've reproduced.

jfkirk commented 9 years ago

I've attempted to reproduce, but the code you provided runs fine for me in python 2.7.10 and 3.4.

@twiecki Any ideas on how I should investigate?

twiecki commented 9 years ago

Seems like maybe the data isn't correctly loaded?

xingjianpan commented 9 years ago

I have the same error following the tutorial at http://www.zipline.io/tutorial/

code:


%%zipline --start 2000-1-1 --end 2014-1-1 --symbols AAPL -o perf_ipython

import zipline
from zipline.api import order, record, symbol

def initialize(context):
    pass

def handle_data(context, data):
    order(symbol('AAPL'), 10)
    record(AAPL=data[symbol('AAPL')].price)

error message:


AAPL

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-7-0d07572f6ef6> in <module>()
      1 
----> 2 get_ipython().run_cell_magic(u'zipline', u'--start 2000-1-1 --end 2014-1-1 --symbols AAPL -o perf_ipython', u"\n\nimport zipline\nfrom zipline.api import order, record, symbol\n\nfrom zipline.api import symbol, order, record\n\ndef initialize(context):\n    pass\n\ndef handle_data(context, data):\n    order(symbol('AAPL'), 10)\n    record(AAPL=data[symbol('AAPL')].price)")

d:\Users\Xingjian Pan\Anaconda\envs\pyfolio\lib\site-packages\IPython\core\interactiveshell.pyc in run_cell_magic(self, magic_name, line, cell)
   2262             magic_arg_s = self.var_expand(line, stack_depth)
   2263             with self.builtin_trap:
-> 2264                 result = fn(magic_arg_s, cell)
   2265             return result
   2266 

d:\Users\Xingjian Pan\Anaconda\envs\pyfolio\lib\site-packages\zipline-0.8.0rc1-py2.7-win-amd64.egg\zipline\utils\cli.pyc in parse_cell_magic(line, cell)
    138     output_var_name = args.pop('output', None)
    139 
--> 140     perf = run_pipeline(print_algo=False, algo_text=cell, **args)
    141 
    142     if output_var_name is not None:

d:\Users\Xingjian Pan\Anaconda\envs\pyfolio\lib\site-packages\zipline-0.8.0rc1-py2.7-win-amd64.egg\zipline\utils\cli.pyc in run_pipeline(print_algo, **kwargs)
    252                                     end=end)
    253 
--> 254     perf = algo.run(source, overwrite_sim_params=overwrite_sim_params)
    255 
    256     output_fname = kwargs.get('output', None)

d:\Users\Xingjian Pan\Anaconda\envs\pyfolio\lib\site-packages\zipline-0.8.0rc1-py2.7-win-amd64.egg\zipline\algorithm.pyc in run(self, source, overwrite_sim_params, benchmark_return_source)
    557         # perf dictionary
    558         perfs = []
--> 559         for perf in self.gen:
    560             perfs.append(perf)
    561 

d:\Users\Xingjian Pan\Anaconda\envs\pyfolio\lib\site-packages\zipline-0.8.0rc1-py2.7-win-amd64.egg\zipline\gens\tradesimulation.pyc in transform(self, stream_in)
    118                         date,
    119                         snapshot,
--> 120                         self.algo.instant_fill,
    121                     )
    122                     # Perf messages are only emitted if the snapshot contained

d:\Users\Xingjian Pan\Anaconda\envs\pyfolio\lib\site-packages\zipline-0.8.0rc1-py2.7-win-amd64.egg\zipline\gens\tradesimulation.pyc in _process_snapshot(self, dt, snapshot, instant_fill)
    296 
    297         if any_trade_occurred:
--> 298             new_orders = self._call_handle_data()
    299             for order in new_orders:
    300                 perf_process_order(order)

d:\Users\Xingjian Pan\Anaconda\envs\pyfolio\lib\site-packages\zipline-0.8.0rc1-py2.7-win-amd64.egg\zipline\gens\tradesimulation.pyc in _call_handle_data(self)
    325             self.algo,
    326             self.current_data,
--> 327             self.simulation_dt,
    328         )
    329         orders = self.algo.blotter.new_orders

d:\Users\Xingjian Pan\Anaconda\envs\pyfolio\lib\site-packages\zipline-0.8.0rc1-py2.7-win-amd64.egg\zipline\utils\events.pyc in handle_data(self, context, data, dt)
    192     def handle_data(self, context, data, dt):
    193         for event in self._events:
--> 194             event.handle_data(context, data, dt)
    195 
    196 

d:\Users\Xingjian Pan\Anaconda\envs\pyfolio\lib\site-packages\zipline-0.8.0rc1-py2.7-win-amd64.egg\zipline\utils\events.pyc in handle_data(self, context, data, dt)
    210         """
    211         if self.rule.should_trigger(dt):
--> 212             self.callback(context, data)
    213 
    214 

d:\Users\Xingjian Pan\Anaconda\envs\pyfolio\lib\site-packages\zipline-0.8.0rc1-py2.7-win-amd64.egg\zipline\algorithm.pyc in handle_data(self, data)
    334             self.history_container.update(data, self.datetime)
    335 
--> 336         self._handle_data(self, data)
    337 
    338         # Unlike trading controls which remain constant unless placing an

<string> in handle_data(context, data)

d:\Users\Xingjian Pan\Anaconda\envs\pyfolio\lib\site-packages\zipline-0.8.0rc1-py2.7-win-amd64.egg\zipline\protocol.pyc in __getitem__(self, name)
    528 
    529     def __getitem__(self, name):
--> 530         return self._data[name]
    531 
    532     def __delitem__(self, name):

KeyError: Equity(0, symbol='AAPL', asset_name='', exchange='', start_date=0, end_date=Timestamp('2015-08-29 00:00:00+0000', tz='UTC'), first_traded=None)
StewartDouglas commented 9 years ago

@beebeed Can you please pull the latest version of Zipline and let us know whether you still experience problems?

AnthonyFJGarner commented 9 years ago

I confirm that I get identical results to Beebeeb and xingjianpan using identical code. Windows 8.1, Python 2.7.10, zipline 0.8.0rc1

KeyError: Equity(0, symbol='AAPL', asset_name='None', exchange='None', start_date=Timestamp('1970-01-01 00:00:00+0000', tz='UTC'), end_date=Timestamp('2116-02-20 23:53:38.427387392+0000', tz='UTC'), first_traded=None)
AnthonyFJGarner commented 9 years ago

None of the examples in the latest build of zipline work with my zipline installation.

StewartDouglas commented 9 years ago

@AnthonyFJGarner can you post the command you are using the launch the backtest?

StewartDouglas commented 9 years ago

Ok @AnthonyFJGarner I'm assuming you're running the exact same code as @beebeed. I'm still unclear as to why you are getting the KeyError. One thing to note though is that your code needs some additional lines added if it is to plot the results correctly:

import matplotlib.pyplot as plt  # put this at the top
...
plt.show()  # put this at the end of the main block
AnthonyFJGarner commented 9 years ago

I'm using Spyder and the "run" command on byapple.py. Here is the full stack.

Python 2.7.10 |Anaconda 2.3.0 (32-bit)| (default, May 28 2015, 17:02:00) [MSC v.1500 32 bit (Intel)]
Type "copyright", "credits" or "license" for more information.

IPython 4.0.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.
%guiref   -> A brief reference about the graphical user interface.

In [1]: runfile('C:/Application/github/zipline/zipline/examples/buyapple.py', wdir='C:/Application/github/zipline/zipline/examples')
AAPL
Traceback (most recent call last):

  File "<ipython-input-1-2319e3d0f7d4>", line 1, in <module>
    runfile('C:/Application/github/zipline/zipline/examples/buyapple.py', wdir='C:/Application/github/zipline/zipline/examples')

  File "C:\Anaconda\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 685, in runfile
    execfile(filename, namespace)

  File "C:\Anaconda\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 71, in execfile
    exec(compile(scripttext, filename, 'exec'), glob, loc)

  File "C:/Application/github/zipline/zipline/examples/buyapple.py", line 65, in <module>
    results = algo.run(data)

  File "c:\users\anthony fj garner\src\zipline\zipline\algorithm.py", line 610, in run
    for perf in self.gen:

  File "c:\users\anthony fj garner\src\zipline\zipline\gens\tradesimulation.py", line 121, in transform
    self.algo.instant_fill,

  File "c:\users\anthony fj garner\src\zipline\zipline\gens\tradesimulation.py", line 298, in _process_snapshot
    new_orders = self._call_handle_data()

  File "c:\users\anthony fj garner\src\zipline\zipline\gens\tradesimulation.py", line 327, in _call_handle_data
    self.simulation_dt,

  File "c:\users\anthony fj garner\src\zipline\zipline\utils\events.py", line 192, in handle_data
    event.handle_data(context, data, dt, context.trading_environment)

  File "c:\users\anthony fj garner\src\zipline\zipline\utils\events.py", line 210, in handle_data
    self.callback(context, data)

  File "c:\users\anthony fj garner\src\zipline\zipline\algorithm.py", line 352, in handle_data
    self._handle_data(self, data)

  File "C:/Application/github/zipline/zipline/examples/buyapple.py", line 26, in handle_data
    record(AAPL=data[symbol('AAPL')].price)

  File "c:\users\anthony fj garner\src\zipline\zipline\protocol.py", line 536, in __getitem__
    return self._data[name]

KeyError: Equity(0, symbol='AAPL', asset_name='None', exchange='None', start_date=Timestamp('1970-01-01 00:00:00+0000', tz='UTC'), end_date=Timestamp('2116-02-20 23:53:38.427387392+0000', tz='UTC'), first_traded=None)

In [2]:
AnthonyFJGarner commented 9 years ago

I get exactly the same Key Error in Spyder with beebeed's code. With xingjianpan's code used in iP notebook again I get exactly the same error.

AnthonyFJGarner commented 9 years ago

Have a look at my closing comments on the closed thread #707. It turned out I had the wrong version of sqlite3 in the Python library.

The point is unless you guys specify every single component of every single element in Python / anaconda/ whatever necessary to run the latest version of Zipline, your job is impossible. Even clowns like me are capable of following a simple recipe book. And unfortunately the recipe book needs to be wider than just the zipline dependencies contained in requirement.txt

You Quantopians are not suffering from this Key Error and your back tester is zipline. If, therefore, you gave a more complete recipe of every single piece of software and the correct version (for a given operating system such as Windows 8.1) would it not be simpler to track such issues?

Because at present, is it entirely clear where the issue lies? Within zipline? Or within the wider environment in which zipline operates?

StewartDouglas commented 9 years ago

@AnthonyFJGarner thanks for all the very helpful feedback. Did the actions you took in https://github.com/quantopian/zipline/issues/707 also resolve this issue?

AnthonyFJGarner commented 9 years ago

Stewart - sorry, I'm new here! Perhaps you are not on the Quantopian team but just trying to kindly help me out? Even so, I do think the Quantopian guys could make life easier if they were more prescise in their set up instructions.

AnthonyFJGarner commented 9 years ago

Yes. That particular issue was solved.Now I am faced with a host of other (hopefully less serious) issues. I'm enjoying the process but clearly it is going to take me quite a while to get the comfort I need before using either Zipline or Quantopian for actual trading.

StewartDouglas commented 9 years ago

@AnthonyFJGarner No problem. I'm on the Quantopian team and have been trying to get to the bottom of this. Glad this issue in particular has been resolved, and sorry it has taken you some time.

@beebeed @xingjianpan can I suggest you take the action explained here: http://lambdathefirst.blogspot.com/2011/01/how-to-upgrade-sqlite-that-comes-with.html to ensure you have a recent version of SQLite under the hood.

AnthonyFJGarner commented 9 years ago

Tried @ssanderson recommendations re generating C files (python setup.py build_ext --inplace) at issue #663 to no avail. Exactly the same problem.

StewartDouglas commented 9 years ago

@AnthonyFJGarner My understanding (from https://github.com/quantopian/zipline/issues/650#issuecomment-141459502) was that this issue had be resolved for you? Are you still getting the KeyError previously discussed?

AnthonyFJGarner commented 9 years ago

The issue in this thread is not resolved for me and I simply thought I would try generating the C files as per

python setup.py build_ext --inplace.

I thought it may have something to do with the current problems in this thread. But It does not. And yes, I'm still getting the Key Error set out above.

I don't think order() is working either. Probably I'm doing something stupid. The code set out below generates no orders:

from datetime import datetime
import logbook
from logbook import Logger
log = Logger('Algorithm')
import pytz
#import TradingAlgorithm

from zipline.algorithm import TradingAlgorithm
from zipline.utils.factory import load_from_yahoo 

from zipline.api import order, symbol, get_order

import pylab as pl

def initialize(context):
    context.test = 10
    context.stock = symbol('AAPL')

def handle_data(context, data):
    context.order_id=order(context.stock, 1)
    aapl_order = get_order(context.order_id)  
    if aapl_order:  
    # log the order amount and the amount that is filled  
        message = 'Order for {amount} has {filled} shares filled.'  
        message = message.format(amount=aapl_order.amount, filled=aapl_order.filled)  
        log.info(message)

#log.info(order)

if __name__ == '__main__':
    logbook.StderrHandler().push_application()
    start = datetime(2008, 1, 1, 0, 0, 0, 0, pytz.utc)
    end = datetime(2009, 1, 1, 0, 0, 0, 0, pytz.utc)
    data = load_from_yahoo(stocks=['AAPL'], indexes={}, start=start,
                           end=end)
    data = data.dropna()
    algo = TradingAlgorithm(initialize=initialize,
                            handle_data=handle_data,
                            identifiers=['AAPL'])
    results = algo.run(data)
    results.portfolio_value.plot()
    pl.show()
AnthonyFJGarner commented 9 years ago

buyapple.py still generates:

KeyError: Equity(0, symbol='AAPL', asset_name='None', exchange='None', start_date=Timestamp('1970-01-01 00:00:00+0000', tz='UTC'), end_date=Timestamp('2116-02-20 23:53:38.427387392+0000', tz='UTC'), first_traded=None
Zigguratti commented 9 years ago

for what its worth, I just ran the code above, and it executed fine. Although it seems to lose money, so something must be pretty wrong with the logic!

Sorry you are still having problems Anthony. I'm running fine on 0.80rc1, although I did have a couple of problems installing that. I'm on python 3.4.3, and the pip and conda installers would only install 0.7 so I had to build from github and had an annoying error that my c++ compiler could not be found which I somehow managed to fix. I am contemplating moving to ubuntu in due course, but for now, it is possible to get it running under windows 7 64 bit. It is just a bit of a chore. I do think Quantopian should make this easier. I know that their focus is on their core Quantopian business and that they are no doubt overwhelmed with work. Still, I wonder how many hours they lose on supporting zipline users. I still believe that Docker might make the install process easier to maintain by enabling a whole environment to be created for each platform.

On 22 September 2015 at 00:15, AnthonyFJGarner notifications@github.com wrote:

buyapple.py still generates:

KeyError: Equity(0, symbol='AAPL', asset_name='None', exchange='None', start_date=Timestamp('1970-01-01 00:00:00+0000', tz='UTC'), end_date=Timestamp('2116-02-20 23:53:38.427387392+0000', tz='UTC'), first_traded=None

— Reply to this email directly or view it on GitHub https://github.com/quantopian/zipline/issues/650#issuecomment-142110243.

AnthonyFJGarner commented 9 years ago

Many thanks - given the time I have wasted so far I have nothing to lose by installing the same version of Python as you have and see what happens. The problem is very clearly with the environment which is ridiculously difficult to set up - as you say, the Quantopians could make like much easier for everyone by simplifying this. I have not even begun to code any systems yet since I can't pass go!

Zigguratti commented 9 years ago

Yes, if you create a separate anaconda install and try from scratch, it shouldn't take too long. I'm not entirely sure how I managed to get my C++ compiler installed correctly, but I think if you install some of the same files I did, it should work as it did for me. I have been thinking of posting up what I had to do as a mini 'hacktorial' for anyone who wants to use zipline with external data sources as I am, because there really isn't much documentation on that, and hopefully I'd get better insights from quantopian correcting any errors I have undoubtedly made! It seems pretty cool now that I have it working, although I don't trust it yet and need to go through some of the major parts of the code which will involve learning some OO.

I gather I will have to disable the trading calendar to use non-US stocks which is nearly where I am at ... replacing that for every major market in the world (including all of Europe) just is't going to be practical at this stage! If my sharpe ratios are a little out it doesn't matter too much (not like anyone uses intraday figures in any of these calcluations!), but it does matter if trading days are being skipped due to zipline thinking they are public holidays etc.!

On 22 September 2015 at 10:40, AnthonyFJGarner notifications@github.com wrote:

Many thanks - given the time I have wasted so far I have nothing to lose by installing the same version of Python as you have and see what happens. The problem is very clearly with the environment which is ridiculously difficult to set up - as you say, the Quantopians could make like much easier for everyone by simplifying this. I have not even begun to code any systems yet since I can't pass go!

— Reply to this email directly or view it on GitHub https://github.com/quantopian/zipline/issues/650#issuecomment-142203622.

AnthonyFJGarner commented 9 years ago

Thank you Zigguratti, your procedure has worked for me.

  1. I removed my existing anaconda version using the standard Windows un-install method and reinstalled anaconda for Python 3.4 using the Windows 32 bit graphical installer
  2. I downloaded Microsoft Visual C++ 2010 Express 10 from http://microsoft-visual-cpp-express.soft32.com/
  3. I installed zipline as follows in the development mode

pip install -e C:\Application\Github\Zipline (which is where my zipline is installed on my PC)

Lo and behold, this time all the uninstalled dependencies were installed and any incorrect version was uninstalled and then reinstalled with the correct version.

  1. buyapple.py and the code I wrote above now work.

Here is the point for the Quantopian guys:

Your set up instructions are a hopeless, total mess. Not really your fault since you don't aim to deal with morons such as myself. But my god you could save yourself some problems if you exercised some precision in your instructions and explanations.

I am an ex City securities lawyer so absolute precision was drummed into me many years ago. I hope the above may be of help to someone. The problems are legion for someone new to this game and I reiterate my very strong recommendation that you guys (for your own sake) give a much easier and more explicit set of instructions.

I was initially fooled into downloading Python 2.7 because I thought I had to use Zipline 0.7.0 https://pypi.python.org/pypi/zipline

I then realised Zipline 0.7.0 was an outdated and (for my purposes) hopeless version and so eventually stumbled onto the ability to use the very latest version which I update regularly from github.

I never realised that changing from Python 2.7 to 3.4 would solve my problems....but that's probably because I'm just dumb.

You never know, I might just be able to get on with developing systems in Zipline now......

Zigguratti commented 9 years ago

Great!

In quantopian's defense, they are probably targeting zipline at linux users; hardly anyone does serious development on Windows systems nowadays (I am told). I would recommend moving to e.g. Ubuntu as I have read that the latest versions of many libraries' binaries come to windows late and they don't always compile ... but there will be more people like us who wind up in this situation, and it'll waste Quantopian's resources on support/PR which might otherwise be better spent making quantopian/zipline better! For now, I'm using windows as I have a large list of much more pressing things to master, and grappling with a new environment would be a distraction.

Just one other thing: check out the ipython QT console ... if you aren't already using that, it is a great way to write python code, because you can interact with the data objects as you develop your code ... kind of crucial in figuring out how zipline works. It is slower than running scripts in an ide (e.g. pycharm), but it is so so powerful ... an analogy would be Rstudio if you are at all familiar with that. And these ipython notebooks look pretty darned cool ...

Best,

Carl

(ps trying to remove my Zigguratti name from github/google account! a little unprofessional and I have religious nutters now adding me to their circles on google+! Do let me know when I have managed that!)

On 22 September 2015 at 13:34, AnthonyFJGarner notifications@github.com wrote:

Thank you Zigguratti, your procedurse has worked for me.

  1. I removed my existing anaconda version using the standard Windows un-install method and reinstalled anaconda for Python 3.4 using the Windows 32 bit graphical installer
  2. I downloaded Microsoft Visual C++ 2010 Express 10 from http://microsoft-visual-cpp-express.soft32.com/
  3. I installed zipline as follows in the development mode <pip install -e C:\Application\Github\Zipline (which is where my zipline is installed on my PC) Lo and behold, this time all the uninstalled dependencies were installed and any incorrect version was uninstalled and then reinstalled with the correct version.
  4. buyapple.py and the code I wrote above now works.

Here is the point for the Quantopian guys:

Your set up instructions are a hopeless, total mess. Not really your fault since you don't aim to deal with morons such as myself. But my god you could save yourself some problems if you exercised some precision in your instructions and explanations.

— Reply to this email directly or view it on GitHub https://github.com/quantopian/zipline/issues/650#issuecomment-142242041.

StewartDouglas commented 9 years ago

@AnthonyFJGarner @Zigguratti Thanks for the extensive feedback guys, it will be genuinely useful to us going forward.

Zigguratti commented 9 years ago

No problem, nice to meet you Stewart.

Here are the notes I made to myself the other week, should anyone else venture here with similar problems: Installation Version 0.8.0 is best

pip install zipline installs 0.7, which is an old release lacking various pieces of functionality, not least scheduler, required to use pyfolio. So it is worth installing 0.8. Unfortunately, this is non-trivial, especially for non-linux users (but for most people). I am on python 3.4, although only 3.3 is officially supported. How? github

I used github to clone the repo from gitbash:

F:\work\systematic equity\Coding\python\tst\zipline> pip install -e git+https://

github.com/quantopian/zipline.git#egg=zipline Errors

Originally I had an error concerning the building of cython:

skipping

'C:\Users\HPLappy\AppData\Local\Temp\pip-build-v6y_t76p\Cython\Cyth

on\Plex\Scanners.c' Cython extension (up-to-date)

building 'Cython.Plex.Scanners' extension

error: Microsoft Visual C++ 10.0 is required (Unable to find

vcvarsall.bat). Fix

Googling revealed that this is not an uncommon problem ( http://stackoverflow.com/questions/26473854/python-pip-has-issues-with-path-for-ms-visual-studio-2010-express-for-64-bit-ins ).

The advice seemed to be to install Microsoft visual C++ 2010 express, and to add an environment variable VS90COMNTOOLS which I set to 2013 (not convinced that this made any difference, or that 2013 was the correct value to set; chosen as that was the most recent disctributable C++ library I had installed). (file visual studio 2010 VS10sp1-KB983509.exe, https://support.microsoft.com/en-gb/kb/2977003). I also installed vcredist_x64.exe, C++ redistributable ( https://www.microsoft.com/en-gb/download/details.aspx?id=40784). It seems that actually loading visual studio may have set up the path variables (or something) required to build zipline 0.8.0rc1.

On 22 September 2015 at 16:34, Stewart Douglas notifications@github.com wrote:

@AnthonyFJGarner https://github.com/AnthonyFJGarner @Zigguratti https://github.com/Zigguratti Thanks for the extensive feedback guys, it will be genuinely useful to us going forward.

— Reply to this email directly or view it on GitHub https://github.com/quantopian/zipline/issues/650#issuecomment-142290995.

ljw2602 commented 8 years ago

To add to AnthonyFJGarner's post on Sep 22:

  1. Install Anaconda with Python 3.5 Since zipline is compatible with Python 3.4, you need to create an environment with Python 3.4 I named the environment "py34" here $conda create -n py34 python=3.4 anaconda
  2. Install Microsoft Visual C++ 2010 Express This is what Python 3.4 is compatible with (http://microsoft-visual-cpp-express.soft32.com/)
  3. Activate the environment & install zipline $activate py34 $pip install -e C:\GitHub\zipline
richafrank commented 8 years ago

This should be fixed by #959, which is now on master.

CraneCooker commented 8 years ago

@ljw2602, @richafrank I used ljw2602's way and finally installed zipline. But when I turned to Anaconda Spyder (after activate py34), I found zipline is not exist again. Now I could only use zipline in cmd. What can I do to use it in Spyder as well ? thanks

BraveNewMath commented 7 years ago

I tried running conda install -c quantopian zipline

and got this error:

Fetching package metadata .............
Solving package specifications: .

UnsatisfiableError: The following specifications were found to be in conflict:
  - python 3.6*
  - zipline -> cyordereddict >=0.2.2 -> python 2.7*
Use "conda info <package>" to see the dependencies for each package.

I then tried conda install -c quantopian/label/ci zipline

I got this error message:

UnsatisfiableError: The following specifications were found to be in conflict:
  - python 3.6*
  - zipline -> bcolz >=0.12.1,<1 -> python 3.5*

is there a quick fix for this?

RJUNS commented 7 years ago

Am getting the same error, while installing zipline on python 3.5 virtual env.

freddiev4 commented 7 years ago

@BraveNewMath to me it sounds like you're trying to install zipline for Python 3.6. The newest version of conda by default uses Python 3.6, so you'll have to create a new conda env using conda create, that uses Python 3.5

There's more information on the Zipline Install Docs

thomas2004ch commented 7 years ago

@BraveNewMath The link you posted has 404 error.

freddiev4 commented 7 years ago

@thomas2004ch Fixed 🙂

thomas2004ch commented 7 years ago

@FreddieV4 No, I can't open the page. It still shows 404 error.

freddiev4 commented 7 years ago

@thomas2004ch I'm sorry, I may have misunderstood which link you're talking about. The only link I saw with a 404 in this thread is the one to the Install Docs (which I edited and corrected, http://zipline.io/install.html).

Which link were you talking about exactly?

thomas2004ch commented 7 years ago

@FreddieV4 The link I mention is this one in your post: Zipline Install Docs. As I open it I got 404.

The link http://zipline.io/install.html works. But it hasn't told how to overcome the problem by installing the zipline.1.1.1 on Anaconda 3 (Python 3). Are successful to install the zipline 1.1.1 on Anaconda 3?

freddiev4 commented 7 years ago

@thomas2004ch You should be able to install zipline on Python 3.4 and 3.5 with Anaconda (I'd recommend installing in a new conda env)

thomas2004ch commented 7 years ago

@FreddieV4 Yes, I did it. Thanks.

morris9795 commented 6 years ago

I have already create a new conda env in Python 3.5, but it stll shows I am in python3.6

C:\untitled03>python Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:18:55) [MSC v.1900 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.

Fetching package metadata ............... Solving package specifications: . UnsatisfiableError: The following specifications were found to be in conflict:

can you help me?

thomas2004ch commented 6 years ago

1. I haven't uased the Zip-line since many people say it is not ripe enough to do real-time trading.

2. How did you build your ENV? Do you use Windows or Ubuntu? Where can I find your codes?


morris9795 notifications@github.com schrieb am Mi, 20.12.2017:

Betreff: Re: [quantopian/zipline] Tutorial buyapple.py fails in python 2.7.10 (#650) An: "quantopian/zipline" zipline@noreply.github.com CC: "thomas2004ch" thomas2004ch@yahoo.de, "Mention" mention@noreply.github.com Datum: Mittwoch, 20. Dezember, 2017 10:12 Uhr

I have already create a new conda env in Python 3.5, but it stll shows I am in python3.6 C:\untitled03>python

Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:18:55) [MSC v.1900 64 bit (AMD64)] on win32

Type "help", "copyright", "credits" or "license" for more information. Fetching package metadata ...............

Solving package specifications: .

UnsatisfiableError: The following specifications were found to be in conflict:

python 3.6 zipline -> bcolz >=0.12.1,<1 -> numpy 1.10 -> python 2.7*

Use "conda info " to see the dependencies for each package.

can you help me?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.