yfinance icon indicating copy to clipboard operation
yfinance copied to clipboard

Code seems faulty

Open paulmcq opened this issue 2 years ago • 2 comments

I have not seen a bug in execution, but reading this code in ranaroussi/yfinance/feature/prune-info/yfinance/scrapers/quote.py, it appears wrong to me.

I do not understand where this k gets a value in _scrape_complementary() line 293: if k not in key_stats:

ranaroussi/yfinance/feature/prune-info/yfinance/scrapers/quote.py: 290 .. 299

            json_data = json.loads(json_str)
            key_stats = json_data["timeseries"]["result"][0]
            if k not in key_stats:
                # Yahoo website prints N/A, indicates Yahoo lacks necessary data to calculate
                v = None
            else:
                # Select most recent (last) raw value in list:
                v = key_stats[k][-1]["reportedValue"]["raw"]
            self._info[k] = v

paulmcq avatar Jan 15 '23 15:01 paulmcq

Should be in a for k in keys: . Do you mind submitting a fix?

ValueRaider avatar Jan 15 '23 16:01 ValueRaider

I would not mind submitting a fix, but I am not now set up to do development on yfinance. I know it is basically a git clone, then edit the file, push, and test. However, my code files and virtual environments are such a mess that it will take a while before that can be sanitary. I just noticed this whilst browsing the code. I do not even have a test case. I will eventually get straightened out, but thought it best to expose the issue sooner.

paulmcq avatar Jan 15 '23 16:01 paulmcq