code: def create_capacity_tear_sheet(
      returns,
      positions,
      transactions,
      market_data,
      liquidation_daily_vol_limit=0.2,
      trade_daily_vol_limit=0.05,
      last_n_days=utils.APPROX_BDAYS_PER_MONTH * 6,
      days_to_liquidate_limit=1,
      estimate_intraday="infer",
      return_fig=False,
  ):
      """
      Generates a report detailing portfolio size constraints set by
      least liquid tickers. Plots a "capacity sweep," a curve describing
      projected sharpe ratio given the slippage penalties that are
      applied at various capital bases.
  
      Parameters
      ----------
      returns : pd.Series
          Daily returns of the strategy, noncumulative.
           - See full explanation in create_full_tear_sheet.
      positions : pd.DataFrame
          Daily net position values.
           - See full explanation in create_full_tear_sheet.
      transactions : pd.DataFrame
          Prices and amounts of executed trades. One row per trade.
           - See full explanation in create_full_tear_sheet.
      market_data : pd.DataFrame
          Daily market_data
          - DataFrame has a multi-index index, one level is dates and another is
          market_data contains volume & price, equities as columns
      liquidation_daily_vol_limit : float
          Max proportion of a daily bar that can be consumed in the
          process of liquidating a position in the
          "days to liquidation" analysis.
      trade_daily_vol_limit : float
          Flag daily transaction totals that exceed proportion of
          daily bar.
      last_n_days : integer
          Compute max position allocation and dollar volume for only
          the last N days of the backtest
      days_to_liquidate_limit : integer
          Display all tickers with greater max days to liquidation.
      estimate_intraday: boolean or str, optional
          Approximate returns for intraday strategies.
          See description in create_full_tear_sheet.
      return_fig : boolean, optional
          If True, returns the figure that was plotted on.
      """
  
      positions = utils.check_intraday(
          estimate_intraday, returns, positions, transactions
      )
  
      print(
          "Max days to liquidation is computed for each traded name "
          "assuming a 20% limit on daily bar consumption \n"
          "and trailing 5 day mean volume as the available bar volume.\n\n"
          "Tickers with >1 day liquidation time at a"
          " constant $1m capital base:"
      )
  
      max_days_by_ticker = capacity.get_max_days_to_liquidate_by_ticker(
          positions,
          market_data,
          max_bar_consumption=liquidation_daily_vol_limit,
          capital_base=1e6,
          mean_volume_window=5,
      )
      max_days_by_ticker.index = max_days_by_ticker.index.map(
          utils.format_asset
      )
  
      print("Whole backtest:")
      utils.print_table(
          max_days_by_ticker[
              max_days_by_ticker.days_to_liquidate
              > days_to_liquidate_limit
          ]
      )
  
      max_days_by_ticker_lnd = (
          capacity.get_max_days_to_liquidate_by_ticker(
              positions,
              market_data,
              max_bar_consumption=liquidation_daily_vol_limit,
              capital_base=1e6,
              mean_volume_window=5,
              last_n_days=last_n_days,
          )
      )
      max_days_by_ticker_lnd.index = max_days_by_ticker_lnd.index.map(
          utils.format_asset
      )
  
      print("Last {} trading days:".format(last_n_days))
      utils.print_table(
          max_days_by_ticker_lnd[
              max_days_by_ticker_lnd.days_to_liquidate > 1
          ]
      )
  
      llt = capacity.get_low_liquidity_transactions(
          transactions, market_data
      )
      llt.index = llt.index.map(utils.format_asset)
  
      print(
          "Tickers with daily transactions consuming >{}% of daily bar \n"
          "all backtest:".format(trade_daily_vol_limit * 100)
      )
      utils.print_table(
          llt[llt["max_pct_bar_consumed"] > trade_daily_vol_limit * 100]
      )
  
      llt = capacity.get_low_liquidity_transactions(
          transactions, market_data, last_n_days=last_n_days
      )
  
      print("Last {} trading days:".format(last_n_days))
      utils.print_table(
          llt[llt["max_pct_bar_consumed"] > trade_daily_vol_limit * 100]
      )
  
      bt_starting_capital = positions.iloc[0].sum() / (
          1 + returns.iloc[0]
      )
      fig, ax_capacity_sweep = plt.subplots(figsize=(14, 6))
      plotting.plot_capacity_sweep(
          returns,
          transactions,
          market_data,
          bt_starting_capital,
          min_pv=100000,
          max_pv=300000000,
          step_size=1000000,
          ax=ax_capacity_sweep,
      )
  
      if return_fig:
          return fig
  
imports: from __future__ import division
  import warnings
  from time import time
  import empyrical
  from IPython.display import display, Markdown
  import matplotlib.gridspec
  import matplotlib.pyplot
  import pandas
  from .None import _seaborn
  from .None import capacity
  from .None import perf_attrib
  from .None import plotting
  from .None import pos
  from .None import round_trips
  from .None import timeseries
  from .None import txn
  from .None import utils
label_desc: Use image node_id 9 for calling a global function with example usage: create_capacity_tear_sheet(returns, positions, transactions, market_data, liquidation_daily_vol_limit, trade_daily_vol_limit, last_n_days, days_to_liquidate_limit, estimate_intraday, return_fig) and returns: fig