Преглед изворни кода

Change to total_shares in is_npc_drop()

Foppe Hemminga пре 6 година
родитељ
комит
d4ef56ffc7
1 измењених фајлова са 6 додато и 4 уклоњено
  1. 6 4
      model.py

+ 6 - 4
model.py

@@ -64,7 +64,9 @@ def get_data(stock_id, this_timestamp, this_db):
     :return:
     """
     cursor = this_db.cursor(cursor_factory=psycopg2.extras.NamedTupleCursor)
-    query = """SELECT current_price, available_shares, forecast FROM stocks WHERE stock_id = %s AND timestamp = %s"""
+    query = """SELECT current_price, available_shares, forecast, total_shares
+        FROM stocks 
+        WHERE stock_id = %s AND timestamp = %s"""
     cursor.execute(query, (stock_id, this_timestamp))
     this_data = cursor.fetchone()
     cursor.close()
@@ -96,9 +98,9 @@ def is_npc_drop(data_previous, data_latest):
     :return:
     """
     npc_drop = False
-    if data_latest.available_shares - data_previous.available_shares > 0:
-        print('data_latest.available_shares {}'.format(data_latest.available_shares))
-        print('data_previous.available_shares {}'.format(data_previous.available_shares))
+    if data_latest.total_shares - data_previous.totals_shares > 0:
+        print('data_latest.total_shares {}'.format(data_latest.total_shares))
+        print('data_previous.total_shares {}'.format(data_previous.totals_shares))
         npc_drop = True
     return npc_drop