pmorissette / ffn

ffn - a financial function library for Python
pmorissette.github.io/ffn
MIT License
2.03k stars 300 forks source link

yfinance dependency triggers import fail in downstream project #198

Closed karrmagadgeteer2 closed 1 year ago

karrmagadgeteer2 commented 1 year ago

I have been using ffn>=0.3.6. Upon the release of 0.3.7 I get the below import fail when attempting to run the test suite on our project, OpenSeries. I do not get the fail if I nail the version to 0.3.6. It may be an issue with yfinance but raising it here. Please let me know if you feel it misdirected. I am running Python 3.10. The fail occurs on both Linux and Windows.

____________________________ ERROR collecting tests/test_frame.py ________________________
venv/lib/python3.10/site-packages/_pytest/python.py:617: in _importtestmodule
    mod = import_path(self.path, mode=importmode, root=self.config.rootpath)
venv/lib/python3.10/site-packages/_pytest/pathlib.py:564: in import_path
    importlib.import_module(module_name)
/usr/lib/python3.10/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
<frozen importlib._bootstrap>:1050: in _gcd_import
    ???
<frozen importlib._bootstrap>:1027: in _find_and_load
    ???
<frozen importlib._bootstrap>:1006: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:688: in _load_unlocked
    ???
venv/lib/python3.10/site-packages/_pytest/assertion/rewrite.py:172: in exec_module
    exec(co, module.__dict__)
tests/test_frame.py:13: in <module>
    from tests.simulate import make_simulated_data_from_merton_jump_gbm
tests/simulate.py:10: in <module>
    from openseries.frame import OpenFrame
openseries/frame.py:15: in <module>
    from ffn.core import calc_mean_var_weights, calc_inv_vol_weights, calc_erc_weights
venv/lib/python3.10/site-packages/ffn/__init__.py:2: in <module>
    from . import data
venv/lib/python3.10/site-packages/ffn/data.py:3: in <module>
    import yfinance
venv/lib/python3.10/site-packages/yfinance/__init__.py:23: in <module>
    from .ticker import Ticker
venv/lib/python3.10/site-packages/yfinance/ticker.py:29: in <module>
    from .base import TickerBase
venv/lib/python3.10/site-packages/yfinance/base.py:33: in <module>
    from .data import TickerData
E     File "/home/xxx/workgit/OpenSeries/venv/lib/python3.10/site-packages/yfinance/data.py", line 217
E       re_data = json.loads(re.search("root.App.main\s+=\s+(\{.*\})", re_script).group(1))
E                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E   SyntaxError: invalid escape sequence '\s'