0

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 .isupper()?).

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.

Example of the portfolio page with double entries

Discrepancy of lowercase vs. uppercase stock symbols

0

how about toupper(in c) or upper(python)?

Best practice is to convert every symbol to uppercase before putting it into a table and before trying to do a search on a symbol.

BTW, isupper only checks whether a string is uppercase and returns true or false. In Python, upper returns the actual string in uppercase.

| improve this answer | |
  • So far, so good. Thanks! – azb1297 Mar 2 at 18:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .