import model import sys import stocks import view """ This is the controller file """ if __name__ == '__main__': timestamp_latest = model.get_timestamp_latest() timestamp_stored = model.get_timestamp_stored() if timestamp_latest == timestamp_stored: """Nothing to do""" sys.exit() # Update timestamp_stored model.put_timestamp_stored(timestamp_latest) timestamp_previous = model.get_timestamp_previous() for stock in stocks.stocks: data_previous = model.get_data(stock.stock_id, timestamp_previous) data_latest = model.get_data(stock.stock_id, timestamp_latest) 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 message = view.create_message( stock_name, timestamp_latest, current_price, quantity) print(message) if is_drop: view.broadcast(message)