def setup(self, universe):
        """
        Setup strategy with universe. This will speed up future calculations
        and updates.
        """
        # save full universe in case we need it
        self._original_data = universe

        # determine if needs paper trading
        # and setup if so
        if self is not self.parent:
            self._paper_trade = True
            self._paper_amount = 1000000

            paper = deepcopy(self)
            paper.parent = paper
            paper.root = paper
            paper._paper_trade = False
            paper.setup(self._original_data)
            paper.adjust(self._paper_amount)
            self._paper = paper

        # setup universe
        funiverse = universe

        if self._universe_tickers is not None:
            # if we have universe_tickers defined, limit universe to
            # those tickers
            valid_filter = list(set(universe.columns)
                                .intersection(self._universe_tickers))

            funiverse = universe[valid_filter].copy()

            # if we have strat children, we will need to create their columns
            # in the new universe
            if self._has_strat_children:
                for c in self._strat_children:
                    funiverse[c] = np.nan

            # must create to avoid pandas warning
            funiverse = pd.DataFrame(funiverse)

        self._universe = funiverse
        # holds filtered universe
        self._funiverse = funiverse
        self._last_chk = None

        # We're not bankrupt yet
        self.bankrupt = False

        # setup internal data
        self.data = pd.DataFrame(index=funiverse.index,
                                 columns=['price', 'value', 'cash', 'fees'],
                                 data=0.0)

        self._prices = self.data['price']
        self._values = self.data['value']
        self._cash = self.data['cash']
        self._fees = self.data['fees']

        # setup children as well - use original universe here - don't want to
        # pollute with potential strategy children in funiverse
        if self.children is not None:
            [c.setup(universe) for c in self._childrenv]
def setup ( self , universe ) : self . _original_data = universe if self is not self . parent : self . _paper_trade = True self . _paper_amount = 1000000 paper = deepcopy ( self ) paper . parent = paper paper . root = paper paper . _paper_trade = False paper . setup ( self . _original_data ) paper . adjust ( self . _paper_amount ) self . _paper = paper funiverse = universe if self . _universe_tickers is not None : valid_filter = list ( set ( universe . columns ) . intersection ( self . _universe_tickers ) ) funiverse = universe [ valid_filter ] . copy ( ) if self . _has_strat_children : for c in self . _strat_children : funiverse [ c ] = np . nan funiverse = pd . DataFrame ( funiverse ) self . _universe = funiverse self . _funiverse = funiverse self . _last_chk = None self . bankrupt = False self . data = pd . DataFrame ( index = funiverse . index , columns = [ 'price' , 'value' , 'cash' , 'fees' ] , data = 0.0 ) self . _prices = self . data [ 'price' ] self . _values = self . data [ 'value' ] self . _cash = self . data [ 'cash' ] self . _fees = self . data [ 'fees' ] if self . children is not None : [ c . setup ( universe ) for c in self . _childrenv ]
Setup strategy with universe. This will speed up future calculations
        and updates.