code: def construct_request(ticker, fields=None, date=None,
                            date_from=None, date_to=None, freq=None):
          
          if isinstance(ticker, basestring):
              request = ticker
          elif hasattr(ticker, '__len__'):
              request = ','.join(ticker)
          else:
              raise ValueError('ticker should be either string or list/array of strings')
          if fields is not None:
              if isinstance(fields, basestring):
                  request += '~=' + fields
              elif isinstance(fields, list) and len(fields) > 0:
                  request += '~=' + ','.join(fields)
          if date is not None:
              request += '~@' + pd.to_datetime(date).strftime('%Y-%m-%d')
          else:
              if date_from is not None:
                  request += '~' + pd.to_datetime(date_from).strftime('%Y-%m-%d')
              if date_to is not None:
                  request += '~:' + pd.to_datetime(date_to).strftime('%Y-%m-%d')
          if freq is not None:
              request += '~' + freq
          return request
docs: Construct a request string for querying TR DWE.
  
             tickers - ticker or symbol
             fields  - list of fields.
             date    - date for a single-date query
             date_from, date_to - date range (used only if "date" is not specified)
             freq    - frequency of data: daily('D'), weekly('W') or monthly('M')
                       Use here 'REP' for static requests
  
             Some of available fields:
             P  - adjusted closing price
             PO - opening price
             PH - high price
             PL - low price
             VO - volume, which is expressed in 1000's of shares.
             UP - unadjusted price
             OI - open interest
  
             MV - market value
             EPS - earnings per share
             DI - dividend index
             MTVB - market to book value
             PTVB - price to book value
             ...
  
             The full list of data fields is available at http://dtg.tfn.com/.