code: def __init__(
      self,
      start_session,
      end_session,
      returns,
      trading_calendar,
      treasury_curves,
      benchmark_returns,
      algorithm_leverages=None,
  ):
      if treasury_curves.index[-1] >= start_session:
          mask = (treasury_curves.index >= start_session) & (
              treasury_curves.index <= end_session
          )
  
          self.treasury_curves = treasury_curves[mask]
      else:
          # our test is beyond the treasury curve history
          # so we'll use the last available treasury curve
          self.treasury_curves = treasury_curves[-1:]
  
      self._start_session = start_session
      self._end_session = end_session
      self.trading_calendar = trading_calendar
  
      trading_sessions = trading_calendar.sessions_in_range(
          self._start_session,
          self._end_session,
      )
      self.algorithm_returns = self.mask_returns_to_period(
          returns, trading_sessions
      )
  
      # Benchmark needs to be masked to the same dates as the algo returns
      self.benchmark_returns = self.mask_returns_to_period(
          benchmark_returns, self.algorithm_returns.index
      )
      self.algorithm_leverages = algorithm_leverages
  
      self.calculate_metrics()
  
file_path: catalyst/catalyst/finance/risk/period.py
imports: import functools
  import warnings
  import logbook
  from six import iteritems
  import numpy
  import pandas
  from .None import risk
  from .risk import check_entry
  from empyrical import alpha_beta_aligned, annual_volatility, downside_risk, information_ratio, sharpe_ratio, sortino_ratio
  from catalyst.patches.stats import max_drawdown, cum_returns
  from catalyst.constants import LOG_LEVEL
label_desc: Use image node_id 1 to create a new RiskMetricsPeriod object from inherited base classes: object with example: obj = RiskMetricsPeriod(start_session, end_session, returns, trading_calendar, treasury_curves, benchmark_returns, algorithm_leverages)