@@ -1,10 +1,10 @@
-# from dotenv import load_dotenv
+from dotenv import load_dotenv
import os
import psycopg2
# Develop only
-# load_dotenv()
+load_dotenv()
host = os.environ["STOCK_DB_HOST"]
port = os.environ["STOCK_DB_PORT"]
@@ -25,7 +25,7 @@ if __name__ == '__main__':
data_latest = model.get_data(stock_id, timestamp_latest, db)
threshold = stock[3]
is_drop = model.process_data(data_previous, data_latest, threshold)
- current_price = data_latest.current_price
+ current_price = float(data_latest.current_price)
quantity = data_latest.available_shares - data_previous.available_shares
stock_name = stock[0]
message = view.create_message(
@@ -71,8 +71,8 @@ def process_data(this_data_previous, this_data_latest, this_threshold):
:return boolean:
"""
this_drop = False
- quantity_previous = this_data_previous.available_shares * this_data_latest.current_price
- quantity_latest = this_data_latest.available_shares * this_data_latest.current_price
+ quantity_previous = this_data_previous.available_shares * float(this_data_latest.current_price)
+ quantity_latest = this_data_latest.available_shares * float(this_data_latest.current_price)
if quantity_latest - quantity_previous > this_threshold * 1e9:
this_drop = True
return this_drop
@@ -1 +1 @@
-1559608500
+1559654400
@@ -13,7 +13,7 @@ def create_message(name, timestamp, price, quantity):
:return:
this_time = datetime.utcfromtimestamp(timestamp).strftime('%Y-%m-%d %H:%M:%S')
- this_drop_decimal = float((quantity * 1.0) * (price * 1.0) / 1e9)
+ this_drop_decimal = quantity * price / 1e9
this_message = "{}: {} dropped {} shares at ${:.2f} for a grand total of ${:.1f}B".format(
this_time, name, quantity, price, this_drop_decimal)
return this_message