Pyalgotrade Tutorial Attribute Error
Question: I have been googling for a while now, but am still unable to find a solution,
or even determine the problem, honestly.

My installation of Python and Pyalgotrade is correct, as verified by the
successful imports.

Nonetheless, I can't manage to run the example code in the tutorial, it always
throws:

    
    
    AttributeError: MyStrategy instance has no attribute 'info'
    

Here's the example code:

    
    
    from pyalgotrade import strategy
    from pyalgotrade.barfeed import yahoofeed
    
    
    class MyStrategy(strategy.BacktestingStrategy):
        def __init__(self, feed, instrument):
            strategy.BacktestingStrategy.__init__(self, feed)
            self.__instrument = instrument
    
        def onBars(self, bars):
            bar = bars[self.__instrument]
            self.info(bar.getClose())
    
    # Load the yahoo feed from the CSV file
    feed = yahoofeed.Feed()
    feed.addBarsFromCSV("orcl", "orcl-2000.csv")
    
    # Evaluate the strategy with the feed's bars.
    myStrategy = MyStrategy(feed, "orcl")
    myStrategy.run()
    

And the iPython Notebook output:

    
    
    ---------------------------------------------------------------------------
    AttributeError                            Traceback (most recent call last)
    <ipython-input-1-f786d1b471f7> in <module>()
     18 # Evaluate the strategy with the feed's bars.
     19 myStrategy = MyStrategy(feed, "orcl")
    ---> 20 myStrategy.run()
    
    /usr/local/lib/python2.7/site-packages/pyalgotrade/strategy/__init__.pyc in run(self)
    398                 self.onStart()
    399 
    --> 400                 self.__dispatcher.run()
    401 
    402                 if self.__feed.getCurrentBars() != None:
    
    /usr/local/lib/python2.7/site-packages/pyalgotrade/observer.pyc in run(self)
    139                                 subject.start()
    140 
    --> 141                         while not self.__stopped and self.__dispatch():
    142                                 pass
    143                 finally:
    
    /usr/local/lib/python2.7/site-packages/pyalgotrade/observer.pyc in __dispatch(self)
    131                                         nextDateTime = subject.peekDateTime()
    132                                         if nextDateTime == None or nextDateTime ==   smallestDateTime:
    --> 133                                                 subject.dispatch()
    134                 return ret
    135 
    
    /usr/local/lib/python2.7/site-packages/pyalgotrade/feed/__init__.pyc in dispatch(self)
     95                 dateTime, values = self.getNextValuesAndUpdateDS()
     96                 if dateTime != None:
    ---> 97                         self.__event.emit(dateTime, values)
     98 
     99         def getKeys(self):
    
    /usr/local/lib/python2.7/site-packages/pyalgotrade/observer.pyc in emit(self, *parameters)
     51                 self.__emitting = True
     52                 for handler in self.__handlers:
    ---> 53                         handler(*parameters)
     54                 self.__emitting = False
     55                 self.__applyChanges()
    
    /usr/local/lib/python2.7/site-packages/pyalgotrade/strategy/__init__.pyc in __onBars(self, dateTime, bars)
    386 
    387                 # 1: Let the strategy process current bars and place orders.
    --> 388                 self.onBars(bars)
    389 
    390                 # 2: Place the necessary orders for positions marked to exit on session close.
    
    <ipython-input-1-f786d1b471f7> in onBars(self, bars)
     10     def onBars(self, bars):
     11         bar = bars[self.__instrument]
    ---> 12         self.info(bar.getClose())
     13 
     14 # Load the yahoo feed from the CSV file
    
    AttributeError: MyStrategy instance has no attribute 'info'
    

Has anyone at least a hint on what the problem could be?


Answer: Which version of PyAlgoTrade are you using ?

    
    
    import pyalgotrade
    print pyalgotrade.__version__
    

