In finance.fetch_historical_yahoo, if an explicit cachename is supplied, the code still attempts to create a directory in the usual cache location (which is not necessary), and fails to create directories required for the supplied cache directory.
I have patched it so that it creates the necessary directories leading up to cachename.
As an aside, I also fixed it so that it explicitly closes the URL object opened by urlopen and uses the modern with style context managers.
finance.fetch_historical_yahoo: Create directories leading up to cach…
Previously, if cachename was specified, it would create the directories to
cachedir instead, resulting in OSError if the directories leading up to
cachename were not specified.
finance: Use context manager to close files.
Previously, the urllib object opened in fetch_historical_yahoo was not
👍 Thanks @mgiuca-google