Error when running the app_5.py code, yfinance complains that 2d is a invalid duration. Changing this to 5d (the next valid option) worked.
previous_price = stock.history(period="2d")['Close'].iloc[0]
previous_price = stock.history(period="5d")['Close'].iloc[0]