anilshanbhag / RobinhoodShell

A command line shell for trading stocks using Robinhood
MIT License
411 stars 94 forks source link

list portfolio fails #36

Open cfredericksen opened 4 years ago

cfredericksen commented 4 years ago

Welcome to the Robinhood shell. Type help or ? to list commands.

l ┌Account──────────┬─────────────────┬──────────────┐ │ Portfolio Value │ Change │ Buying Power │ ├─────────────────┼─────────────────┼──────────────┤ │ redactedredactedredacted │ └─────────────────┴─────────────────┴──────────────┘ Traceback (most recent call last): File "./shell.py", line 627, in RobinhoodShell().cmdloop() File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/cmd.py", line 138, in cmdloop stop = self.onecmd(line) File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/cmd.py", line 217, in onecmd return func(arg) File "./shell.py", line 150, in do_l price = market_data[i]['last_trade_price'] TypeError: 'NoneType' object is not subscriptable

Cannot list my portfolio.

version: Python 3.7.7

anilshanbhag commented 4 years ago

That is strange, do you know which stock symbol it is failing on ? To find out could you go to line 150 and just add

print(symbol)

cfredericksen commented 4 years ago

┌Account──────────┬───────────────┬──────────────┐ │ Portfolio Value │ Change │ Buying Power │ ├─────────────────┼───────────────┼──────────────┤ │ redacted │ 60.64 (0.11%) │ redacted │ └─────────────────┴───────────────┴──────────────┘ VZ UNISQ Traceback (most recent call last): File "./shell.py", line 628, in RobinhoodShell().cmdloop() File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/cmd.py", line 138, in cmdloop stop = self.onecmd(line) File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/cmd.py", line 217, in onecmd return func(arg) File "./shell.py", line 151, in do_l price = market_data[i]['last_trade_price'] TypeError: 'NoneType' object is not subscriptable

UNISQ doesnt have any chart data as it was pulled from trading.

h0lybyte commented 4 years ago

I ran into the same issue!

The reason for the error is because the stock "UNISQ" went bankrupt. So we would need to add a special rule to exclude stock tickers that went bankrupt or about to be de-listed.

Ideally a blockticker.txt ? and have it cross reference any stock that causes issues. This can also happen during stock splits too or ticker renaming.