ValueRaider / yfinance-cache

Caching wrapper for yfinance module. Intelligent caching, not dumb caching of web requests.
MIT License
37 stars 13 forks source link

Need to add mapping of exchange {exchange} to xcal (ticker={self._ticker}) #77

Open hajes opened 6 days ago

hajes commented 6 days ago

hi,

I have a little script for options. I have used yfinance, but it always fetches all data despite use of cache.

print(ticker.info)

no issues

ohlc_data = ticker.history(period="1y", interval="1d", actions=False, adjust_splits=False, adjust_divs=False)

ends up with following error:

Traceback (most recent call last): File "<string>", line 1, in <module> File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.2032.0_x64__qbz5n2kfra8p0\Lib\multiprocessing\spawn.py", line 122, in spawn_main exitcode = _main(fd, parent_sentinel) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.2032.0_x64__qbz5n2kfra8p0\Lib\multiprocessing\spawn.py", line 131, in _main prepare(preparation_data) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.2032.0_x64__qbz5n2kfra8p0\Lib\multiprocessing\spawn.py", line 246, in prepare _fixup_main_from_path(data['init_main_from_path']) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.2032.0_x64__qbz5n2kfra8p0\Lib\multiprocessing\spawn.py", line 297, in _fixup_main_from_path main_content = runpy.run_path(main_path, ^^^^^^^^^^^^^^^^^^^^^^^^^ File "<frozen runpy>", line 287, in run_path File "<frozen runpy>", line 98, in _run_module_code File "<frozen runpy>", line 88, in _run_code File "c:\Users\hajes\Dropbox\_programing_scripts\python_scripts\trading\options-screener\options-scanner.py", line 188, in <module> screener_list.append(get_ticker_stats(i, etf=0)) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "c:\Users\hajes\Dropbox\_programing_scripts\python_scripts\trading\options-screener\options-scanner.py", line 124, in get_ticker_stats ohlc_data = ticker.history(period="1y") ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\hajes\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\yfinance_cache\yfc_ticker.py", line 108, in history raise Exception(f"Need to add mapping of exchange {exchange} to xcal (ticker={self._ticker})") Exception: Need to add mapping of exchange NMS to xcal (ticker=NVDA)

ValueRaider commented 6 days ago

Looks like a Windows issue, and I don't have Windows to test fixes. Look here: https://github.com/ValueRaider/yfinance-cache/blob/b418b163f9e12e46ccd20deea8bb79bc66f20c83/yfinance_cache/yfc_dat.py#L281-L287

I know you aren't running parallel, but exchange_locks needs to be initialised anyway.