code: def build_feed(
      sourceCode,
      tableCodes,
      fromYear,
      toYear,
      storage,
      frequency=bar.Frequency.DAY,
      timezone=None,
      skipErrors=False,
      authToken=None,
      columnNames={},
      forceDownload=False,
      skipMalformedBars=False,
  ):
      """Build and load a :class:`pyalgotrade.barfeed.quandlfeed.Feed` using CSV files downloaded from Quandl.
      CSV files are downloaded if they haven't been downloaded before.
  
      :param sourceCode: The dataset source code.
      :type sourceCode: string.
      :param tableCodes: The dataset table codes.
      :type tableCodes: list.
      :param fromYear: The first year.
      :type fromYear: int.
      :param toYear: The last year.
      :type toYear: int.
      :param storage: The path were the files will be loaded from, or downloaded to.
      :type storage: string.
      :param frequency: The frequency of the bars. Only **pyalgotrade.bar.Frequency.DAY** or **pyalgotrade.bar.Frequency.WEEK**
          are supported.
      :param timezone: The default timezone to use to localize bars. Check :mod:`pyalgotrade.marketsession`.
      :type timezone: A pytz timezone.
      :param skipErrors: True to keep on loading/downloading files in case of errors.
      :type skipErrors: boolean.
      :param authToken: Optional. An authentication token needed if you're doing more than 50 calls per day.
      :type authToken: string.
      :param columnNames: Optional. A dictionary to map column names. Valid key values are:
  
          * datetime
          * open
          * high
          * low
          * close
          * volume
          * adj_close
  
      :type columnNames: dict.
      :param skipMalformedBars: True to skip errors while parsing bars.
      :type skipMalformedBars: boolean.
  
      :rtype: :class:`pyalgotrade.barfeed.quandlfeed.Feed`.
      """
  
      logger = pyalgotrade.logger.getLogger("quandl")
      ret = quandlfeed.Feed(frequency, timezone)
  
      # Additional column names.
      for col, name in six.iteritems(columnNames):
          ret.setColumnName(col, name)
  
      if not os.path.exists(storage):
          logger.info("Creating %s directory" % (storage))
          os.mkdir(storage)
  
      for year in range(fromYear, toYear + 1):
          for tableCode in tableCodes:
              fileName = os.path.join(
                  storage,
                  "%s-%s-%d-quandl.csv" % (sourceCode, tableCode, year),
              )
              if not os.path.exists(fileName) or forceDownload:
                  logger.info(
                      "Downloading %s %d to %s"
                      % (tableCode, year, fileName)
                  )
                  try:
                      if frequency == bar.Frequency.DAY:
                          download_daily_bars(
                              sourceCode,
                              tableCode,
                              year,
                              fileName,
                              authToken,
                          )
                      else:
                          assert (
                              frequency == bar.Frequency.WEEK
                          ), "Invalid frequency"
                          download_weekly_bars(
                              sourceCode,
                              tableCode,
                              year,
                              fileName,
                              authToken,
                          )
                  except Exception as e:
                      if skipErrors:
                          logger.error(str(e))
                          continue
                      else:
                          raise e
              ret.addBarsFromCSV(
                  tableCode,
                  fileName,
                  skipMalformedBars=skipMalformedBars,
              )
      return ret
  
file_path: pyalgotrade/pyalgotrade/tools/quandl.py
imports: import datetime
  import os
  import argparse
  import six
  from pyalgotrade import bar
  from pyalgotrade.barfeed import quandlfeed
  from pyalgotrade.utils import dt
  from pyalgotrade.utils import csvutils
  import pyalgotrade.logger
label_desc: Use image node_id 4 for calling a global function with example usage: build_feed(sourceCode, tableCodes, fromYear, toYear, storage, frequency, timezone, skipErrors, authToken, columnNames, forceDownload, skipMalformedBars) and returns: ret