code: def requestHistoricalData(self, contracts=None, resolution="1 min",
              lookback="1 D", data="TRADES", end_datetime=None, rth=False,
              csv_path=None, format_date=2, utc=False):
  
          
  
          self.csv_path = csv_path
          self.utc_history = utc
  
          if end_datetime == None:
              end_datetime = time.strftime(dataTypes["DATE_TIME_FORMAT_HISTORY"])
  
          if contracts == None:
              contracts = list(self.contracts.values())
  
          if not isinstance(contracts, list):
              contracts = [contracts]
  
          for contract in contracts:
              show = str(data).upper()
              if contract.m_secType in ['CASH', 'CFD'] and data == 'TRADES':
                  show = 'MIDPOINT'
  
              # tickerId = self.tickerId(contract.m_symbol)
              tickerId = self.tickerId(self.contractString(contract))
              self.ibConn.reqHistoricalData(
                  tickerId       = tickerId,
                  contract       = contract,
                  endDateTime    = end_datetime,
                  durationStr    = lookback,
                  barSizeSetting = resolution,
                  whatToShow     = show,
                  useRTH         = int(rth),
                  formatDate     = int(format_date)
              )
docs: Download to historical data
          https://www.interactivebrokers.com/en/software/api/apiguide/java/reqhistoricaldata.htm