Browse Source

stock is a tuple not a dict

Foppe Hemminga 6 years ago
parent
commit
0574f0ff9a
1 changed files with 4 additions and 3 deletions
  1. 4 3
      main.py

+ 4 - 3
main.py

@@ -20,13 +20,14 @@ if __name__ == '__main__':
     model.put_timestamp_stored(timestamp_latest)
     timestamp_previous = model.get_timestamp_previous(db)
     for stock in stocks.stocks:
-        data_previous = model.get_data(stock.stock_id, timestamp_previous, db)
-        data_latest = model.get_data(stock.stock_id, timestamp_latest, db)
+        stock_id = stock[1]
+        data_previous = model.get_data(stock_id, timestamp_previous, db)
+        data_latest = model.get_data(stock_id, timestamp_latest, db)
         threshold = stock[3]
         is_drop = model.process_data(data_previous, data_latest, threshold)
-        stock_name = stock[0]
         current_price = data_latest.current_price
         quantity = data_latest.available_shares = data_previous.available_shares
+        stock_name = stock[0]
         message = view.create_message(
             stock_name, timestamp_latest, current_price, quantity)
         print(message)