title: IB Python API - List of Prices of Stock for last x-seconds
body: <p>I would like to get a list of prices for a given stock for the last x-seconds. I have written the following code to do this:</p>
  <pre><code>symbol = &quot;DAI&quot;
  contract = Contract()
  contract.symbol = symbol
  contract.secType = 'STK'
  contract.exchange = 'SMART'
  contract.currency = &quot;EUR&quot;
  contract.primaryExchange = &quot;SMART&quot;
  
  class TestApp(EWrapper, EClient):
      def __init__(self):
          EClient.__init__(self, self)
          self.data = []
          self.workingOrders = {}
  
      def nextValidId(self, orderId):
          self.nextOrderId = orderId
          self.start()
  
      def start(self):
          self.reqMarketDataType(3)
          self.reqMktData(1, contract, '', False, False, [])
  
      def tickPrice(self, reqId, tickType, price, attrib):
          if tickType == 2 and reqId == 1:
              self.checkLogic(price)
  
      def checkLogic(self, ask):
          prices = []
          seconds = []
          time_ = []
          seconds_counter = 0
          timer = str(format(datetime.now() + timedelta(seconds=15), '%H:%M:%S'))
          while str(format(datetime.now(), '%H:%M:%S')) &lt;= timer:
              self.data.append(ask)
              prices.append(ask)
              seconds.append(seconds_counter)
              time_.append(str(datetime.now(tz).time())[:8])
              time.sleep(1)
              seconds_counter += 1
  
          df = pd.DataFrame(np.column_stack([time_, seconds, prices]),
                            columns=['Time', 'Seconds', 'Prices'])
          pd.DataFrame(df).to_csv(&quot;Prices/%s.csv&quot; % symbol)
  
          self.disconnect()
  
  
  def main():
      app = TestApp()
      app.connect('127.0.0.1', 7497, 24)
      app.run()
  </code></pre>
  <p>This produces a list of the prices of the stock for the last 15 seconds. The problem is, that the price is the same for all 15 seconds, so it is not updating.
  I guess the reason for this is that the price is just queried once and not updated in the while-loop.</p>
  <p>How can I get the actual updated prices for every price query in the while-loop?</p>