code: def load_market_data(
      trading_day=None, trading_days=None, bm_symbol="SPY", environ=None
  ):
      """
      Load benchmark returns and treasury yield curves for the given calendar and
      benchmark symbol.
  
      Benchmarks are downloaded as a Series from Google Finance.  Treasury curves
      are US Treasury Bond rates and are downloaded from 'www.federalreserve.gov'
      by default.  For Canadian exchanges, a loader for Canadian bonds from the
      Bank of Canada is also available.
  
      Results downloaded from the internet are cached in
      ~/.catalyst/data. Subsequent loads will attempt to read from the cached
      files before falling back to redownload.
  
      Parameters
      ----------
      trading_day : pandas.CustomBusinessDay, optional
          A trading_day used to determine the latest day for which we
          expect to have data.  Defaults to an NYSE trading day.
      trading_days : pd.DatetimeIndex, optional
          A calendar of trading days.  Also used for determining what cached
          dates we should expect to have cached. Defaults to the NYSE calendar.
      bm_symbol : str, optional
          Symbol for the benchmark index to load.  Defaults to 'SPY', the Google
          ticker for the S&P 500.
  
      Returns
      -------
      (benchmark_returns, treasury_curves) : (pd.Series, pd.DataFrame)
  
      Notes
      -----
  
      Both return values are DatetimeIndexed with values dated to midnight in UTC
      of each stored date.  The columns of `treasury_curves` are:
  
      '1month', '3month', '6month',
      '1year','2year','3year','5year','7year','10year','20year','30year'
      """
      if trading_day is None:
          trading_day = get_calendar("NYSE").trading_day
      if trading_days is None:
          trading_days = get_calendar("NYSE").all_sessions
  
      first_date = trading_days[0]
      now = pd.Timestamp.utcnow()
  
      # We expect to have benchmark and treasury data that's current up until
      # **two** full trading days prior to the most recently completed trading
      # day.
      # Example:
      # On Thu Oct 22 2015, the previous completed trading day is Wed Oct 21.
      # However, data for Oct 21 doesn't become available until the early morning
      # hours of Oct 22.  This means that there are times on the 22nd at which we
      # cannot reasonably expect to have data for the 21st available.  To be
      # conservative, we instead expect that at any time on the 22nd, we can
      # download data for Tuesday the 20th, which is two full trading days prior
      # to the date on which we're running a test.
  
      # We'll attempt to download new data if the latest entry in our cache is
      # before this date.
      last_date = trading_days[
          trading_days.get_loc(now, method="ffill") - 2
      ]
  
      br = ensure_benchmark_data(
          bm_symbol,
          first_date,
          last_date,
          now,
          # We need the trading_day to figure out the close prior to the first
          # date so that we can compute returns for the first date.
          trading_day,
          environ,
      )
      tc = ensure_treasury_data(
          bm_symbol,
          first_date,
          last_date,
          now,
          environ,
      )
      benchmark_returns = br[
          br.index.slice_indexer(first_date, last_date)
      ]
      treasury_curves = tc[
          tc.index.slice_indexer(first_date, last_date)
      ]
      return benchmark_returns, treasury_curves
  
imports: import os
  from collections import OrderedDict
  import logbook
  import pandas
  import pytz
  from pandas_datareader.data import DataReader
  from six import iteritems
  from six.moves.urllib_error import HTTPError
  from catalyst.constants import LOG_LEVEL
  from catalyst.utils.calendars import get_calendar
  from .None import treasuries, treasuries_can
  from .benchmarks import get_benchmark_returns
  from ..utils.deprecate import deprecated
  from ..utils.paths import cache_root, data_root
label_desc: Use image node_id 7 for calling a global function with example usage: load_market_data(trading_day, trading_days, bm_symbol, environ) and returns: benchmark_returns,  treasury_curves