Re: Figuring out what dependencies are needed
On 12/12/2013 4:53 PM, sal i wrote: This is the entire testing file along with the error at the bottom. data = load_from_yahoo() You're _still_ not passing into `load_from_yahoo` either `indexes` or `stocks` parameters, as I tried to point out by highlighting: assert indexes is not None or stocks is not None, Either `indexes` must have a value or stocks must. AssertionError: must specify stocks or indexes Which is exactly what the error is telling you. This isn't a dependency issue. You just need to read the documentation, work out what format it requires indexes or stocks to be specified in, and then pass them to `load_from_yahoo`. Calling it without _any_ arguments will give you the exception you're seeing. Look at the file examples/dual_moving_average.py, it shows you exactly what you need: data = load_from_yahoo(stocks=['AAPL'], indexes={}, start=start, end=end) -- https://mail.python.org/mailman/listinfo/python-list
Figuring out what dependencies are needed
I'm a Python beginner. I want to use it for stats work, so I downloaded Anaconda which has several of the popular libraries already packaged for Mac OS X. Now I'd like to use the backtesting package from zipline (zipline.io), but while running the test script in iPython, I receive the following error: AssertionErrorTraceback (most recent call last) ipython-input-6-f921351f78e2 in module() 1 data = load_from_yahoo() 2 dma = DualMovingAverage() 3 results = dma.run(data) 1) I assume that I'm missing some packages that aren't included in Anaconda, but how do I know which ones to upload? 2) Often I'll just unzip a library file and put the main folder in the iPython folder, but I notice there's usually a setup.py file in the main library folder. I've been ignoring this. Should I be using it? Thanks -- https://mail.python.org/mailman/listinfo/python-list
Re: Figuring out what dependencies are needed
On Wed, 11 Dec 2013 04:44:53 -0800, sal wrote: Now I'd like to use the backtesting package from zipline (zipline.io), .io is not normally a file extension for Python files. Are you sure that's Python code? but while running the test script in iPython, I receive the following error: AssertionErrorTraceback (most recent call last) ipython-input-6-f921351f78e2 in module() 1 data = load_from_yahoo() 2 dma = DualMovingAverage() 3 results = dma.run(data) I think you may be missing one or more lines? Perhaps something like AssertionError: blah blah blah appearing after that? For those unfamiliar with iPython, rather than a standard Traceback, that appears to suggest that dma.run(data) is raising AssertionError, but we can't see what (if any) error message is given by that assert, or how it fails. Can you explain what precise command you are running? Please copy and paste the exact command line you used that gives that error. Also, whenever you get unexpected errors while running from an IDE or non- standard environment like IDLE or iPython, your first step should be to run the same script from the command line using the vanilla Python interpreter and see if the error goes away. Do you need assistance with doing that? Feel free to ask for additional instructions. 1) I assume that I'm missing some packages that aren't included in Anaconda, but how do I know which ones to upload? Why do you make that assumption? I would expect missing packages to give an ImportError, not an AssertionError. 2) Often I'll just unzip a library file and put the main folder in the iPython folder, but I notice there's usually a setup.py file in the main library folder. I've been ignoring this. Should I be using it? Absolutely! You'll probably see a READ ME file in the unzipped folder, you should read that for instructions. It may be that sometimes the setup.py file will do nothing more than copy the main folder into your site-packages folder, but it may do a lot more. Also, if you just dump random packages into iPython's private library area, you may even break iPython. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Figuring out what dependencies are needed
On 11/12/2013 12:44, s...@nearlocal.com wrote: I'm a Python beginner. I want to use it for stats work, so I downloaded Anaconda which has several of the popular libraries already packaged for Mac OS X. Now I'd like to use the backtesting package from zipline (zipline.io), but while running the test script in iPython, I receive the following error: AssertionErrorTraceback (most recent call last) ipython-input-6-f921351f78e2 in module() 1 data = load_from_yahoo() 2 dma = DualMovingAverage() 3 results = dma.run(data) 1) I assume that I'm missing some packages that aren't included in Anaconda, but how do I know which ones to upload? 2) Often I'll just unzip a library file and put the main folder in the iPython folder, but I notice there's usually a setup.py file in the main library folder. I've been ignoring this. Should I be using it? Thanks https://pypi.python.org/pypi/z3c.dependencychecker and probably others. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: Figuring out what dependencies are needed
On 2013-12-11 13:27, Steven D'Aprano wrote: On Wed, 11 Dec 2013 04:44:53 -0800, sal wrote: Now I'd like to use the backtesting package from zipline (zipline.io), .io is not normally a file extension for Python files. Are you sure that's Python code? That's a package name, not a filename. but while running the test script in iPython, I receive the following error: AssertionErrorTraceback (most recent call last) ipython-input-6-f921351f78e2 in module() 1 data = load_from_yahoo() 2 dma = DualMovingAverage() 3 results = dma.run(data) I think you may be missing one or more lines? Perhaps something like AssertionError: blah blah blah appearing after that? For those unfamiliar with iPython, rather than a standard Traceback, that appears to suggest that dma.run(data) is raising AssertionError, but we can't see what (if any) error message is given by that assert, or how it fails. No, the arrow points to the active line in that frame of the traceback. Unfortunately, the OP cut off the remaining frames under `load_from_yahoo()` actually has the assert that is failing. -- Robert Kern I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. -- Umberto Eco -- https://mail.python.org/mailman/listinfo/python-list
Re: Figuring out what dependencies are needed
On Wed, Dec 11, 2013 at 6:38 AM, Robert Kern robert.k...@gmail.com wrote: On 2013-12-11 13:27, Steven D'Aprano wrote: On Wed, 11 Dec 2013 04:44:53 -0800, sal wrote: Now I'd like to use the backtesting package from zipline (zipline.io), .io is not normally a file extension for Python files. Are you sure that's Python code? That's a package name, not a filename. Actually, the .io there appears to be a TLD. At least, zipline.io is the address for the website of a zipline Python package. -- https://mail.python.org/mailman/listinfo/python-list
Re: Figuring out what dependencies are needed
On 11/12/2013 10:44 PM, s...@nearlocal.com wrote: I'm a Python beginner. I want to use it for stats work, so I downloaded Anaconda which has several of the popular libraries already packaged for Mac OS X. Now I'd like to use the backtesting package from zipline (zipline.io), but while running the test script in iPython, I receive the following error: AssertionErrorTraceback (most recent call last) ipython-input-6-f921351f78e2 in module() 1 data = load_from_yahoo() 2 dma = DualMovingAverage() 3 results = dma.run(data) 1) I assume that I'm missing some packages that aren't included in Anaconda, but how do I know which ones to upload? You're not missing a package, you're missing parameters. This is the signature for load_from_yahoo: def load_from_yahoo(indexes=None, stocks=None, start=None, end=None, adjusted=True): The first thing it does is call a helper function `_load_raw_yahoo_data`, which has this assertion: assert indexes is not None or stocks is not None, As you're passing no parameters into `load_from_yahoo`, both `indexes` and `stocks` default to None, so the assertion fails. Take a look at the examples in the zipline library to see what it is expecting. 2) Often I'll just unzip a library file and put the main folder in the iPython folder, but I notice there's usually a setup.py file in the main library folder. I've been ignoring this. Should I be using it? Thanks -- https://mail.python.org/mailman/listinfo/python-list
Re: Figuring out what dependencies are needed
On Thursday, December 12, 2013 1:48:42 PM UTC+8, alex23 wrote: On 11/12/2013 10:44 PM, s...@nearlocal.com wrote: I'm a Python beginner. I want to use it for stats work, so I downloaded Anaconda which has several of the popular libraries already packaged for Mac OS X. Now I'd like to use the backtesting package from zipline (zipline.io), but while running the test script in iPython, I receive the following error: AssertionErrorTraceback (most recent call last) ipython-input-6-f921351f78e2 in module() 1 data = load_from_yahoo() 2 dma = DualMovingAverage() 3 results = dma.run(data) 1) I assume that I'm missing some packages that aren't included in Anaconda, but how do I know which ones to upload? You're not missing a package, you're missing parameters. This is the signature for load_from_yahoo: def load_from_yahoo(indexes=None, stocks=None, start=None, end=None, adjusted=True): The first thing it does is call a helper function `_load_raw_yahoo_data`, which has this assertion: assert indexes is not None or stocks is not None, As you're passing no parameters into `load_from_yahoo`, both `indexes` and `stocks` default to None, so the assertion fails. Take a look at the examples in the zipline library to see what it is expecting. 2) Often I'll just unzip a library file and put the main folder in the iPython folder, but I notice there's usually a setup.py file in the main library folder. I've been ignoring this. Should I be using it? Thanks Thanks everyone. This is the entire testing file along with the error at the bottom. It looks like a stock is specified as data['AAPL']: %pylab inline Populating the interactive namespace from numpy and matplotlib In [14]: from zipline.algorithm import TradingAlgorithm from zipline.transforms import MovingAverage from zipline.utils.factory import load_from_yahoo In [15]: class DualMovingAverage(TradingAlgorithm): Dual Moving Average algorithm. def initialize(self, short_window=200, long_window=400): # Add 2 mavg transforms, one with a long window, one # with a short window. self.add_transform(MovingAverage, 'short_mavg', ['price'], market_aware=True, window_length=short_window) self.add_transform(MovingAverage, 'long_mavg', ['price'], market_aware=True, window_length=long_window) # To keep track of whether we invested in the stock or not self.invested = False self.short_mavg = [] self.long_mavg = [] def handle_data(self, data): if (data['AAPL'].short_mavg['price'] data['AAPL'].long_mavg['price']) and not self.invested: self.order('AAPL', 100) self.invested = True elif (data['AAPL'].short_mavg['price'] data['AAPL'].long_mavg['price']) and self.invested: self.order('AAPL', -100) self.invested = False # Save mavgs for later analysis. self.short_mavg.append(data['AAPL'].short_mavg['price']) self.long_mavg.append(data['AAPL'].long_mavg['price']) In [16]: data = load_from_yahoo() dma = DualMovingAverage() results = dma.run(data) --- AssertionErrorTraceback (most recent call last) ipython-input-16-f921351f78e2 in module() 1 data = load_from_yahoo() 2 dma = DualMovingAverage() 3 results = dma.run(data) /Users/my_mac/zipline/data/loader.pyc in load_from_yahoo(indexes, stocks, start, end, adjusted) 302 303 -- 304 data = _load_raw_yahoo_data(indexes, stocks, start, end) 305 if adjusted: 306 close_key = 'Adj Close' /Users/my_mac/zipline/data/loader.pyc in _load_raw_yahoo_data(indexes, stocks, start, end) 245 246 assert indexes is not None or stocks is not None, -- 247 must specify stocks or indexes 248 249 if start is None: AssertionError: must specify stocks or indexes -- https://mail.python.org/mailman/listinfo/python-list