@plotting.customize<EOL>def create_perf_attrib_tear_sheet(returns,<EOL>positions,<EOL>factor_returns,<EOL>factor_loadings,<EOL>transactions=None,<EOL>pos_in_dollars=True,<EOL>return_fig=False,<EOL>factor_partitions=FACTOR_PARTITIONS):
portfolio_exposures, perf_attrib_data = perf_attrib.perf_attrib(<EOL>returns, positions, factor_returns, factor_loadings, transactions,<EOL>pos_in_dollars=pos_in_dollars<EOL>)<EOL>display(Markdown("<STR_LIT>"))<EOL>perf_attrib.show_perf_attrib_stats(returns, positions, factor_returns,<EOL>factor_loadings, transactions,<EOL>pos_in_dollars)<EOL>vertical_sections = <NUM_LIT:1> + <NUM_LIT:2> * max(len(factor_partitions), <NUM_LIT:1>)<EOL>current_section = <NUM_LIT:0><EOL>fig = plt.figure(figsize=[<NUM_LIT>, vertical_sections * <NUM_LIT:6>])<EOL>gs = gridspec.GridSpec(vertical_sections, <NUM_LIT:1>,<EOL>wspace=<NUM_LIT:0.5>, hspace=<NUM_LIT:0.5>)<EOL>perf_attrib.plot_returns(perf_attrib_data,<EOL>ax=plt.subplot(gs[current_section]))<EOL>current_section += <NUM_LIT:1><EOL>if factor_partitions is not None:<EOL><INDENT>for factor_type, partitions in factor_partitions.iteritems():<EOL><INDENT>columns_to_select = perf_attrib_data.columns.intersection(<EOL>partitions<EOL>)<EOL>perf_attrib.plot_factor_contribution_to_perf(<EOL>perf_attrib_data[columns_to_select],<EOL>ax=plt.subplot(gs[current_section]),<EOL>title=(<EOL>'<STR_LIT>'<EOL>).format(factor_type)<EOL>)<EOL>current_section += <NUM_LIT:1><EOL><DEDENT>for factor_type, partitions in factor_partitions.iteritems():<EOL><INDENT>perf_attrib.plot_risk_exposures(<EOL>portfolio_exposures[portfolio_exposures.columns<EOL>.intersection(partitions)],<EOL>ax=plt.subplot(gs[current_section]),<EOL>title='<STR_LIT>'.format(factor_type)<EOL>)<EOL>current_section += <NUM_LIT:1><EOL><DEDENT><DEDENT>else:<EOL><INDENT>perf_attrib.plot_factor_contribution_to_perf(<EOL>perf_attrib_data,<EOL>ax=plt.subplot(gs[current_section])<EOL>)<EOL>current_section += <NUM_LIT:1><EOL>perf_attrib.plot_risk_exposures(<EOL>portfolio_exposures,<EOL>ax=plt.subplot(gs[current_section])<EOL>)<EOL><DEDENT>gs.tight_layout(fig)<EOL>if return_fig:<EOL><INDENT>return fig<EOL><DEDENT>
Generate plots and tables for analyzing a strategy's performance.

Parameters
----------
returns : pd.Series
    Returns for each day in the date range.

positions: pd.DataFrame
    Daily holdings (in dollars or percentages), indexed by date.
    Will be converted to percentages if positions are in dollars.
    Short positions show up as cash in the 'cash' column.

factor_returns : pd.DataFrame
    Returns by factor, with date as index and factors as columns

factor_loadings : pd.DataFrame
    Factor loadings for all days in the date range, with date
    and ticker as index, and factors as columns.

transactions : pd.DataFrame, optional
    Prices and amounts of executed trades. One row per trade.
     - See full explanation in create_full_tear_sheet.
     - Default is None.

pos_in_dollars : boolean, optional
    Flag indicating whether `positions` are in dollars or percentages
    If True, positions are in dollars.

return_fig : boolean, optional
    If True, returns the figure that was plotted on.

factor_partitions : dict
    dict specifying how factors should be separated in factor returns
    and risk exposures plots
    - Example:
      {'style': ['momentum', 'size', 'value', ...],
       'sector': ['technology', 'materials', ... ]}