Bläddra i källkod

Don't send message when the dop is tiny in comparison with shares available

Foppe Hemminga 6 år sedan
förälder
incheckning
e6b45d8bc7
3 ändrade filer med 7 tillägg och 3 borttagningar
  1. 2 1
      main.py
  2. 3 0
      model.py
  3. 2 2
      view.py

+ 2 - 1
main.py

@@ -29,10 +29,11 @@ def process_drop(this_stock):
     quantity = data_latest.available_shares - data_previous.available_shares
     stock_name = this_stock[0]
     npc_drop = False
+    total_stocks = data_latest.total_shares
     if model.is_npc_drop(data_previous, data_latest):
         npc_drop = True
     message = view.create_message(
-        stock_name, timestamp_latest, current_price, quantity, npc_drop=npc_drop)
+        stock_name, timestamp_latest, current_price, quantity, current_quantity=total_stocks, npc_drop=npc_drop)
     print(message)
     if is_drop:
         view.broadcast(message)

+ 3 - 0
model.py

@@ -87,6 +87,9 @@ def process_data(data_previous, data_latest, price, threshold):
     quantity_latest = data_latest.available_shares * float(data_latest.current_price)
     if data_latest.current_price < price and quantity_latest - quantity_previous > threshold * 1e9:
         this_drop = True
+    # New: don't report when there are a lot of stocks outstanding
+    if data_previous.available_shares > data_previous.total_shares / 20:
+        this_drop = False
     return this_drop
 
 

+ 2 - 2
view.py

@@ -22,8 +22,8 @@ def create_message(name, timestamp, price, quantity, current_quantity=0, forecas
     npc = ''
     if npc_drop:
         npc = '*NPC* '
-    this_message = "{}: {}{} dropped {:,} shares at ${:,.2f} for a grand total of ${:,.1f}B".format(
-        this_time, npc, name, quantity, price, this_drop_decimal)
+    this_message = "{}: {}{} dropped {:,} shares at ${:,.2f} for a grand total of ${:,.1f}B [{:,}]".format(
+        this_time, npc, name, quantity, price, this_drop_decimal, current_quantity)
     if forecast_previous and forecast_latest:
         this_message = "{}: {} changed from {} to {} with {:,} shares available at ${:,.2f}".format(
             this_time, name, forecast_previous, forecast_latest, current_quantity, price)