I think the line
if price * shares > cash:
might be problematic on multiple stages.
Here, price
would be the float, and shares
the sequence.
shares
is probably a string and needs conversion to integer first (also reject it if it contains any non-digit)
cash
is a list of dicts, most likely containing exactly one dict with one value. The value you want is probably at cash[0]["cash"]
.
Your app is in debug mode. Within werkzeug's debug mode, you can open a python console at where the crash happened, printing the variables and experiencing some surprise from time to time.