title: IB TWS API - reqHistoricalData - keepUpToDate
body: <p>I am working with a program that retrieves historical data for a given contract through IB TWS API. The issue that I am facing is that when I wish to change 'keepUpToDate' from False to True so that I keep receiving up-to-date data however, the program doesn't run.</p>
  <p>Here is the code:</p>
  <pre><code>from ibapi.client import EClient
  from ibapi.wrapper import EWrapper
  from ibapi.contract import Contract
  from ibapi.common import BarData
  import datetime
  
  
  class MyWrapper(EWrapper):
  
      def nextValidId(self, orderId:int):
          print(&quot;Setting nextValidOrderId: %d&quot;, orderId)
          self.nextValidOrderId = orderId
          self.start()
  
      def historicalData(self, reqId:int, bar: BarData):
          print(&quot;HistoricalData. ReqId:&quot;, reqId, &quot;BarData.&quot;, bar)
  
      def historicalDataEnd(self, reqId: int, start: str, end: str):
          print(&quot;HistoricalDataEnd. ReqId:&quot;, reqId, &quot;from&quot;, start, &quot;to&quot;, end)
          app.disconnect()
          print(&quot;Finished&quot;)
  
      def historicalDataUpdate(self, reqId: int, bar: BarData):
          print(&quot;HistoricalDataUpdate. ReqId:&quot;, reqId, &quot;BarData.&quot;, bar)
  
      def error(self, reqId, errorCode, errorString):
          print(&quot;Error. Id: &quot; , reqId, &quot; Code: &quot; , errorCode , &quot; Msg: &quot; , errorString)
  
      def start(self):
          queryTime = (datetime.datetime.today() - datetime.timedelta(days=0)).strftime(&quot;%Y%m%d %H:%M:%S&quot;)
  
          contract = Contract()
          contract.secType = &quot;STK&quot;
          contract.symbol = &quot;CBLI&quot;
          contract.currency = &quot;USD&quot;
          contract.exchange = &quot;SMART&quot;
  
          app.reqHistoricalData(1, contract, queryTime, &quot;2 D&quot;, &quot;15 mins&quot;, &quot;TRADES&quot;, 0, 1, False, [])
  
  app = EClient(MyWrapper())
  app.connect(&quot;127.0.0.1&quot;, 7496, clientId=123)
  app.run()
  </code></pre>
  <p>I am trying to change the value on line 38 from False to True. I also believe that the problem may be in line 30, because the documentation states &quot;If True, and endDateTime cannot be specified.&quot;</p>
  <p><a href="https://interactivebrokers.github.io/tws-api/historical_bars.html" rel="nofollow noreferrer">https://interactivebrokers.github.io/tws-api/historical_bars.html</a></p>
  <p>Any input would be appreciated.</p>