finance: Fixed making directories for explicit cachename

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.