Some assets do not have long names on YT finance
bolapara opened this issue · comments
When looking up the BTC-USD asset, I get the following traceback:
Traceback (most recent call last): File "/home/josh/.local/bin/lak", line 8, in <module> sys.exit(lak()) File "/home/josh/.local/lib/python3.8/site-packages/click/core.py", line 1128, in __call__ return self.main(*args, **kwargs) File "/home/josh/.local/lib/python3.8/site-packages/click/core.py", line 1053, in main rv = self.invoke(ctx) File "/home/josh/.local/lib/python3.8/site-packages/click/core.py", line 1659, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/home/josh/.local/lib/python3.8/site-packages/click/core.py", line 1690, in invoke rv.append(sub_ctx.command.invoke(sub_ctx)) File "/home/josh/.local/lib/python3.8/site-packages/click/core.py", line 1395, in invoke return ctx.invoke(self.callback, **ctx.params) File "/home/josh/.local/lib/python3.8/site-packages/click/core.py", line 754, in invoke return __callback(*args, **kwargs) File "/home/josh/.local/lib/python3.8/site-packages/lakshmi/lak.py", line 272, in assets output = portfolio.assets( File "/home/josh/.local/lib/python3.8/site-packages/lakshmi/lakshmi.py", line 636, in assets + [asset.name(), asset.adjusted_value()]) File "/home/josh/.local/lib/python3.8/site-packages/lakshmi/cache.py", line 174, in new_func value = call_func(class_obj, func) File "/home/josh/.local/lib/python3.8/site-packages/lakshmi/cache.py", line 138, in call_func return func(class_obj) File "/home/josh/.local/lib/python3.8/site-packages/lakshmi/assets.py", line 489, in name raise NotFoundError( lakshmi.assets.NotFoundError: Cannot retrieve ticker ("BTC-USD") from Yahoo Finance
I found that this asset does not actually have a longName field in the ticker object provided by YT API. There are a few other name fields so I've got a PR coming shortly to try to fall back to some other naming fields if the longName field does not exist.
Thanks for catching this. Could you please add a unit test in test_assets.py for this case as well?
Thanks for the quick fix. Please let me know if you want me to push a new release to pypi?
I can run with my local changes until you update. Thanks.
These changes are now released in lakshmi v2.1.2