class_docstr: A Backtest combines a Strategy with data to
  produce a Result.
  
  A backtest is basically testing a strategy over a data set.
  
  Note:
      The Strategy will be deepcopied so it is re-usable in other
      backtests. To access the backtested strategy, simply access
      the strategy attribute.
  
  Args:
      * strategy (Strategy, Node, StrategyBase): The Strategy to be tested.
      * data (DataFrame): DataFrame containing data used in backtest. This
        will be the Strategy's "universe".
      * name (str): Backtest name - defaults to strategy name
      * initial_capital (float): Initial amount of capital passed to
        Strategy.
      * commissions (fn(quantity, price)): The commission function
        to be used. Ex: commissions=lambda q, p: max(1, abs(q) * 0.01)
      * integer_positions (bool): Whether to use integer positions for securities
        in the backtest. This can have unintended consequences when prices are
        high relative to the amount of capital (i.e. though split-adjusted prices,
        or too-low of a capital amount), causing allocated positions to round to zero.
        While the default is True, try setting to False for more robust behavior.
      * progress_bar (Bool): Display progress bar while running backtest
      * additional_data (dict): Additional kwargs passed to StrategyBase.setup, after preprocessing
        This data can be retrieved by Algos using StrategyBase.get_data.
        The data may also be used by the Strategy itself, i.e.
          - ``bidoffer``: A DataFrame with the same format as 'data', will be used
            by the strategy for transaction cost modeling
          - ``coupons``: A DataFrame with the same format as 'data', will by used
            by :class:`CouponPayingSecurity <bt.core.CouponPayingSecurity>`
            to determine cashflows.
          - ``cost_long``/``cost_short``: A DataFrame with the same format as 'data',
            will by used
            by :class:`CouponPayingSecurity <bt.core.CouponPayingSecurity>`
            to calculate asymmetric holding cost of long (or short) positions.
  
  
  Attributes:
      * strategy (Strategy): The Backtest's Strategy. This will be a deepcopy
        of the Strategy that was passed in.
      * data (DataFrame): Data passed in
      * dates (DateTimeIndex): Data's index
      * initial_capital (float): Initial capital
      * name (str): Backtest name
      * stats (ffn.PerformanceStats): Performance statistics
      * has_run (bool): Run flag
      * weights (DataFrame): Weights of each component over time
      * security_weights (DataFrame): Weights of each security as a
        percentage of the whole portfolio over time
      * additional_data (dict): Additional data passed at construction
class_docstr_tok: ["A","Backtest","combines","a","Strategy","with","data","to","produce","a","Result",".","A","backtest","is","basically","testing","a","strategy","over","a","data","set",".","Note",":","The","Strategy","will","be","deepcopied","so","it","is","re-usable","in","other","backtests",".","To","access","the","backtested","strategy",",","simply","access","the","strategy","attribute",".","Args",":","*","strategy","(","Strategy",",","Node",",","StrategyBase",")",":","The","Strategy","to","be","tested",".","*","data","(","DataFrame",")",":","DataFrame","containing","data","used","in","backtest",".","This","will","be","the","Strategy","'s","``","universe","''",".","*","name","(","str",")",":","Backtest","name","-","defaults","to","strategy","name","*","initial_capital","(","float",")",":","Initial","amount","of","capital","passed","to","Strategy",".","*","commissions","(","fn","(","quantity",",","price",")",")",":","The","commission","function","to","be","used",".","Ex",":","commissions=lambda","q",",","p",":","max","(","1",",","abs","(","q",")","*","0.01",")","*","integer_positions","(","bool",")",":","Whether","to","use","integer","positions","for","securities","in","the","backtest",".","This","can","have","unintended","consequences","when","prices","are","high","relative","to","the","amount","of","capital","(","i.e",".","though","split-adjusted","prices",",","or","too-low","of","a","capital","amount",")",",","causing","allocated","positions","to","round","to","zero",".","While","the","default","is","True",",","try","setting","to","False","for","more","robust","behavior",".","*","progress_bar","(","Bool",")",":","Display","progress","bar","while","running","backtest","*","additional_data","(","dict",")",":","Additional","kwargs","passed","to","StrategyBase.setup",",","after","preprocessing","This","data","can","be","retrieved","by","Algos","using","StrategyBase.get_data",".","The","data","may","also","be","used","by","the","Strategy","itself",",","i.e",".","-","``","bidoffer","``",":","A","DataFrame","with","the","same","format","as","'data","'",",","will","be","used","by","the","strategy","for","transaction","cost","modeling","-","``","coupons","``",":","A","DataFrame","with","the","same","format","as","'data","'",",","will","by","used","by",":","class",":","`","CouponPayingSecurity","<","bt.core.CouponPayingSecurity",">","`","to","determine","cashflows",".","-","``","cost_long","``","\/","``","cost_short","``",":","A","DataFrame","with","the","same","format","as","'data","'",",","will","by","used","by",":","class",":","`","CouponPayingSecurity","<","bt.core.CouponPayingSecurity",">","`","to","calculate","asymmetric","holding","cost","of","long","(","or","short",")","positions",".","Attributes",":","*","strategy","(","Strategy",")",":","The","Backtest","'s","Strategy",".","This","will","be","a","deepcopy","of","the","Strategy","that","was","passed","in",".","*","data","(","DataFrame",")",":","Data","passed","in","*","dates","(","DateTimeIndex",")",":","Data","'s","index","*","initial_capital","(","float",")",":","Initial","capital","*","name","(","str",")",":","Backtest","name","*","stats","(","ffn.PerformanceStats",")",":","Performance","statistics","*","has_run","(","bool",")",":","Run","flag","*","weights","(","DataFrame",")",":","Weights","of","each","component","over","time","*","security_weights","(","DataFrame",")",":","Weights","of","each","security","as","a","percentage","of","the","whole","portfolio","over","time","*","additional_data","(","dict",")",":","Additional","data","passed","at","construction"]
docstr: DataFrame of each component's weight over time
docstr_tok: ["DataFrame","of","each","component","'s","weight","over","time"]
code: def weights(self):
      """
      DataFrame of each component's weight over time
      """
      if self._weights is not None:
          return self._weights
      else:
          if self.strategy.fixed_income:
              vals = pd.DataFrame(
                  {
                      x.full_name: x.notional_values
                      for x in self.strategy.members
                  }
              )
              vals = vals.div(self.strategy.notional_values, axis=0)
          else:
              vals = pd.DataFrame(
                  {x.full_name: x.values for x in self.strategy.members}
              )
              vals = vals.div(self.strategy.values, axis=0)
          self._weights = vals
          return vals
  
imports: from __future__ import division
  from copy import deepcopy
  import bt
  import ffn
  import pandas
  import numpy
  from matplotlib import pyplot
  import pyprind
  from tqdm import tqdm
label_desc: Use image node_id 4 for calling the Backtest obj's underlying member method code with example usage: obj.weights() and returns: self, vals