'Runs the analysis using the bars supplied by the feed.
:param barFeed: The bar feed to use to run the analysis.
:type barFeed: :class:`pyalgotrade.barfeed.BarFeed`.
:param useAdjustedCloseForReturns: True if adjusted close values should be used to calculate returns.
:type useAdjustedCloseForReturns: boolean.'

def run(self, feed, useAdjustedCloseForReturns=True):

    if useAdjustedCloseForReturns:
        assert feed.barsHaveAdjClose(), "Feed    doesn't    have    adjusted    close    values"
    try:
        self.__feed = feed
        self.__rets = {}
        self.__futureRets = {}
        for instrument in feed.getRegisteredInstruments():
            self.__events.setdefault(instrument, [])
            self.__futureRets[instrument] = []
            if useAdjustedCloseForReturns:
                ds = feed[instrument].getAdjCloseDataSeries()
            else:
                ds = feed[instrument].getCloseDataSeries()
            self.__rets[instrument] = roc.RateOfChange(ds, 1)
        feed.getNewValuesEvent().subscribe(self.__onBars)
        disp = dispatcher.Dispatcher()
        disp.addSubject(feed)
        disp.run()
    finally:
        feed.getNewValuesEvent().unsubscribe(self.__onBars)
