I noticed a beta-tester was typing in the stock symbols in lower case. This didn't seem to cause a problem for purchasing or selling, and the transactions appeared in the History table. However, they do not show up in the index/portfolio.
If the same stock is attempted to be sold, but in uppercase, it claims there is no such stock and thus cannot sell it.
When the same stock is bought in uppercase, the purchase goes through once, but appears in the portfolio table twice (and the lowercase version of the stock bought is still not reflected in the table).
I was under the impression that the lookup() function would take care of this problem as it seems to find the correct stock name and price.
I tried using
.isupper() when grabbing the stock symbol, but it didn't seem to work. My attempt:
the_stock_symbol = request.form.get("symbol") big_symbol = the_stock_symbol.isupper() quote = lookup(big_symbol)
but this threw an error:
File "/usr/local/lib/python3.7/urllib/parse.py", line 839, in quote_from_bytes raise TypeError("quote_from_bytes() expected bytes") TypeError: quote_from_bytes() expected bytes
which, from what I understand, means that something is not being considered a string when it should be (perhaps
the_stock_symbol since that's what I'm trying to use with
Some images below (1: the portfolio page with double entries. 2: History of transactions showing discrepancy of lower vs. uppercase stock symbols).
Overall question is: how can I ensure a lowercase entry isn't considered different from an uppercase entry?
Any thoughts appreciated.